summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Knox <psimyn@gmail.com>2017-02-24 13:21:26 +1100
committerSimon Knox <psimyn@gmail.com>2017-06-03 04:04:28 +1000
commit0b1843b3880ebd0d4a31fb0ceeb0c093bfd8bd31 (patch)
treebfde880a59fd6152b80c9ea94051199325700f7f
parent1e8dbd46758d5c9772baf233ebcff889dc742d3d (diff)
downloadgitlab-ce-27814-token-autocomplete-off.tar.gz
disable autocomplete for Token field on chat slash command config page27814-token-autocomplete-off
update screenshots of config page
-rw-r--r--app/models/project_services/chat_slash_commands_service.rb2
-rw-r--r--app/views/shared/_field.html.haml3
-rw-r--r--changelogs/unreleased/27814-token-autocomplete-off.yml4
-rw-r--r--doc/user/project/integrations/img/mattermost_config_help.pngbin102890 -> 46174 bytes
-rw-r--r--doc/user/project/integrations/img/slack_setup.pngbin86314 -> 39685 bytes
-rw-r--r--spec/features/projects/services/chat_slash_commands_spec.rb33
-rw-r--r--spec/features/projects/services/mattermost_slash_command_spec.rb18
-rw-r--r--spec/features/projects/services/slack_slash_command_spec.rb6
-rw-r--r--spec/models/project_services/chat_slash_commands_service_spec.rb9
9 files changed, 52 insertions, 23 deletions
diff --git a/app/models/project_services/chat_slash_commands_service.rb b/app/models/project_services/chat_slash_commands_service.rb
index 8b5bc24fd3c..f0e0c6a25a3 100644
--- a/app/models/project_services/chat_slash_commands_service.rb
+++ b/app/models/project_services/chat_slash_commands_service.rb
@@ -23,7 +23,7 @@ class ChatSlashCommandsService < Service
def fields
[
- { type: 'text', name: 'token', placeholder: 'XXxxXXxxXXxxXXxxXXxxXXxx' }
+ { type: 'text', name: 'token', placeholder: 'XXxxXXxxXXxxXXxxXXxxXXxx', autocomplete: 'off' }
]
end
diff --git a/app/views/shared/_field.html.haml b/app/views/shared/_field.html.haml
index 795447a9ca6..410d95a026c 100644
--- a/app/views/shared/_field.html.haml
+++ b/app/views/shared/_field.html.haml
@@ -4,6 +4,7 @@
- type = field[:type]
- placeholder = field[:placeholder]
- required = field[:required]
+- autocomplete = field[:autocomplete]
- choices = field[:choices]
- default_choice = field[:default_choice]
- help = field[:help]
@@ -15,7 +16,7 @@
= form.label name, title, class: "control-label"
.col-sm-10
- if type == 'text'
- = form.text_field name, class: "form-control", placeholder: placeholder, required: required
+ = form.text_field name, class: "form-control", placeholder: placeholder, required: required, autocomplete: autocomplete
- elsif type == 'textarea'
= form.text_area name, rows: 5, class: "form-control", placeholder: placeholder, required: required
- elsif type == 'checkbox'
diff --git a/changelogs/unreleased/27814-token-autocomplete-off.yml b/changelogs/unreleased/27814-token-autocomplete-off.yml
new file mode 100644
index 00000000000..1bce817082c
--- /dev/null
+++ b/changelogs/unreleased/27814-token-autocomplete-off.yml
@@ -0,0 +1,4 @@
+---
+title: Disable autocomplete for Token field on Mattermost/Slack config pages
+merge_request:
+author:
diff --git a/doc/user/project/integrations/img/mattermost_config_help.png b/doc/user/project/integrations/img/mattermost_config_help.png
index dd3481bc1f6..219dbb42ae4 100644
--- a/doc/user/project/integrations/img/mattermost_config_help.png
+++ b/doc/user/project/integrations/img/mattermost_config_help.png
Binary files differ
diff --git a/doc/user/project/integrations/img/slack_setup.png b/doc/user/project/integrations/img/slack_setup.png
index 7928fb7d495..0b5362160b4 100644
--- a/doc/user/project/integrations/img/slack_setup.png
+++ b/doc/user/project/integrations/img/slack_setup.png
Binary files differ
diff --git a/spec/features/projects/services/chat_slash_commands_spec.rb b/spec/features/projects/services/chat_slash_commands_spec.rb
new file mode 100644
index 00000000000..e72392c1f06
--- /dev/null
+++ b/spec/features/projects/services/chat_slash_commands_spec.rb
@@ -0,0 +1,33 @@
+require 'spec_helper'
+
+feature 'Chat slash commands', models: true do
+ let(:user) { create(:user) }
+ let(:project) { create(:empty_project) }
+ let(:service) do
+ class ExampleChatSlashCommandsService < ChatSlashCommandsService
+ def self.to_param
+ 'mattermost_slash_commands'
+ end
+ end
+
+ ExampleChatSlashCommandsService.new
+ end
+
+ before do
+ project.team << [user, :master]
+ login_as(user)
+ visit edit_namespace_project_service_path(project.namespace, project, service)
+ end
+
+ it 'shows a token placeholder' do
+ token_placeholder = find_field('service_token')['placeholder']
+
+ expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
+ end
+
+ it 'prevents autocomplete for token field' do
+ autocomplete = find_field('service_token')['autocomplete']
+
+ expect(autocomplete).to eq('off')
+ end
+end
diff --git a/spec/features/projects/services/mattermost_slash_command_spec.rb b/spec/features/projects/services/mattermost_slash_command_spec.rb
index 1fe82222e59..b56226020a3 100644
--- a/spec/features/projects/services/mattermost_slash_command_spec.rb
+++ b/spec/features/projects/services/mattermost_slash_command_spec.rb
@@ -18,13 +18,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do
expect(page).to have_content("This service allows users to perform common")
end
- it 'shows a token placeholder' do
- token_placeholder = find_field('service_token')['placeholder']
-
- expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
- end
-
- it 'redirects to the integrations page after saving but not activating' do
+ it 'shows the token after saving' do
token = ('a'..'z').to_a.join
fill_in 'service_token', with: token
@@ -34,7 +28,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do
expect(page).to have_content('Mattermost slash commands settings saved, but not activated.')
end
- it 'redirects to the integrations page after activating' do
+ it 'redirects to the integrations page after saving but not activating' do
token = ('a'..'z').to_a.join
fill_in 'service_token', with: token
@@ -54,7 +48,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do
click_link 'Add to Mattermost'
- expect(page).to have_content('You aren’t a member of any team on the Mattermost instance')
+ expect(page).to have_content("You aren’t a member of any team on the Mattermost instance")
expect(page).to have_link('join a team', href: "#{Gitlab.config.mattermost.host}/select_team")
end
@@ -161,12 +155,6 @@ feature 'Setup Mattermost slash commands', :feature, :js do
expect(value).to match("api/v3/projects/#{project.id}/services/mattermost_slash_commands/trigger")
end
-
- it 'shows a token placeholder' do
- token_placeholder = find_field('service_token')['placeholder']
-
- expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
- end
end
end
diff --git a/spec/features/projects/services/slack_slash_command_spec.rb b/spec/features/projects/services/slack_slash_command_spec.rb
index f53b820c460..35425319536 100644
--- a/spec/features/projects/services/slack_slash_command_spec.rb
+++ b/spec/features/projects/services/slack_slash_command_spec.rb
@@ -11,12 +11,6 @@ feature 'Slack slash commands', feature: true do
visit edit_namespace_project_service_path(project.namespace, project, service)
end
- it 'shows a token placeholder' do
- token_placeholder = find_field('service_token')['placeholder']
-
- expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
- end
-
it 'shows a help message' do
expect(page).to have_content('This service allows users to perform common')
end
diff --git a/spec/models/project_services/chat_slash_commands_service_spec.rb b/spec/models/project_services/chat_slash_commands_service_spec.rb
new file mode 100644
index 00000000000..cd949359a2c
--- /dev/null
+++ b/spec/models/project_services/chat_slash_commands_service_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe ChatSlashCommandsService, models: true do
+ it 'returns placeholder in fields' do
+ service = ChatSlashCommandsService.new()
+
+ expect(service[:fields][0][:autocomplete]).to eq 'off'
+ end
+end