Skip to content

Commit

Permalink
feat: include deployed and released versions in index page when viewi…
Browse files Browse the repository at this point in the history
…ng latest tags
  • Loading branch information
bethesque committed Jul 15, 2021
1 parent ad6774b commit 655e9dd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
5 changes: 2 additions & 3 deletions lib/pact_broker/index/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def self.head_pact_publications(options = {})
]

query.order(*order_columns)
.paginate(options[:page_number] || DEFAULT_PAGE_NUMBER, options[:page_size] || DEFAULT_PAGE_SIZE)
.paginate(options[:page_number] || DEFAULT_PAGE_NUMBER, options[:page_size] || DEFAULT_PAGE_SIZE)
end

# eager loading the tag stuff doesn't seem to make it quicker
Expand All @@ -196,8 +196,7 @@ def self.latest_verifications_for_consumer_version_tags(options)
def self.query_pact_publication_ids_by_tags(base, tags)
latest = base.overall_latest
return latest.union(base.latest_for_consumer_tag(tags)) if tags.is_a?(Array)
return latest.union(base.latest_by_consumer_tag) if tags

return latest.union(base.latest_by_consumer_tag).union(base.for_environment(nil)) if tags
latest
end

Expand Down
44 changes: 28 additions & 16 deletions spec/lib/pact_broker/index/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,29 +363,41 @@ module Index
end

describe "find_index_items_for_api" do
before do
td.create_pact_with_hierarchy("Foo", "1", "Bar")
.create_consumer_version_tag("feat-x")
.create_verification(provider_version: "1", comment: "latest feat-x verif")
.create_consumer_version("2")
.create_consumer_version_tag("feat-y")
.create_pact
.create_verification(provider_version: "2", comment: "latest feat-y verif")
.create_consumer_version("3")
.create_consumer_version_tag("feat-x")
.create_consumer_version_tag("feat-y")
.create_pact
.create_consumer_version("4")
.create_pact
end

let(:rows) { subject.find_index_items_for_api(consumer_name: td.consumer.name, provider_name: td.provider.name) }

context "when the pact has not yet been verified" do
before do
td.create_pact_with_hierarchy("Foo", "1", "Bar")
.create_consumer_version_tag("feat-x")
.create_verification(provider_version: "1", comment: "latest feat-x verif")
.create_consumer_version("2")
.create_consumer_version_tag("feat-y")
.create_pact
.create_verification(provider_version: "2", comment: "latest feat-y verif")
.create_consumer_version("3")
.create_consumer_version_tag("feat-x")
.create_consumer_version_tag("feat-y")
.create_pact
.create_consumer_version("4")
.create_pact
end
it "returns the latest verification as nil (unlike the pseudo branch code for the server side rendered UI)" do
expect(rows.last.provider_version_number).to be nil
end
end

context "when a version is currently deployed" do
before do
td.create_environment("test")
.create_pact_with_hierarchy("Foo", "1", "Bar")
.create_deployed_version_for_consumer_version
.create_pact_with_hierarchy("Foo", "2", "Bar")
end

it "includes the deployed versions" do
expect(rows.size).to eq 2
end
end
end
end
end
Expand Down

0 comments on commit 655e9dd

Please sign in to comment.