-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat; populate the webhook template ${pactbroker.buildUrl} from the b…
…uildUrl of the verification results
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
spec/integration/webhooks/verification_publication_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
RSpec.describe "triggering a webhook for verification publication" do | ||
before do | ||
td.create_global_webhook(event_names: ["provider_verification_published"], body: webhook_body_template) | ||
.create_pact_with_hierarchy("Foo", "1", "Bar") | ||
end | ||
|
||
let(:webhook_body_template) do | ||
{ | ||
"build_url" => "${pactbroker.buildUrl}" | ||
} | ||
end | ||
|
||
let(:expected_webhook_body) do | ||
{ | ||
build_url: "http://ci/builds/1234" | ||
} | ||
end | ||
|
||
let(:path) { "/pacts/provider/Bar/consumer/Foo/pact-version/#{td.and_return(:pact).pact_version_sha}/verification-results" } | ||
let(:verification_content) { load_json_fixture("verification.json").merge("buildUrl" => "http://ci/builds/1234") } | ||
|
||
let(:rack_headers) do | ||
{ | ||
"CONTENT_TYPE" => "application/json", | ||
"HTTP_ACCEPT" => "application/hal+json", | ||
"pactbroker.database_connector" => database_connector | ||
} | ||
end | ||
|
||
let!(:request) do | ||
stub_request(:post, /http/).to_return(:status => 200) | ||
end | ||
|
||
subject { post(path, verification_content.to_json, rack_headers) } | ||
|
||
let(:database_connector) { ->(&block) { block.call } } | ||
|
||
it { is_expected.to be_a_hal_json_created_response } | ||
|
||
it "passes through the correct parameters to the webhook" do | ||
subject | ||
expect(a_request(:post, /http/).with(body: expected_webhook_body)).to have_been_made | ||
end | ||
end |