diff options
author | Andrès Koetsier <koetsier@oblivion.nl> | 2014-12-28 23:08:33 +0300 |
---|---|---|
committer | Andrès Koetsier <koetsier@oblivion.nl> | 2015-02-28 12:06:32 +0300 |
commit | d2c85a68bb763d2beccf8ebc0087791f6714c6de (patch) | |
tree | 0fe74d494865c075fc17649227dc97ea52315ec2 /spec/models/project_services/slack_service_spec.rb | |
parent | 82a9a4c034eab240330696df578045336f34675e (diff) |
Allow a user to specify a channel and username for the slack-webhook
Diffstat (limited to 'spec/models/project_services/slack_service_spec.rb')
-rw-r--r-- | spec/models/project_services/slack_service_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb index 90b385423f1..8a75d8987ab 100644 --- a/spec/models/project_services/slack_service_spec.rb +++ b/spec/models/project_services/slack_service_spec.rb @@ -36,6 +36,8 @@ describe SlackService do let(:project) { create(:project) } let(:sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) } let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' } + let(:username) { 'slack_username' } + let(:channel) { 'slack_channel' } before do slack.stub( @@ -53,5 +55,25 @@ describe SlackService do expect(WebMock).to have_requested(:post, webhook_url).once end + + it 'should use the username as an option for slack when configured' do + slack.stub(username: username) + expect(Slack::Notifier).to receive(:new). + with(webhook_url, username: username). + and_return( + double(:slack_service).as_null_object + ) + slack.execute(sample_data) + end + + it 'should use the channel as an option when it is configured' do + slack.stub(channel: channel) + expect(Slack::Notifier).to receive(:new). + with(webhook_url, channel: channel). + and_return( + double(:slack_service).as_null_object + ) + slack.execute(sample_data) + end end end |