summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Ribeiro <mail@carlosribeiro.me>2016-08-08 11:03:30 -0300
committerCarlos Ribeiro <mail@carlosribeiro.me>2016-08-08 13:55:57 -0300
commited63ead22aa9fd9fe509f3bebd73223b4ff8b8c5 (patch)
tree739a7e68954e27c635474dc66a28eaef613d61f8
parent59ce1af53b8d25d1b4ae8b6e59f069c5147ca572 (diff)
downloadgitlab-ce-ed63ead22aa9fd9fe509f3bebd73223b4ff8b8c5.tar.gz
Avoid to show the original password field when password is automatically seted
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/profiles/passwords_controller.rb1
-rw-r--r--spec/features/profiles/password_spec.rb45
3 files changed, 47 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f5416434ab1..bf250d4e34e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -77,6 +77,7 @@ v 8.11.0 (unreleased)
- Speed up and reduce memory usage of Commit#repo_changes, Repository#expire_avatar_cache and IrkerWorker
- Add unfold links for Side-by-Side view. !5415 (Tim Masliuchenko)
- Adds support for pending invitation project members importing projects
+ - Avoid to show the original password field when password is automatically set. !5712 (duduribeiro)
v 8.10.5 (unreleased)
diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb
index c780e0983f9..6217ec5ecef 100644
--- a/app/controllers/profiles/passwords_controller.rb
+++ b/app/controllers/profiles/passwords_controller.rb
@@ -50,6 +50,7 @@ class Profiles::PasswordsController < Profiles::ApplicationController
flash[:notice] = "Password was successfully updated. Please login with it"
redirect_to new_user_session_path
else
+ @user.reload
render 'edit'
end
end
diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb
new file mode 100644
index 00000000000..4cbdd89d46f
--- /dev/null
+++ b/spec/features/profiles/password_spec.rb
@@ -0,0 +1,45 @@
+require 'spec_helper'
+
+describe 'Profile > Password', feature: true do
+ let(:user) { create(:user, password_automatically_set: true) }
+
+ before do
+ login_as(user)
+ visit edit_profile_password_path
+ end
+
+ def fill_passwords(password, confirmation)
+ fill_in 'New password', with: password
+ fill_in 'Password confirmation', with: confirmation
+
+ click_button 'Save password'
+ end
+
+ context 'User with password automatically set' do
+ describe 'User puts different passwords in the field and in the confirmation' do
+ it 'shows an error message' do
+ fill_passwords('mypassword', 'mypassword2')
+
+ page.within('.alert-danger') do
+ expect(page).to have_content("Password confirmation doesn't match Password")
+ end
+ end
+
+ it 'does not contains the current password field after an error' do
+ fill_passwords('mypassword', 'mypassword2')
+
+ expect(page).to have_no_field('user[current_password]')
+ end
+ end
+
+ describe 'User puts the same passwords in the field and in the confirmation' do
+ it 'shows a success message' do
+ fill_passwords('mypassword', 'mypassword')
+
+ page.within('.flash-notice') do
+ expect(page).to have_content('Password was successfully updated. Please login with it')
+ end
+ end
+ end
+ end
+end