mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-10 03:30:22 +00:00
Using deferred methods on the user model breaks delayed jobs when the user is deleted while the job still exists. We could create a proper job referencing a user id for sending these emails instead. But since the user has to wait for the confirmation email anyway, we can send it within the current request. This should be revised if performance becomes an issue. Sending the email directly also has the advantage that we can tell the user if emailing failed. See the following commits. This change impacts a bunch of specs as we now need a working email setup to create unconfirmed users. This commit introduces a custom matcher to unify testing for confirmation emails.
32 lines
973 B
Ruby
32 lines
973 B
Ruby
require 'spec_helper'
|
||
|
||
feature "Account Settings", js: true do
|
||
include AuthenticationWorkflow
|
||
|
||
describe "as a logged in user" do
|
||
let(:user) { create(:user, email: 'old@email.com') }
|
||
|
||
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')
|
||
fill_in 'user_email', with: 'new@email.com'
|
||
|
||
click_button I18n.t(:update)
|
||
|
||
expect(find(".alert-box.success").text.strip).to eq "#{I18n.t(:account_updated)} ×"
|
||
user.reload
|
||
expect(user.email).to eq 'old@email.com'
|
||
expect(user.unconfirmed_email).to eq 'new@email.com'
|
||
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
|
||
end
|
||
end
|