Commit 20179772 authored by Marin Jankovski's avatar Marin Jankovski

Use only webhook for slack service integration.

parent 86d5a63e
......@@ -40,7 +40,7 @@ class Projects::ServicesController < Projects::ApplicationController
def service_params
params.require(:service).permit(
:title, :token, :type, :active, :api_key, :subdomain,
:room, :recipients, :project_url,
:room, :recipients, :project_url, :webhook
:user_key, :device, :priority, :sound
)
end
......
......@@ -13,10 +13,8 @@
#
class SlackService < Service
prop_accessor :room, :subdomain, :token
validates :room, presence: true, if: :activated?
validates :subdomain, presence: true, if: :activated?
validates :token, presence: true, if: :activated?
prop_accessor :webhook
validates :webhook, presence: true, if: :activated?
def title
'Slack'
......@@ -32,9 +30,7 @@ class SlackService < Service
def fields
[
{ type: 'text', name: 'subdomain', placeholder: '' },
{ type: 'text', name: 'token', placeholder: '' },
{ type: 'text', name: 'room', placeholder: 'Ex. #general' },
{ type: 'text', name: 'webhook', placeholder: '' }
]
end
......@@ -44,9 +40,10 @@ class SlackService < Service
project_name: project_name
))
credentials = webhook.match(/(\w*).slack.com.*token=(\w*)/)
subdomain = credentials[1]
token = credentials[2]
notifier = Slack::Notifier.new(subdomain, token)
notifier.channel = room
notifier.username = 'GitLab'
notifier.ping(message.pretext, attachments: message.attachments)
end
......
......@@ -108,16 +108,12 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
step 'I fill Slack settings' do
check 'Active'
fill_in 'Subdomain', with: 'gitlab'
fill_in 'Room', with: '#gitlab'
fill_in 'Token', with: 'verySecret'
fill_in 'Webhook', with: 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI'
click_button 'Save'
end
step 'I should see Slack service settings saved' do
find_field('Subdomain').value.should == 'gitlab'
find_field('Room').value.should == '#gitlab'
find_field('Token').value.should == 'verySecret'
find_field('Webhook').value.should == 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI'
end
step 'I click Pushover service link' do
......
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