mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Restore perform_deliveries value in tests
This commit is contained in:
@@ -32,9 +32,11 @@ feature "Managing users" do
|
||||
describe "resending confirmation email", js: true do
|
||||
let(:user) { create :user, confirmed_at: nil }
|
||||
|
||||
it "displays success" do
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
around do |example|
|
||||
performing_deliveries { example.run }
|
||||
end
|
||||
|
||||
it "displays success" do
|
||||
visit spree.edit_admin_user_path user
|
||||
|
||||
expect do
|
||||
|
||||
@@ -21,23 +21,23 @@ feature "Account Settings", js: true do
|
||||
end
|
||||
|
||||
it "allows the user to update their email address" do
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
performing_deliveries do
|
||||
fill_in 'user_email', with: 'new@email.com'
|
||||
|
||||
fill_in 'user_email', with: 'new@email.com'
|
||||
expect do
|
||||
click_button I18n.t(:update)
|
||||
end.to send_confirmation_instructions
|
||||
|
||||
expect do
|
||||
click_button I18n.t(:update)
|
||||
end.to send_confirmation_instructions
|
||||
sent_mail = ActionMailer::Base.deliveries.last
|
||||
expect(sent_mail.to).to eq ['new@email.com']
|
||||
|
||||
sent_mail = ActionMailer::Base.deliveries.last
|
||||
expect(sent_mail.to).to eq ['new@email.com']
|
||||
|
||||
expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.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')
|
||||
expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.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
|
||||
|
||||
it "allows the user to change their password" do
|
||||
|
||||
@@ -71,17 +71,17 @@ feature "Authentication", js: true do
|
||||
end
|
||||
|
||||
scenario "Signing up successfully" do
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
performing_deliveries do
|
||||
setup_email
|
||||
fill_in "Email", with: "test@foo.com"
|
||||
fill_in "Choose a password", with: "test12345"
|
||||
fill_in "Confirm password", with: "test12345"
|
||||
|
||||
setup_email
|
||||
fill_in "Email", with: "test@foo.com"
|
||||
fill_in "Choose a password", with: "test12345"
|
||||
fill_in "Confirm password", with: "test12345"
|
||||
|
||||
expect do
|
||||
click_signup_button
|
||||
expect(page).to have_content I18n.t('devise.user_registrations.spree_user.signed_up_but_unconfirmed')
|
||||
end.to send_confirmation_instructions
|
||||
expect do
|
||||
click_signup_button
|
||||
expect(page).to have_content I18n.t('devise.user_registrations.spree_user.signed_up_but_unconfirmed')
|
||||
end.to send_confirmation_instructions
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,5 +7,17 @@ module OpenFoodNetwork
|
||||
def setup_email
|
||||
Spree::Config[:mails_from] = "test@ofn.example.org"
|
||||
end
|
||||
|
||||
# Ensures the value `perform_deliveries` had is restored. This saves us
|
||||
# from messing up with the test suite's global state which is cause of
|
||||
# trouble.
|
||||
def performing_deliveries
|
||||
old_value = ActionMailer::Base.perform_deliveries
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
|
||||
yield
|
||||
|
||||
ActionMailer::Base.perform_deliveries = old_value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user