diff --git a/app/models/project_services/mattermost_slash_commands_service.rb b/app/models/project_services/mattermost_slash_commands_service.rb index 67902329593ffa8a730902b8d43618855efca062..33431f41dc2344a2f196b5fb1b6a294b1f4ccff2 100644 --- a/app/models/project_services/mattermost_slash_commands_service.rb +++ b/app/models/project_services/mattermost_slash_commands_service.rb @@ -19,13 +19,6 @@ class MattermostSlashCommandsService < ChatService 'mattermost_slash_commands' end - def help - "This service allows you to use slash commands with your Mattermost installation.<br/> - To setup this Service you need to create a new <b>Slash commands</b> in your Mattermost integration panel.<br/> - <br/> - Create integration with URL #{service_trigger_url(self)} and enter the token below." - end - def fields [ { type: 'text', name: 'token', placeholder: '' } diff --git a/app/views/projects/services/mattermost_command/_help.html.haml b/app/views/projects/services/mattermost_slash_commands/_help.html.haml similarity index 89% rename from app/views/projects/services/mattermost_command/_help.html.haml rename to app/views/projects/services/mattermost_slash_commands/_help.html.haml index c6e0e8837521a5c03c885e6a49e71ad3ac0029de..15aa2006c023b68832caffca0cfd013b260bd4c6 100644 --- a/app/views/projects/services/mattermost_command/_help.html.haml +++ b/app/views/projects/services/mattermost_slash_commands/_help.html.haml @@ -1,5 +1,5 @@ - pretty_path_with_namespace = "#{@project ? @project.namespace.name : 'namespace'} / #{@project ? @project.name : 'name'}" -- run_actions_text = "Run action on the GitLab project: #{pretty_path_with_namespace}" +- run_actions_text = "Perform common operations on this project: #{pretty_path_with_namespace}" .well %p @@ -15,7 +15,7 @@ %li 1. = link_to 'Enable custom slash commands', 'https://docs.mattermost.com/developer/slash-commands.html#enabling-custom-commands' - on your Mattermost installation. + on your Mattermost installation %li 2. = link_to 'Add a slash command', 'https://docs.mattermost.com/developer/slash-commands.html#set-up-a-custom-command' @@ -44,9 +44,9 @@ %p Fill in the word that works best for your team. %p Suggestions: - %code= @project ? @project.name : 'project_name' - %code= @project ? @project.namespace.name : 'namespace_name' - %code= @project ? @project.name_with_namespace : 'namespace_name/project_name' + %code= 'gitlab' + %code= @project.path # Path contains no spaces, but dashes + %code= @project.path_with_namespace .form-group = label_tag :request_url, 'Request URL', class: 'col-sm-2 col-xs-12 control-label' @@ -69,7 +69,7 @@ .form-group = label_tag :response_icon, 'Response icon', class: 'col-sm-2 col-xs-12 control-label' .col-sm-10.col-xs-12.input-group - = text_field_tag :response_icon, asset_path('gitlab_logo.png'), class: 'form-control input-sm', readonly: 'readonly' + = text_field_tag :response_icon, asset_url('gitlab_logo.png'), class: 'form-control input-sm', readonly: 'readonly' .input-group-btn = clipboard_button(clipboard_target: '#response_icon') diff --git a/changelogs/unreleased/zj-mattermost-command-help-message.yml b/changelogs/unreleased/zj-mattermost-command-help-message.yml new file mode 100644 index 0000000000000000000000000000000000000000..fab238a8d8d990e1058fa7c0406b8dc72a4fe6ec --- /dev/null +++ b/changelogs/unreleased/zj-mattermost-command-help-message.yml @@ -0,0 +1,4 @@ +--- +title: Add help message for configuring Mattermost slash commands +merge_request: 7558 +author: diff --git a/spec/features/projects/services/mattermost_slash_command_spec.rb b/spec/features/projects/services/mattermost_slash_command_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..f474e7e891bd949c60f5bd8a2bedbbf73c6d2b4d --- /dev/null +++ b/spec/features/projects/services/mattermost_slash_command_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +feature 'Setup Mattermost slash commands', feature: true do + include WaitForAjax + + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:service) { project.create_mattermost_slash_commands_service } + + before do + project.team << [user, :master] + login_as(user) + end + + describe 'user visites the mattermost slash command config page', js: true do + it 'shows a help message' do + visit edit_namespace_project_service_path(project.namespace, project, service) + + wait_for_ajax + + expect(page).to have_content("This service allows GitLab users to perform common") + end + end + + describe 'saving a token' do + let(:token) { ('a'..'z').to_a.join } + + it 'shows the token after saving' do + visit edit_namespace_project_service_path(project.namespace, project, service) + + fill_in 'service_token', with: token + click_on 'Save' + + value = find_field('service_token').value + + expect(value).to eq(token) + end + end + + describe 'the trigger url' do + it 'shows the correct url' do + visit edit_namespace_project_service_path(project.namespace, project, service) + + value = find_field('request_url').value + expect(value).to match("api/v3/projects/#{project.id}/services/mattermost_slash_commands/trigger") + end + end +end diff --git a/spec/features/projects/slack_service/slack_service_spec.rb b/spec/features/projects/services/slack_service_spec.rb similarity index 100% rename from spec/features/projects/slack_service/slack_service_spec.rb rename to spec/features/projects/services/slack_service_spec.rb