diff --git a/config/initializers/spree.rb b/config/initializers/spree.rb index 9b62e3ad6e..e63d21bde9 100644 --- a/config/initializers/spree.rb +++ b/config/initializers/spree.rb @@ -22,6 +22,9 @@ Spree.config do |config| #config.override_actionmailer_config = false end +# Don't log users out when setting a new password +Spree::Auth::Config[:signout_after_password_change] = false + # TODO Work out why this is necessary # Seems like classes within OFN module become 'uninitialized' when server reloads # unless the empty module is explicity 'registered' here. Something to do with autoloading? diff --git a/spec/features/consumer/account/settings_spec.rb b/spec/features/consumer/account/settings_spec.rb index 64cdff0f05..aaea521671 100644 --- a/spec/features/consumer/account/settings_spec.rb +++ b/spec/features/consumer/account/settings_spec.rb @@ -4,18 +4,22 @@ feature "Account Settings", js: true do 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' expect do @@ -32,5 +36,17 @@ feature "Account Settings", js: true do 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 + 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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 328c2aaac3..6b73d23fb0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -120,6 +120,7 @@ RSpec.configure do |config| spree_config.allow_backorders = false end + Spree::Auth::Config[:signout_after_password_change] = false Spree::Api::Config[:requires_authentication] = true end