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

Improve after feedback

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