Skip to content

Commit

Permalink
style: rename execute_webhooks to trigger_webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 16, 2018
1 parent b15ba85 commit 87a8416
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/pacts/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def update_pact params, existing_pact
updated_pact = pact_repository.update existing_pact.id, params

if existing_pact.json_content != updated_pact.json_content
webhook_service.execute_webhooks updated_pact, nil, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED
webhook_service.trigger_webhooks updated_pact, nil, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED
else
logger.debug "Pact has not changed since previous revision, not triggering webhooks"
end
Expand All @@ -127,7 +127,7 @@ def create_pact params, version, provider
def trigger_webhooks pact
# TODO add tests for this
if pact_is_new_or_pact_has_changed_since_previous_version?(pact)
webhook_service.execute_webhooks pact, nil, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED
webhook_service.trigger_webhooks pact, nil, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED
else
logger.debug "Pact has not changed since previous version, not triggering webhooks"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/verifications/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create next_verification_number, params, pact
PactBroker::Api::Decorators::VerificationDecorator.new(verification).from_hash(params)
verification.number = next_verification_number
verification = verification_repository.create(verification, provider_version_number, pact)
webhook_service.execute_webhooks pact, verification, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED
webhook_service.trigger_webhooks pact, verification, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED
verification
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/webhooks/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def self.find_by_consumer_and_provider consumer, provider
webhook_repository.find_by_consumer_and_provider consumer, provider
end

def self.execute_webhooks pact, verification, event_name
def self.trigger_webhooks pact, verification, event_name
webhooks = webhook_repository.find_by_consumer_and_provider_and_event_name pact.consumer, pact.provider, event_name

if webhooks.any?
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pact_broker/verifications/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Verifications

describe "#create" do
before do
allow(PactBroker::Webhooks::Service).to receive(:execute_webhooks)
allow(PactBroker::Webhooks::Service).to receive(:trigger_webhooks)
end

let(:params) { {'success' => true, 'providerApplicationVersion' => '4.5.6'} }
Expand Down Expand Up @@ -43,7 +43,7 @@ module Verifications

it "invokes the webhooks for the verification" do
verification = create_verification
expect(PactBroker::Webhooks::Service).to have_received(:execute_webhooks).with(pact, verification, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED)
expect(PactBroker::Webhooks::Service).to have_received(:trigger_webhooks).with(pact, verification, PactBroker::Webhooks::WebhookEvent::VERIFICATION_PUBLISHED)
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/lib/pact_broker/webhooks/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Webhooks
end
end

describe ".execute_webhooks" do
describe ".trigger_webhooks" do

let(:verification) { instance_double(PactBroker::Domain::Verification)}
let(:pact) { instance_double(PactBroker::Domain::Pact, consumer: consumer, provider: provider, consumer_version: consumer_version)}
Expand All @@ -44,7 +44,7 @@ module Webhooks
allow(Job).to receive(:perform_in)
end

subject { Service.execute_webhooks pact, verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED }
subject { Service.trigger_webhooks pact, verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED }

it "finds the webhooks" do
expect_any_instance_of(PactBroker::Webhooks::Repository).to receive(:find_by_consumer_and_provider_and_event_name).with(consumer, provider, PactBroker::Webhooks::WebhookEvent::DEFAULT_EVENT_NAME)
Expand Down Expand Up @@ -133,7 +133,7 @@ module Webhooks
end
end

describe ".execute_webhooks integration test" do
describe ".trigger_webhooks integration test" do
let!(:http_request) do
stub_request(:get, "http://example.org").
to_return(:status => 200)
Expand All @@ -151,7 +151,7 @@ module Webhooks
.and_return(:pact)
end

subject { PactBroker::Webhooks::Service.execute_webhooks pact, td.verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED }
subject { PactBroker::Webhooks::Service.trigger_webhooks pact, td.verification, PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED }

it "executes the HTTP request of the webhook" do
subject
Expand Down

0 comments on commit 87a8416

Please sign in to comment.