summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 21:09:23 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 21:09:23 +0000
commit32fd4cd5e2134511936899d6bcc4aaf18b9be6fd (patch)
tree10378ceffed52dd0e160a0d9bcf3c5ab72c18958 /spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
parent951616a26a61e880860ad862c1d45a8e3762b4bc (diff)
downloadgitlab-ce-32fd4cd5e2134511936899d6bcc4aaf18b9be6fd.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb50
1 files changed, 11 insertions, 39 deletions
diff --git a/spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb b/spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
index 2b68e7bfa82..24ff57c8517 100644
--- a/spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
+++ b/spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb
@@ -151,22 +151,14 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
it 'uses the username as an option for slack when configured' do
allow(chat_service).to receive(:username).and_return(username)
- expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, username: username, http_client: SlackService::Notifier::HTTPClient)
- .and_return(
- double(:slack_service).as_null_object
- )
+ expect(Slack::Messenger).to execute_with_options(username: username)
chat_service.execute(data)
end
it 'uses the channel as an option when it is configured' do
allow(chat_service).to receive(:channel).and_return(channel)
- expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: channel, http_client: SlackService::Notifier::HTTPClient)
- .and_return(
- double(:slack_service).as_null_object
- )
+ expect(Slack::Messenger).to execute_with_options(channel: [channel])
chat_service.execute(data)
end
@@ -174,11 +166,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
it "uses the right channel for push event" do
chat_service.update(push_channel: "random")
- expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random", http_client: SlackService::Notifier::HTTPClient)
- .and_return(
- double(:slack_service).as_null_object
- )
+ expect(Slack::Messenger).to execute_with_options(channel: ['random'])
chat_service.execute(data)
end
@@ -186,11 +174,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
it "uses the right channel for merge request event" do
chat_service.update(merge_request_channel: "random")
- expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random", http_client: SlackService::Notifier::HTTPClient)
- .and_return(
- double(:slack_service).as_null_object
- )
+ expect(Slack::Messenger).to execute_with_options(channel: ['random'])
chat_service.execute(@merge_sample_data)
end
@@ -198,11 +182,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
it "uses the right channel for issue event" do
chat_service.update(issue_channel: "random")
- expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random", http_client: SlackService::Notifier::HTTPClient)
- .and_return(
- double(:slack_service).as_null_object
- )
+ expect(Slack::Messenger).to execute_with_options(channel: ['random'])
chat_service.execute(@issues_sample_data)
end
@@ -213,7 +193,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
it "uses confidential issue channel" do
chat_service.update(confidential_issue_channel: 'confidential')
- expect(Slack::Notifier).to execute_with_options(channel: 'confidential')
+ expect(Slack::Messenger).to execute_with_options(channel: ['confidential'])
chat_service.execute(@issues_sample_data)
end
@@ -221,7 +201,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
it 'falls back to issue channel' do
chat_service.update(issue_channel: 'fallback_channel')
- expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel')
+ expect(Slack::Messenger).to execute_with_options(channel: ['fallback_channel'])
chat_service.execute(@issues_sample_data)
end
@@ -230,11 +210,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
it "uses the right channel for wiki event" do
chat_service.update(wiki_page_channel: "random")
- expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random", http_client: SlackService::Notifier::HTTPClient)
- .and_return(
- double(:slack_service).as_null_object
- )
+ expect(Slack::Messenger).to execute_with_options(channel: ['random'])
chat_service.execute(@wiki_page_sample_data)
end
@@ -249,11 +225,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
- expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random", http_client: SlackService::Notifier::HTTPClient)
- .and_return(
- double(:slack_service).as_null_object
- )
+ expect(Slack::Messenger).to execute_with_options(channel: ['random'])
chat_service.execute(note_data)
end
@@ -268,7 +240,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
- expect(Slack::Notifier).to execute_with_options(channel: 'confidential')
+ expect(Slack::Messenger).to execute_with_options(channel: ['confidential'])
chat_service.execute(note_data)
end
@@ -278,7 +250,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do |service_name|
note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
- expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel')
+ expect(Slack::Messenger).to execute_with_options(channel: ['fallback_channel'])
chat_service.execute(note_data)
end