summaryrefslogtreecommitdiff
path: root/spec/models/integrations/base_chat_notification_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/integrations/base_chat_notification_spec.rb')
-rw-r--r--spec/models/integrations/base_chat_notification_spec.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/spec/models/integrations/base_chat_notification_spec.rb b/spec/models/integrations/base_chat_notification_spec.rb
index b959ead2cae..67fc09fd8b5 100644
--- a/spec/models/integrations/base_chat_notification_spec.rb
+++ b/spec/models/integrations/base_chat_notification_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe Integrations::BaseChatNotification do
webhook: webhook_url
)
- WebMock.stub_request(:post, webhook_url)
+ WebMock.stub_request(:post, webhook_url) if webhook_url.present?
subject.active = true
end
@@ -55,6 +55,33 @@ RSpec.describe Integrations::BaseChatNotification do
end
end
+ context 'when webhook is blank' do
+ let(:webhook_url) { '' }
+
+ it 'returns false' do
+ expect(chat_integration).not_to receive(:notify)
+ expect(chat_integration.execute(data)).to be false
+ end
+
+ context 'when webhook is not required' do
+ it 'returns true' do
+ allow(chat_integration).to receive(:requires_webhook?).and_return(false)
+
+ expect(chat_integration).to receive(:notify).and_return(true)
+ expect(chat_integration.execute(data)).to be true
+ end
+ end
+ end
+
+ context 'when event is not supported' do
+ it 'returns false' do
+ allow(chat_integration).to receive(:supported_events).and_return(['foo'])
+
+ expect(chat_integration).not_to receive(:notify)
+ expect(chat_integration.execute(data)).to be false
+ end
+ end
+
context 'with a project with name containing spaces' do
it 'does not remove spaces' do
allow(project).to receive(:full_name).and_return('Project Name')