From 0954ac065220d90c5dfa404941630c7905f6c4ea Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 22 May 2020 15:31:45 +1000 Subject: [PATCH] chore: upgrade to reform 2.3.1 --- lib/pact_broker/api/contracts/webhook_contract.rb | 10 ++++++---- lib/pact_broker/webhooks/service.rb | 7 ++++--- pact_broker.gemspec | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/pact_broker/api/contracts/webhook_contract.rb b/lib/pact_broker/api/contracts/webhook_contract.rb index 5b0903b7b..c86b5a86a 100644 --- a/lib/pact_broker/api/contracts/webhook_contract.rb +++ b/lib/pact_broker/api/contracts/webhook_contract.rb @@ -14,11 +14,13 @@ def validate(*) # I just cannot seem to get the validation to stop on the first error. # If one rule fails, they all come back failed, and it's driving me nuts. # Why on earth would I want that behaviour? - new_errors = Reform::Contract::Errors.new - errors.messages.each do | key, value | - new_errors.add(key, value.first) + # I cannot believe I have to do this shit. + @first_errors = errors + @first_errors.messages.keys.each do | key | + @first_errors.messages[key] = @first_errors.messages[key][0...1] end - @errors = new_errors + + def self.errors; @first_errors end result end diff --git a/lib/pact_broker/webhooks/service.rb b/lib/pact_broker/webhooks/service.rb index ec9524bb0..3482921aa 100644 --- a/lib/pact_broker/webhooks/service.rb +++ b/lib/pact_broker/webhooks/service.rb @@ -40,12 +40,13 @@ def self.next_uuid def self.errors webhook, uuid = nil contract = PactBroker::Api::Contracts::WebhookContract.new(webhook) contract.validate(webhook.attributes) - errors = contract.errors + messages = contract.errors.messages if uuid && !valid_uuid_format?(uuid) - errors.add("uuid", message("errors.validation.invalid_webhook_uuid")) + messages["uuid"] = [message("errors.validation.invalid_webhook_uuid")] end - errors + + OpenStruct.new(messages: messages, empty?: messages.empty?, any?: messages.any?) end def self.create uuid, webhook, consumer, provider diff --git a/pact_broker.gemspec b/pact_broker.gemspec index 1c92b239e..d113dc051 100644 --- a/pact_broker.gemspec +++ b/pact_broker.gemspec @@ -46,7 +46,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'httparty', '~> 0.14' gem.add_runtime_dependency 'json', '~> 2.3' gem.add_runtime_dependency 'roar', '~> 1.1' - gem.add_runtime_dependency 'reform', '~> 2.2' + gem.add_runtime_dependency 'reform', '~> 2.3','>= 2.3.1' gem.add_runtime_dependency 'dry-validation', '~> 0.10.5' gem.add_runtime_dependency 'sequel', '~> 5.28' gem.add_runtime_dependency 'webmachine', '1.5.0'