Skip to content

Commit

Permalink
Improve user account spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Yorkley committed Oct 9, 2018
1 parent 3e39f3e commit 55411af
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions spec/features/consumer/account/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
include AuthenticationWorkflow

describe "as a logged in user" do
let(:user) { create(:user, email: '[email protected]') }
let(:user) do
create(:user,
email: '[email protected]',
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: '[email protected]'

click_button I18n.t(:update)
Expand All @@ -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: '[email protected]')
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

0 comments on commit 55411af

Please sign in to comment.