File tree 2 files changed +23
-3
lines changed
spec/lib/pact_broker/webhooks
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,20 @@ def perform data
18
18
19
19
private
20
20
21
- attr_reader :triggered_webhook , :error_count
21
+ attr_reader :triggered_webhook , :error_count , :data
22
22
23
23
def perform_with_connection ( data )
24
24
@data = data
25
- @triggered_webhook = PactBroker ::Webhooks ::TriggeredWebhook . find ( id : data [ :triggered_webhook ] . id )
25
+ triggered_webhook_id = data [ :triggered_webhook ] . id
26
+ @triggered_webhook = PactBroker ::Webhooks ::TriggeredWebhook . find ( id : triggered_webhook_id )
27
+ if triggered_webhook
28
+ perform_with_triggered_webhook
29
+ else
30
+ logger . info "Could not find webhook with id: #{ triggered_webhook_id } "
31
+ end
32
+ end
33
+
34
+ def perform_with_triggered_webhook
26
35
@error_count = data [ :error_count ] || 0
27
36
begin
28
37
webhook_execution_result = PactBroker ::Webhooks ::Service . execute_triggered_webhook_now triggered_webhook , execution_options ( data )
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ module Webhooks
26
26
end
27
27
28
28
context "when the job succeeds" do
29
-
30
29
it "does not reschedule the job" do
31
30
expect ( Job ) . to_not receive ( :perform_in )
32
31
subject
@@ -131,6 +130,18 @@ module Webhooks
131
130
subject
132
131
end
133
132
end
133
+
134
+ context "when the webhook gets deleted between executions" do
135
+ before do
136
+ allow ( PactBroker ::Webhooks ::TriggeredWebhook ) . to receive ( :find ) . and_return ( nil )
137
+ end
138
+
139
+ it "does not reschedule the job" do
140
+ expect ( Job ) . to_not receive ( :perform_in )
141
+ expect ( logger ) . to receive ( :info ) . with ( /Could not find webhook with id: 1/ )
142
+ subject
143
+ end
144
+ end
134
145
end
135
146
end
136
147
end
You can’t perform that action at this time.
0 commit comments