Skip to content

Commit

Permalink
chore: upgrade to reform 2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed May 22, 2020
1 parent 7fe0aa9 commit 0954ac0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/pact_broker/api/contracts/webhook_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions lib/pact_broker/webhooks/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pact_broker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 0954ac0

Please sign in to comment.