debian-mirror-gitlab/spec/features/profiles/password_spec.rb

76 lines
2 KiB
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe 'Profile > Password' do
context 'Password authentication enabled' do
let(:user) { create(:user, password_automatically_set: true) }
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
before do
sign_in(user)
visit edit_profile_password_path
end
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
def fill_passwords(password, confirmation)
fill_in 'New password', with: password
fill_in 'Password confirmation', with: confirmation
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
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')
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
page.within('.alert-danger') do
expect(page).to have_content("Password confirmation doesn't match Password")
end
end
it 'does not contain the current password field after an error' do
fill_passwords('mypassword', 'mypassword2')
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
expect(page).to have_no_field('user[current_password]')
2016-09-13 17:45:13 +05:30
end
end
2017-09-10 17:25:29 +05:30
describe 'User puts the same passwords in the field and in the confirmation' do
it 'shows a success message' do
fill_passwords('mypassword', 'mypassword')
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
page.within('.flash-notice') do
expect(page).to have_content('Password was successfully updated. Please login with it')
end
end
2016-09-13 17:45:13 +05:30
end
end
2017-09-10 17:25:29 +05:30
end
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
context 'Password authentication unavailable' do
before do
gitlab_sign_in(user)
end
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
context 'Regular user' do
let(:user) { create(:user) }
it 'renders 200 when sign-in is disabled' do
stub_application_setting(password_authentication_enabled: false)
visit edit_profile_password_path
expect(page).to have_http_status(200)
end
end
context 'LDAP user' do
let(:user) { create(:omniauth_user, provider: 'ldapmain') }
it 'renders 404' do
visit edit_profile_password_path
expect(page).to have_http_status(404)
2016-09-13 17:45:13 +05:30
end
end
end
end