diff options
author | Marin Jankovski <maxlazio@gmail.com> | 2014-10-03 16:24:11 +0200 |
---|---|---|
committer | Marin Jankovski <maxlazio@gmail.com> | 2014-10-06 10:44:01 +0200 |
commit | 20179772140ff0bdc2d61852c0a4f48ee6e4a2d0 (patch) | |
tree | 53bc3181dfa8ad8dcaf28b21bc99e3e228e6aca2 | |
parent | 86d5a63e5eed67637e8177082d224935dd10b8f9 (diff) | |
download | gitlab-ce-20179772140ff0bdc2d61852c0a4f48ee6e4a2d0.tar.gz |
Use only webhook for slack service integration.
-rw-r--r-- | app/controllers/projects/services_controller.rb | 2 | ||||
-rw-r--r-- | app/models/project_services/slack_service.rb | 15 | ||||
-rw-r--r-- | features/steps/project/services.rb | 8 |
3 files changed, 9 insertions, 16 deletions
diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 4c558e137ea..31ce9581e5f 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -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 diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb index 4bda93f6006..2174919346d 100644 --- a/app/models/project_services/slack_service.rb +++ b/app/models/project_services/slack_service.rb @@ -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 diff --git a/features/steps/project/services.rb b/features/steps/project/services.rb index d816fcafbaa..5bd60f99c84 100644 --- a/features/steps/project/services.rb +++ b/features/steps/project/services.rb @@ -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 |