password_spec.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Profile > Password', type: :system, authenticated_as: :user do
  4. before do
  5. visit 'profile/password'
  6. end
  7. let(:user) { create(:agent, :with_valid_password) }
  8. it 'when current password is wrong, show error' do
  9. fill_in 'password_old', with: 'nonexisting'
  10. fill_in 'password_new', with: 'some'
  11. fill_in 'password_new_confirm', with: 'some'
  12. click '.btn--primary'
  13. expect(page).to have_text 'Current password is wrong'
  14. end
  15. it 'when new passwords do not match, show error' do
  16. fill_in 'password_old', with: user.password_plain
  17. fill_in 'password_new', with: 'some'
  18. fill_in 'password_new_confirm', with: 'some2'
  19. click '.btn--primary'
  20. expect(page).to have_text 'passwords do not match'
  21. end
  22. it 'when new password is invalid, show error' do
  23. fill_in 'password_old', with: user.password_plain
  24. fill_in 'password_new', with: 'some'
  25. fill_in 'password_new_confirm', with: 'some'
  26. click '.btn--primary'
  27. expect(page).to have_text 'Invalid password'
  28. end
  29. it 'allows to change password' do
  30. new_password = generate :password_valid
  31. fill_in 'password_old', with: user.password_plain
  32. fill_in 'password_new', with: new_password
  33. fill_in 'password_new_confirm', with: new_password
  34. click '.btn--primary'
  35. expect(page).to have_text 'Password changed successfully!'
  36. end
  37. end