diff --git a/lib/pact_broker/index/service.rb b/lib/pact_broker/index/service.rb index 180d08016..d31e0cb40 100644 --- a/lib/pact_broker/index/service.rb +++ b/lib/pact_broker/index/service.rb @@ -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 @@ -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 diff --git a/spec/lib/pact_broker/index/service_spec.rb b/spec/lib/pact_broker/index/service_spec.rb index 484f0db42..c953bd1ef 100644 --- a/spec/lib/pact_broker/index/service_spec.rb +++ b/spec/lib/pact_broker/index/service_spec.rb @@ -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