lib/pact_broker/api/resources/pact.rb in pact_broker-2.108.0 vs lib/pact_broker/api/resources/pact.rb in pact_broker-2.109.0

- old
+ new

@@ -69,13 +69,13 @@ response_code = pact ? 200 : 201 subscribe(PactBroker::Integrations::EventListener.new) do handle_webhook_events do if request.patch? && resource_exists? - @pact = pact_service.merge_pact(pact_params) + @pact = pact_service.merge_pact(pact_params.merge(pact_version_sha: pact_version_sha)) else - @pact = pact_service.create_or_update_pact(pact_params) + @pact = pact_service.create_or_update_pact(pact_params.merge(pact_version_sha: pact_version_sha)) end end end response.body = to_json response_code @@ -112,20 +112,24 @@ def pact @pact ||= pact_service.find_pact(pact_params) end def disallowed_modification? - if request.really_put? && pact_service.disallowed_modification?(pact, pact_params.json_content) + if request.really_put? && pact_service.disallowed_modification?(pact, pact_version_sha) message_params = { consumer_name: pact_params.consumer_name, consumer_version_number: pact_params.consumer_version_number, provider_name: pact_params.provider_name } set_json_error_message(message("errors.validation.pact_content_modification_not_allowed", message_params)) true else false end end def schema api_contract_class(:put_pact_params_contract) + end + + def pact_version_sha + @pact_version_sha ||= pact_service.generate_sha(pact_params.json_content) end end end end end