@@ -20,23 +20,35 @@ module Decorators
20
20
let ( :response ) { double ( 'http_response' , code : '200' , body : response_body , to_hash : headers ) }
21
21
let ( :response_body ) { 'body' }
22
22
let ( :error ) { nil }
23
- let ( :webhook ) { instance_double ( PactBroker ::Domain ::Webhook , uuid : 'some-uuid' ) }
23
+ let ( :webhook ) { instance_double ( PactBroker ::Domain ::Webhook , uuid : uuid ) }
24
+ let ( :uuid ) { 'some-uuid' }
24
25
let ( :show_response ) { true }
25
26
let ( :json ) {
26
27
WebhookExecutionResultDecorator . new ( webhook_execution_result )
27
- . to_json ( user_options : { base_url : 'http://example.org' , webhook : webhook , show_response : show_response } )
28
+ . to_json ( user_options : { resource_url : 'http://resource-url' , base_url : 'http://example.org' , webhook : webhook , show_response : show_response } )
28
29
}
29
30
30
31
let ( :subject ) { JSON . parse ( json , symbolize_names : true ) }
31
32
32
33
it "includes a link to execute the webhook again" do
33
- expect ( subject [ :_links ] [ :'try-again' ] [ :href ] ) . to eq 'http://example.org/webhooks/some-uuid/execute '
34
+ expect ( subject [ :_links ] [ :'try-again' ] [ :href ] ) . to eq 'http://resource-url '
34
35
end
35
36
36
- it "includes a link to the webhook" do
37
- expect ( subject [ :_links ] [ :webhook ] [ :href ] ) . to eq 'http://example.org/webhooks/some-uuid'
37
+ context "when there is a uuid" do
38
+ it "include a link to the webhook" do
39
+ expect ( subject [ :_links ] [ :webhook ] [ :href ] ) . to eq 'http://example.org/webhooks/some-uuid'
40
+ end
41
+ end
42
+
43
+ context "when there is a not uuid because this is an unsaved webhook" do
44
+ let ( :uuid ) { nil }
45
+
46
+ it "does not includes a link to the webhook" do
47
+ expect ( subject [ :_links ] ) . to_not have_key ( :webhook )
48
+ end
38
49
end
39
50
51
+
40
52
context "when there is an error" do
41
53
let ( :error ) { double ( 'error' , message : 'message' , backtrace : [ 'blah' , 'blah' ] ) }
42
54
0 commit comments