Skip to content

Commit

Permalink
chore: update policy names
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 9, 2020
1 parent c319146 commit 09cdcc5
Show file tree
Hide file tree
Showing 39 changed files with 140 additions and 134 deletions.
5 changes: 0 additions & 5 deletions lib/pact_broker/api/resources/all_webhooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ def policy_name
:'webhooks::webooks'
end

def policy_record
# Note: consumer and provider not yet set on new webhook
request.post? ? webhook : webhooks
end

private

def validation_errors? webhook
Expand Down
4 changes: 0 additions & 4 deletions lib/pact_broker/api/resources/can_i_deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ def policy_name
:'matrix::can_i_deploy'
end

def policy_record
selectors
end

private

attr_reader :query_params, :selectors, :options
Expand Down
9 changes: 9 additions & 0 deletions lib/pact_broker/api/resources/default_base_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ def pact
@pact ||= pact_service.find_pact(pact_params)
end

# Not necessarily an existing integration
def integration
if consumer_specified? && provider_specified?
OpenStruct.new(consumer: consumer, provider: provider)
else
nil
end
end

def database_connector
request.env["pactbroker.database_connector"]
end
Expand Down
6 changes: 4 additions & 2 deletions lib/pact_broker/api/resources/error_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
module PactBroker
module Api
module Resources

class ErrorTest < BaseResource

def content_types_provided
[
["application/hal+json", :to_json]
Expand All @@ -24,6 +22,10 @@ def to_json
def process_post
raise PactBroker::TestError.new("Don't panic. This is a test API error.")
end

def policy_name
:'default'
end
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions lib/pact_broker/api/resources/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ def policy_name
:'groups::group'
end

def policy_record
pacticipant
end

private

def group
Expand Down
4 changes: 0 additions & 4 deletions lib/pact_broker/api/resources/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ def policy_name
:'integrations::integration'
end

def policy_resource
integration
end

def integration
@integration ||= OpenStruct.new(consumer: consumer, provider: provider)
end
Expand Down
4 changes: 0 additions & 4 deletions lib/pact_broker/api/resources/integrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ def delete_resource
def policy_name
:'integrations::integrations'
end

def policy_resource
integrations
end
end
end
end
Expand Down
8 changes: 0 additions & 8 deletions lib/pact_broker/api/resources/label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,10 @@ def resource_exists?
!!label
end

def resource_object
label
end

def policy_name
:'labels::label'
end

def policy_record
label
end

def to_json
PactBroker::Api::Decorators::LabelDecorator.new(label).to_json(decorator_options)
end
Expand Down
6 changes: 1 addition & 5 deletions lib/pact_broker/api/resources/latest_pact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ def resource_exists?
end

def policy_name
:'pacts:pact'
end

def policy_record
pact
:'pacts::pact'
end

def to_json
Expand Down
6 changes: 1 addition & 5 deletions lib/pact_broker/api/resources/latest_pacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ def pacts
end

def policy_name
:'pacts:pacts'
end

def policy_record
pacts
:'pacts::pacts'
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ def policy_name
:'verifications::verifications'
end

def policy_record
version
end

private

def version
Expand Down
4 changes: 4 additions & 0 deletions lib/pact_broker/api/resources/matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def to_text
PactBroker::Api::Decorators::MatrixTextDecorator.new(results).to_text(decorator_options)
end

def policy_name
:'matrix::matrix'
end

def results
@results ||= matrix_service.find(selectors, options)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def to_json
PactBroker::Api::Decorators::MatrixDecorator.new(results).to_json(decorator_options)
end

def policy_name
:'matrix::matrix'
end

private

attr_reader :options
Expand Down
4 changes: 4 additions & 0 deletions lib/pact_broker/api/resources/metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def allowed_methods
def to_json
metrics_service.metrics.to_json
end

def policy_name
:'metrics::metrics'
end
end
end
end
Expand Down
12 changes: 4 additions & 8 deletions lib/pact_broker/api/resources/pact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ def resource_exists?
!!pact
end

def resource_object
pact
end

def policy_resource
pact
end

def from_json
response_code = pact ? 200 : 201

Expand Down Expand Up @@ -96,6 +88,10 @@ def delete_resource
true
end

def policy_name
:'pacts::pact'
end

private

def pact
Expand Down
4 changes: 4 additions & 0 deletions lib/pact_broker/api/resources/pact_content_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def pact_params
@pact_params ||= PactBroker::Pacts::PactParams.from_path_info identifier_from_path
end

def policy_name
:'pacts::pact'
end

def comparison_pact_params
if identifier_from_path[:comparison_consumer_version_number] || identifier_from_path[:comparison_pact_version_sha]
comparison_identifier_from_path = identifier_from_path.merge(
Expand Down
6 changes: 5 additions & 1 deletion lib/pact_broker/api/resources/pact_triggered_webhooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ def to_json
Decorators::TriggeredWebhooksDecorator.new(triggered_webhooks).to_json(decorator_options(resource_title: resource_title))
end

def policy_name
:'webhooks::webhooks'
end

private

def triggered_webhooks
webhook_service.find_triggered_webhooks_for_pact(pact)
@webhooks ||= webhook_service.find_triggered_webhooks_for_pact(pact)
end

def resource_title
Expand Down
6 changes: 5 additions & 1 deletion lib/pact_broker/api/resources/pact_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ def to_json
end

def pacts
pact_service.find_all_pact_versions_between consumer_name, :and => provider_name
@pacts ||= pact_service.find_all_pact_versions_between consumer_name, :and => provider_name
end

def delete_resource
pact_service.delete_all_pact_publications_between(consumer_name, and: provider_name)
true
end

def policy_name
:'pacts::pacts'
end
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/pact_broker/api/resources/pact_webhooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ def to_json
Decorators::WebhooksDecorator.new(webhooks).to_json(user_options: decorator_context(resource_title: 'Pact webhooks'))
end

def policy_name
:'webhooks::webhooks'
end

private

def webhooks
webhook_service.find_by_consumer_and_provider consumer, provider
@webhooks ||= webhook_service.find_by_consumer_and_provider consumer, provider
end

def webhook
Expand Down
6 changes: 5 additions & 1 deletion lib/pact_broker/api/resources/pact_webhooks_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def to_json
decorator_for(latest_triggered_webhooks).to_json(user_options: decorator_context(identifier_from_path))
end

def policy_name
:'webhooks::webhooks'
end

private

def latest_triggered_webhooks
Expand All @@ -33,7 +37,7 @@ def pact
end

def webhooks
webhook_service.find_by_consumer_and_provider(consumer, provider)
@webhooks ||= webhook_service.find_by_consumer_and_provider(consumer, provider)
end

def decorator_for latest_triggered_webhooks
Expand Down
14 changes: 5 additions & 9 deletions lib/pact_broker/api/resources/pacticipant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,7 @@ def from_json
end

def resource_exists?
!!resource_object
end

def resource_object
pacticipant
end

def policy_resource
pacticipant
!!pacticipant
end

def delete_resource
Expand All @@ -59,6 +51,10 @@ def delete_resource
def to_json
PactBroker::Api::Decorators::PacticipantDecorator.new(pacticipant).to_json(decorator_options)
end

def policy_name
:'pacticipants::pacticipant'
end
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions lib/pact_broker/api/resources/pacticipants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ def policy_name
:'pacticipants::pacticipants'
end

def policy_record
request.post? ? nil : pacticipants
end

private

def pacticipants
Expand Down
4 changes: 4 additions & 0 deletions lib/pact_broker/api/resources/pacticipants_for_label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def to_json
def generate_json pacticipants
PactBroker::Api::Decorators::PacticipantCollectionDecorator.new(pacticipants).to_json(decorator_options)
end

def policy_name
:'pacticipants::pacticipants'
end
end
end
end
Expand Down
13 changes: 4 additions & 9 deletions lib/pact_broker/api/resources/previous_distinct_pact_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ def allowed_methods
end

def resource_exists?
!!resource_object
end

def resource_object
pact
end

def policy_resource
pact
!!pact
end

def to_json
Expand All @@ -40,6 +32,9 @@ def pact_params
@pact_params ||= PactBroker::Pacts::PactParams.from_request request, path_info
end

def policy_name
:'pacts::pact'
end
end
end
end
Expand Down
6 changes: 1 addition & 5 deletions lib/pact_broker/api/resources/provider_pacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ def resource_exists?
end

def policy_name
:'pacts:provider_pacts'
end

def policy_record
provider
:'pacts::pacts'
end

def to_json
Expand Down
Loading

0 comments on commit 09cdcc5

Please sign in to comment.