Commit 298d05a5 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Improve after feedback

parent b1ccf99e
...@@ -39,9 +39,9 @@ Feature: Project Services ...@@ -39,9 +39,9 @@ Feature: Project Services
Scenario: Activate Slack service Scenario: Activate Slack service
When I visit project "Shop" services page When I visit project "Shop" services page
And I click Slack service link And I click Slack Notifications service link
And I fill Slack settings And I fill Slack Notifications settings
Then I should see Slack service settings saved Then I should see Slack Notifications service settings saved
Scenario: Activate Pushover service Scenario: Activate Pushover service
When I visit project "Shop" services page When I visit project "Shop" services page
......
...@@ -137,17 +137,17 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps ...@@ -137,17 +137,17 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
expect(find_field('Colorize messages').value).to eq '1' expect(find_field('Colorize messages').value).to eq '1'
end end
step 'I click Slack service link' do step 'I click Slack Notifications service link' do
click_link 'Slack' click_link 'Slack Notifications'
end end
step 'I fill Slack settings' do step 'I fill Slack Notifications settings' do
check 'Active' check 'Active'
fill_in 'Webhook', with: 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' fill_in 'Webhook', with: 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685'
click_button 'Save' click_button 'Save'
end end
step 'I should see Slack service settings saved' do step 'I should see Slack Notifications service settings saved' do
expect(find_field('Webhook').value).to eq 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' expect(find_field('Webhook').value).to eq 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685'
end end
......
...@@ -378,7 +378,6 @@ module API ...@@ -378,7 +378,6 @@ module API
desc: 'A custom certificate authority bundle to verify the Kubernetes cluster with (PEM format)' desc: 'A custom certificate authority bundle to verify the Kubernetes cluster with (PEM format)'
}, },
], ],
'mattermost-slash-commands' => [ 'mattermost-slash-commands' => [
{ {
required: true, required: true,
...@@ -387,6 +386,14 @@ module API ...@@ -387,6 +386,14 @@ module API
desc: 'The Mattermost token' desc: 'The Mattermost token'
} }
], ],
'slack-slash-commands' => [
{
required: true,
name: :token,
type: String,
desc: 'The Slack token'
}
],
'pipelines-email' => [ 'pipelines-email' => [
{ {
required: true, required: true,
......
module Gitlab
module ChatCommands
class Help < BaseCommand
# This class has to be used last, as it always matches. It has to match
# because other commands were not triggered and we want to show the help
# command
def self.match(_text)
true
end
def self.help_message
'help'
end
def self.allowed?(_project, _user)
true
end
def execute(commands)
Gitlab::ChatCommands::Presenters::Help.new(commands).present(trigger)
end
def trigger
params[:command]
end
end
end
end
module Gitlab module Gitlab
module ChatCommands module ChatCommands
class Presenter class Presenter
include Gitlab::Routing.url_helpers include Gitlab::Routing
def authorize_chat_name(url) def authorize_chat_name(url)
message = if url message = if url
......
require 'spec_helper' require 'spec_helper'
feature 'Setup Slack slash commands', feature: true do feature 'Slack slash commands', feature: true do
include WaitForAjax include WaitForAjax
let(:user) { create(:user) } given(:user) { create(:user) }
let(:project) { create(:project) } given(:project) { create(:project) }
let(:service) { project.create_slack_slash_commands_service } given(:service) { project.create_slack_slash_commands_service }
before do background do
project.team << [user, :master] project.team << [user, :master]
login_as(user) login_as(user)
end end
describe 'user visits the slack slash command config page', js: true do scenario 'user visits the slack slash command config page', js: true do
it 'shows a help message' do it 'shows a help message' do
visit edit_namespace_project_service_path(project.namespace, project, service) visit edit_namespace_project_service_path(project.namespace, project, service)
...@@ -22,8 +22,8 @@ feature 'Setup Slack slash commands', feature: true do ...@@ -22,8 +22,8 @@ feature 'Setup Slack slash commands', feature: true do
end end
end end
describe 'saving a token' do scenario 'saving a token' do
let(:token) { ('a'..'z').to_a.join } given(:token) { ('a'..'z').to_a.join }
it 'shows the token after saving' do it 'shows the token after saving' do
visit edit_namespace_project_service_path(project.namespace, project, service) visit edit_namespace_project_service_path(project.namespace, project, service)
...@@ -37,7 +37,7 @@ feature 'Setup Slack slash commands', feature: true do ...@@ -37,7 +37,7 @@ feature 'Setup Slack slash commands', feature: true do
end end
end end
describe 'the trigger url' do scenario 'the trigger url' do
it 'shows the correct url' do it 'shows the correct url' do
visit edit_namespace_project_service_path(project.namespace, project, service) visit edit_namespace_project_service_path(project.namespace, project, service)
......
require 'spec_helper' require 'spec_helper'
describe MattermostSlashCommandsService, models: true do describe MattermostSlashCommandsService, :models do
it_behaves_like "chat slash commands" it_behaves_like "chat slash commands service"
end end
require 'spec_helper' require 'spec_helper'
describe SlackSlashCommandsService, models: true do describe SlackSlashCommandsService, :models do
it_behaves_like "chat slash commands" it_behaves_like "chat slash commands service"
describe '#trigger' do describe '#trigger' do
context 'when an auth url is generated' do context 'when an auth url is generated' do
...@@ -15,11 +15,13 @@ describe SlackSlashCommandsService, models: true do ...@@ -15,11 +15,13 @@ describe SlackSlashCommandsService, models: true do
token: 'token' token: 'token'
} }
end end
let(:service) do let(:service) do
project.create_slack_slash_commands_service( project.create_slack_slash_commands_service(
properties: { token: 'token' } properties: { token: 'token' }
) )
end end
let(:authorize_url) do let(:authorize_url) do
'http://authorize.example.com/' 'http://authorize.example.com/'
end end
......
RSpec.shared_examples 'chat slash commands' do RSpec.shared_examples 'chat slash commands service' do
describe "Associations" do describe "Associations" do
it { is_expected.to respond_to :token } it { is_expected.to respond_to :token }
it { is_expected.to have_many :chat_names } it { is_expected.to have_many :chat_names }
......
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