diff --git a/lib/pact_broker/pacts/repository.rb b/lib/pact_broker/pacts/repository.rb index 2ddf9d45c..3c3bca3ae 100644 --- a/lib/pact_broker/pacts/repository.rb +++ b/lib/pact_broker/pacts/repository.rb @@ -357,12 +357,11 @@ def find_for_verification(provider_name, consumer_version_selectors) selected_pacts = selected_pacts + find_pacts_for_fallback_tags(selected_pacts, provider_name, consumer_version_selectors) selected_pacts - .group_by(&:pact_version_sha) + .group_by{ |p| [p.consumer_name, p.pact_version_sha] } .values .collect do | selected_pacts_for_pact_version_id | SelectedPact.merge(selected_pacts_for_pact_version_id) end - end private diff --git a/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb b/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb index 2eb27a451..100640aa2 100644 --- a/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +++ b/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb @@ -6,7 +6,6 @@ module Pacts let(:td) { TestDataBuilder.new } describe "#find_for_verification" do - def find_by_consumer_version_number(consumer_version_number) subject.find{ |pact| pact.consumer_version_number == consumer_version_number } end @@ -189,6 +188,24 @@ def find_by_consumer_name_and_consumer_version_number(consumer_name, consumer_ve expect(find_by_consumer_version_number("foo-latest-dev-version").overall_latest?).to be true end end + + context "when two consumers have exactly the same json content" do + before do + td.create_consumer + .create_provider("Bar") + .create_consumer_version + .create_pact(json_content: { interactions: ['foo'] }.to_json ) + .create_consumer + .create_consumer_version + .create_pact(json_content: { interactions: ['foo'] }.to_json ) + end + + let(:consumer_version_selectors) { Selectors.new } + + it "returns a pact for each consumer" do + expect(subject.size).to eq 2 + end + end end end end