Skip to content

Commit

Permalink
revert change_password spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-coggin committed Dec 5, 2023
1 parent 64f70f6 commit 3eb81be
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions spec/system/registered_user/changing_password_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'rails_helper'

RSpec.describe 'Registered user changing password', type: :system do
subject(:user) { create :user, :registered, created_at: 1.month.ago }

let(:password) { 'Str0ngPa$$w0rd' }


include_context 'with user'

before do
puts user.email
visit '/my-account/edit-password'
fill_in 'Enter your current password', with: 'Str0ngPa$$w0rd'
fill_in 'Create a new password', with: password
fill_in 'Confirm password', with: password
end

context 'when cancelled' do
it 'returns to account page' do
click_link 'Cancel'
expect(page).to have_current_path '/my-account'
expect(page).not_to have_text 'Your new password has been saved.'
end
end

context 'when successful' do
let(:password) { '12!@NewPassword' }
let(:today) { Time.zone.today.to_formatted_s(:rfc822) } # 18 May 2022

it 'updates password' do
click_button 'Save'
expect(page).to have_current_path '/my-account'
expect(page).to have_text('Manage your account') # page heading
.and have_text('Your new password has been saved.') # flash message
.and have_text("Password last changed on #{today}") # event
end
end

context 'when too short' do
let(:password) { 'short' }

it 'renders an error message' do
click_button 'Save'
expect(page).to have_text 'Password must be at least 10 characters.'
end
end

context 'when blank' do
let(:password) { '' }

it 'renders an error message' do
click_button 'Save'
expect(page).to have_text 'Enter a password.'
end
end
end

0 comments on commit 3eb81be

Please sign in to comment.