Update specs to work with ActionMailer::DeliveryJob

This commit is contained in:
Matt-Yorkley
2020-11-08 01:53:53 +00:00
parent 64153c5072
commit 2b884be8dd
5 changed files with 20 additions and 19 deletions

View File

@@ -70,7 +70,9 @@ describe UserConfirmationsController, type: :controller do
performing_deliveries do
expect do
spree_post :create, spree_user: { email: unconfirmed_user.email }
end.to send_confirmation_instructions
end.to enqueue_job ActionMailer::DeliveryJob
expect(enqueued_jobs.last.to_s).to match "confirmation_instructions"
end
end
end

View File

@@ -124,7 +124,7 @@ feature "Managing users" do
# The `a` element doesn't have an href, so we can't use click_link.
find("a", text: "Resend").click
expect(page).to have_text "Resend done"
end.to send_confirmation_instructions
end.to enqueue_job ActionMailer::DeliveryJob
end
end
end

View File

@@ -21,23 +21,22 @@ feature "Account Settings", js: true do
end
it "allows the user to update their email address" do
performing_deliveries do
fill_in 'user_email', with: 'new@email.com'
fill_in 'user_email', with: 'new@email.com'
performing_deliveries do
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']
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.to enqueue_job ActionMailer::DeliveryJob
end
expect(enqueued_jobs.last.to_s).to match "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
it "allows the user to change their password" do

View File

@@ -1,6 +1,6 @@
require 'spec_helper'
describe Spree.user_class do
describe Spree::User do
include OpenFoodNetwork::EmailHelper
describe "associations" do
@@ -81,11 +81,10 @@ describe Spree.user_class do
performing_deliveries do
expect do
create(:user, email: 'new_user@example.com', confirmation_sent_at: nil, confirmed_at: nil)
end.to send_confirmation_instructions
end.to enqueue_job ActionMailer::DeliveryJob
end
sent_mail = ActionMailer::Base.deliveries.last
expect(sent_mail.to).to eq ['new_user@example.com']
expect(enqueued_jobs.last.to_s).to match "confirmation_instructions"
end
context "with the the same email as existing customers" do

View File

@@ -194,6 +194,7 @@ RSpec.configure do |config|
config.include OpenFoodNetwork::DelayedJobHelper
config.include OpenFoodNetwork::PerformanceHelper
config.include DownloadsHelper, type: :feature
config.include ActiveJob::TestHelper
# FactoryBot
require 'factory_bot_rails'