diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb b/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb index da5c35c970a..2e062cda4e9 100644 --- a/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb @@ -45,9 +45,33 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name end it "notifies about #{event_type} events" do + expect(chat_integration).not_to receive(:log_error) + chat_integration.execute(data) + expect(WebMock).to have_requested(:post, stubbed_resolved_hostname) end + + context 'when the response is not successful' do + let!(:stubbed_resolved_hostname) do + stub_full_request(webhook_url, method: :post) + .to_return(status: 409, body: 'error message') + .request_pattern.uri_pattern.to_s + end + + it 'logs an error' do + expect(chat_integration).to receive(:log_error).with( + 'SlackMattermostNotifier HTTP error response', + request_host: 'example.gitlab.com', + response_code: 409, + response_body: 'error message' + ) + + chat_integration.execute(data) + + expect(WebMock).to have_requested(:post, stubbed_resolved_hostname) + end + end end shared_examples "untriggered #{integration_name} integration" do |event_type: nil, branches_to_be_notified: nil| @@ -59,8 +83,9 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name stub_full_request(webhook_url, method: :post).request_pattern.uri_pattern.to_s end - it "notifies about #{event_type} events" do + it "does not notify about #{event_type} events" do chat_integration.execute(data) + expect(WebMock).not_to have_requested(:post, stubbed_resolved_hostname) end end |