summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2014-11-03 09:57:05 +0100
committerMarin Jankovski <maxlazio@gmail.com>2014-11-03 09:57:05 +0100
commitfe610ff576fa5bac0b875309f137b471e7fe7e50 (patch)
tree2cede49b6c4d124e5486588fddbff802dec9165b /spec/models
parent1b1403804e03db3cea3ad6a84dcfead449ed29d5 (diff)
parent7b339e61e8e4a93798807f3c90bf7179a0ecd28b (diff)
downloadgitlab-ce-fe610ff576fa5bac0b875309f137b471e7fe7e50.tar.gz
Merge pull request #8156 from stevenosloan/update_slack_and_use_raw_webhook_url
update slack-notifier for new webhook_url format
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/slack_service_spec.rb56
1 files changed, 6 insertions, 50 deletions
diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb
index 526165e397c..d4840391967 100644
--- a/spec/models/slack_service_spec.rb
+++ b/spec/models/slack_service_spec.rb
@@ -31,71 +31,27 @@ describe SlackService do
end
describe "Execute" do
- let(:slack) { SlackService.new }
- let(:slack_service) { SlackService.new }
- let(:user) { create(:user) }
+ let(:slack) { SlackService.new }
+ let(:user) { create(:user) }
let(:project) { create(:project) }
let(:sample_data) { GitPushService.new.sample_data(project, user) }
- let(:webhook) { 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI' }
- let(:new_webhook) { 'https://hooks.gitlabhq.slack.com/services/cdIj4r4LfXUOySDUjp0tk3OI' }
- let(:api_url) {
- 'https://gitlabhq.slack.com/services/hooks/incoming-webhook?token=cdIj4r4LfXUOySDUjp0tk3OI'
- }
+ let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' }
before do
slack.stub(
project: project,
project_id: project.id,
service_hook: true,
- webhook: webhook
+ webhook: webhook_url
)
- WebMock.stub_request(:post, api_url)
+ WebMock.stub_request(:post, webhook_url)
end
it "should call Slack API" do
slack.execute(sample_data)
- WebMock.should have_requested(:post, api_url).once
- end
-
- context 'with new webhook syntax' do
- before do
- slack_service.stub(
- project: project,
- project_id: project.id,
- service_hook: true,
- webhook: new_webhook
- )
-
- WebMock.stub_request(:post, api_url)
- end
-
- it "should call Slack API" do
- slack_service.execute(sample_data)
-
- WebMock.should have_requested(:post, api_url).once
- end
- end
-
- context 'with new webhook syntax with slack allowed team name' do
- before do
- @allowed_webhook = 'https://gitlab-hq-123.slack.com/services/hooks/incoming-webhook?token=cdIj4r4LfXUOySDUjp0tk3OI'
- slack_service.stub(
- project: project,
- project_id: project.id,
- service_hook: true,
- webhook: @allowed_webhook
- )
-
- WebMock.stub_request(:post, @allowed_webhook)
- end
-
- it "should call Slack API" do
- slack_service.execute(sample_data)
-
- WebMock.should have_requested(:post, @allowed_webhook).once
- end
+ WebMock.should have_requested(:post, webhook_url).once
end
end
end