Last active
August 29, 2015 14:08
-
-
Save mtorromeo/0fe22e5e8d2960aa45ba to your computer and use it in GitHub Desktop.
GitLab re-implement room setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb | |
index 963f544..6f235fd 100644 | |
--- a/app/models/project_services/slack_service.rb | |
+++ b/app/models/project_services/slack_service.rb | |
@@ -13,8 +13,9 @@ | |
# | |
class SlackService < Service | |
- prop_accessor :webhook | |
+ prop_accessor :webhook, :room | |
validates :webhook, presence: true, if: :activated? | |
+ validates :room, presence: true, if: :activated? | |
def title | |
'Slack' | |
@@ -30,7 +31,8 @@ class SlackService < Service | |
def fields | |
[ | |
- { type: 'text', name: 'webhook', placeholder: 'https://hooks.slack.com/services/...' } | |
+ { type: 'text', name: 'webhook', placeholder: 'https://hooks.slack.com/services/...' }, | |
+ { type: 'text', name: 'room', placeholder: 'Ex. #general' }, | |
] | |
end | |
@@ -43,6 +45,8 @@ class SlackService < Service | |
)) | |
notifier = Slack::Notifier.new(webhook) | |
+ 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 d5d5807..b7c0960 100644 | |
--- a/features/steps/project/services.rb | |
+++ b/features/steps/project/services.rb | |
@@ -110,11 +110,13 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps | |
step 'I fill Slack settings' do | |
check 'Active' | |
fill_in 'Webhook', with: 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' | |
+ fill_in 'Room', with: '#gitlab' | |
click_button 'Save' | |
end | |
step 'I should see Slack service settings saved' do | |
find_field('Webhook').value.should == 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' | |
+ find_field('Room').value.should == '#gitlab' | |
end | |
step 'I click Pushover service link' do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment