Skip to content

Commit

Permalink
feat: remove feature toggle around change to return the pact for the …
Browse files Browse the repository at this point in the history
…latest tagged version, rather than the latest pact that has a version with the tag
  • Loading branch information
bethesque committed Nov 14, 2021
1 parent a268ef2 commit fac3fc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
38 changes: 17 additions & 21 deletions lib/pact_broker/pacts/pact_publication_dataset_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,28 +204,24 @@ def latest_for_consumer_tag(tag_name)
# The pacts for the latest versions with the specified tag (new logic)
# NOT the latest pact that belongs to a version with the specified tag.
def for_latest_consumer_versions_with_tag(tag_name)
if PactBroker.feature_enabled?(:fix_issue_494)
head_tags = PactBroker::Domain::Tag
.select_group(:pacticipant_id, :name)
.select_append{ max(version_order).as(:latest_version_order) }
.where(name: tag_name)

head_tags_join = {
Sequel[:pact_publications][:consumer_id] => Sequel[:head_tags][:pacticipant_id],
Sequel[:pact_publications][:consumer_version_order] => Sequel[:head_tags][:latest_version_order]
}

base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:head_tags][:name].as(:tag_name))
end

base_query
.join(head_tags, head_tags_join, { table_alias: :head_tags })
.remove_overridden_revisions_from_complete_query
else
latest_for_consumer_tag(tag_name)
head_tags = PactBroker::Domain::Tag
.select_group(:pacticipant_id, :name)
.select_append{ max(version_order).as(:latest_version_order) }
.where(name: tag_name)

head_tags_join = {
Sequel[:pact_publications][:consumer_id] => Sequel[:head_tags][:pacticipant_id],
Sequel[:pact_publications][:consumer_version_order] => Sequel[:head_tags][:latest_version_order]
}

base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:head_tags][:name].as(:tag_name))
end

base_query
.join(head_tags, head_tags_join, { table_alias: :head_tags })
.remove_overridden_revisions_from_complete_query
end

def in_environments
Expand Down
10 changes: 0 additions & 10 deletions spec/lib/pact_broker/pacts/pact_publication_dataset_module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,6 @@ module Pacts
it "returns an empty list" do
expect(subject.all).to eq []
end

context "with the feature_toggle disabled" do
before do
allow(PactBroker).to receive(:feature_enabled?).with(:fix_issue_494).and_return(false)
end

it "returns pacts" do
expect(subject.all.size).to eq 2
end
end
end

context "when columns are already selected" do
Expand Down

0 comments on commit fac3fc8

Please sign in to comment.