From 55411af3fa09db906a3723bac36977a03f78b9b9 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 8 Oct 2018 23:55:28 +0100 Subject: [PATCH] Improve user account spec --- .../consumer/account/settings_spec.rb | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/spec/features/consumer/account/settings_spec.rb b/spec/features/consumer/account/settings_spec.rb index 383d03a4bed..e9001f177c4 100644 --- a/spec/features/consumer/account/settings_spec.rb +++ b/spec/features/consumer/account/settings_spec.rb @@ -4,18 +4,22 @@ include AuthenticationWorkflow describe "as a logged in user" do - let(:user) { create(:user, email: 'old@email.com') } + let(:user) do + create(:user, + email: 'old@email.com', + password: 'OriginalPassword', + password_confirmation: 'OriginalPassword') + end before do create(:mail_method) quick_login_as user - end - - it "allows me to update my account details" do visit "/account" - click_link I18n.t('spree.users.show.tabs.settings') expect(page).to have_content I18n.t('spree.users.form.account_settings') + end + + it "allows the user to update their email address" do fill_in 'user_email', with: 'new@email.com' click_button I18n.t(:update) @@ -27,5 +31,18 @@ click_link I18n.t('spree.users.show.tabs.settings') expect(page).to have_content I18n.t('spree.users.show.unconfirmed_email', unconfirmed_email: 'new@email.com') end + + it "allows the user to change their password" do + allow(Spree::Auth::Config).to receive(:[]).with(:signout_after_password_change).and_return(false) + initial_password = user.encrypted_password + + fill_in 'user_password', with: 'NewPassword' + fill_in 'user_password_confirmation', with: 'NewPassword' + + click_button I18n.t(:update) + expect(find(".alert-box.success").text.strip).to eq "#{I18n.t(:account_updated)} ×" + + expect(user.reload.encrypted_password).to_not eq initial_password + end end end