Commit fbe9b00f authored by Valery Sizov's avatar Valery Sizov

Merge branch 'slack_team_name' into 'master'

Slack team name

Fixes a problem in slack team name with hyphens.

https://gitlab.com/gitlab-org/gitlab-ce/issues/701

See merge request !1204
parents b78cd70d ce61de68
...@@ -40,7 +40,8 @@ class SlackService < Service ...@@ -40,7 +40,8 @@ class SlackService < Service
project_name: project_name project_name: project_name
)) ))
credentials = webhook.match(/(\w*).slack.com.*services\/(.*)/) credentials = webhook.match(/([\w-]*).slack.com.*services\/(.*)/)
if credentials.present? if credentials.present?
subdomain = credentials[1] subdomain = credentials[1]
token = credentials[2].split("token=").last token = credentials[2].split("token=").last
......
...@@ -77,5 +77,25 @@ describe SlackService do ...@@ -77,5 +77,25 @@ describe SlackService do
WebMock.should have_requested(:post, api_url).once WebMock.should have_requested(:post, api_url).once
end end
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
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment