class PactBroker::Api::Resources::Verifications

Public Instance Methods

allowed_methods() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 27
def allowed_methods
  ["POST", "OPTIONS"]
end
content_types_accepted() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 19
def content_types_accepted
  [["application/json", :from_json]]
end
content_types_provided() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 23
def content_types_provided
  [["application/hal+json", :to_json]]
end
create_path() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 43
def create_path
  new_verification_url(pact, next_verification_number, base_url)
end
from_json() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 47
def from_json
  subscribe(PactBroker::Integrations::EventListener.new) do
    handle_webhook_events(build_url: verification_params["buildUrl"]) do
      verified_pacts = pact_service.find_for_verification_publication(pact_params, event_context[:consumer_version_selectors])
      verification = verification_service.create(next_verification_number, verification_params, verified_pacts, event_context)
      response.body = decorator_for(verification).to_json(**decorator_options)
    end
  end
  true
end
malformed_request?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 39
def malformed_request?
  super || (request.post? && validation_errors_for_schema?)
end
policy_name() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 58
def policy_name
  :'verifications::verifications'
end
post_is_create?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 31
def post_is_create?
  true
end
resource_exists?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 35
def resource_exists?
  !!pact
end

Private Instance Methods

decorator_for(model) click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 72
def decorator_for model
  decorator_class(:verification_decorator).new(model)
end
event_context() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 84
def event_context
  metadata
end
next_verification_number() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 68
def next_verification_number
  @next_verification_number ||= verification_service.next_number
end
pact() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 64
def pact
  @pact ||= pact_service.find_pact(pact_params)
end
pending?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 80
def pending?
  metadata[:pending]
end
schema() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 92
def schema
  PactBroker::Api::Contracts::VerificationContract
end
verification_params() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 88
def verification_params
  params(symbolize_names: false).merge("wip" => wip?, "pending" => pending?)
end
wip?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 76
def wip?
  metadata[:wip] == "true"
end