summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-06 16:14:48 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-06 16:14:48 +0000
commit70004f4ef6160e788e6a600b9da06608c8559aa2 (patch)
tree7ee7c7990126555f6edd0ba95bb8b5bf1927d029 /spec/models
parent0fed1b587630ff98808c61881511ee7c077c3db6 (diff)
parenteceef546d19c16d16772868a05e6769907442f83 (diff)
downloadgitlab-ce-70004f4ef6160e788e6a600b9da06608c8559aa2.tar.gz
Merge branch 'slack_integration' into 'master'
Slack integration See merge request !1151
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/slack_service_spec.rb34
1 files changed, 25 insertions, 9 deletions
diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb
index 4576913b473..3e555193b32 100644
--- a/spec/models/slack_service_spec.rb
+++ b/spec/models/slack_service_spec.rb
@@ -26,31 +26,28 @@ describe SlackService do
subject.active = true
end
- it { should validate_presence_of :room }
- it { should validate_presence_of :subdomain }
- it { should validate_presence_of :token }
+ it { should validate_presence_of :webhook }
end
end
describe "Execute" do
let(:slack) { SlackService.new }
+ let(:slack_service) { SlackService.new }
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:sample_data) { GitPushService.new.sample_data(project, user) }
- let(:subdomain) { 'gitlab' }
- let(:token) { 'verySecret' }
+ let(:webhook) { 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI' }
+ let(:new_webhook) { 'https://hooks.gitlabhq.slack.com/services/cdIj4r4LfXUOySDUjp0tk3OI' }
let(:api_url) {
- "https://#{subdomain}.slack.com/services/hooks/incoming-webhook?token=#{token}"
+ 'https://gitlabhq.slack.com/services/hooks/incoming-webhook?token=cdIj4r4LfXUOySDUjp0tk3OI'
}
before do
slack.stub(
project: project,
project_id: project.id,
- room: '#gitlab',
service_hook: true,
- subdomain: subdomain,
- token: token
+ webhook: webhook
)
WebMock.stub_request(:post, api_url)
@@ -61,5 +58,24 @@ describe SlackService do
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
end
end