diff --git a/lib/pact_broker/pacts/service.rb b/lib/pact_broker/pacts/service.rb index 955677310..70b059772 100644 --- a/lib/pact_broker/pacts/service.rb +++ b/lib/pact_broker/pacts/service.rb @@ -59,7 +59,7 @@ def merge_pact params consumer_version = version_repository.find_by_pacticipant_id_and_number_or_create consumer.id, params[:consumer_version_number] existing_pact = pact_repository.find_by_version_and_provider(consumer_version.id, provider.id) - params.merge!(json_content: Merger.merge_pacts(params[:json_content], existing_pact.json_content)) + params.merge!(json_content: Merger.merge_pacts(existing_pact.json_content, params[:json_content])) update_pact params, existing_pact end diff --git a/spec/features/merge_pact_spec.rb b/spec/features/merge_pact_spec.rb index e58ffe416..8b3f8264f 100644 --- a/spec/features/merge_pact_spec.rb +++ b/spec/features/merge_pact_spec.rb @@ -29,7 +29,7 @@ let(:merged_pact_content) { load_fixture('a_consumer-a_provider-merged.json') } before do - TestDataBuilder.new.create_pact_with_hierarchy("A Consumer", "1.2.3", "A Provider", existing_pact_content).and_return(:pact) + TestDataBuilder.new.create_pact_with_hierarchy("A Consumer", "1.2.3", "A Provider", existing_pact_content) end it "returns a 200 Success" do diff --git a/spec/fixtures/a_consumer-a_provider-merged.json b/spec/fixtures/a_consumer-a_provider-merged.json index bdebe24d2..73fbe7f3a 100644 --- a/spec/fixtures/a_consumer-a_provider-merged.json +++ b/spec/fixtures/a_consumer-a_provider-merged.json @@ -7,11 +7,11 @@ }, "interactions": [ { - "description" : "a request for something", + "description" : "another request for something", "providerState": null, "request": { "method": "get", - "path" : "/something" + "path" : "/something_else" }, "response": { "status": 200, @@ -19,11 +19,11 @@ } }, { - "description" : "another request for something", + "description" : "a request for something", "providerState": null, "request": { "method": "get", - "path" : "/something_else" + "path" : "/something" }, "response": { "status": 200,