Feature specs test email sending through delayed jobs

This commit is contained in:
Rohan Mitchell
2015-04-10 17:06:18 +10:00
parent e9fbd74e88
commit ccc1f3df40
3 changed files with 15 additions and 26 deletions

View File

@@ -45,9 +45,9 @@ feature "Authentication", js: true do
describe "signing up" do
before do
ActionMailer::Base.deliveries.clear
select_login_tab "Sign up"
end
scenario "Failing to sign up because password is too short" do
fill_in "Email", with: "test@foo.com"
fill_in "Choose a password", with: "short"
@@ -59,10 +59,11 @@ feature "Authentication", js: true do
fill_in "Email", with: "test@foo.com"
fill_in "Choose a password", with: "test12345"
fill_in "Confirm password", with: "test12345"
click_signup_button
page.should have_content "Welcome! You have signed up successfully"
expect do
click_signup_button
page.should have_content "Welcome! You have signed up successfully"
end.to enqueue_job ConfirmSignupJob
page.should be_logged_in_as "test@foo.com"
ActionMailer::Base.deliveries.last.subject.should =~ /Welcome to/
end
end
@@ -105,4 +106,3 @@ feature "Authentication", js: true do
end
end
end

View File

@@ -16,7 +16,6 @@ feature "As a consumer I want to check out my cart", js: true do
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }
before do
ActionMailer::Base.deliveries.clear
add_enterprise_fee enterprise_fee
set_order order
add_product_to_cart
@@ -80,7 +79,6 @@ feature "As a consumer I want to check out my cart", js: true do
context "on the checkout page with payments open" do
before do
ActionMailer::Base.deliveries.clear
visit checkout_path
checkout_as_guest
toggle_payment
@@ -120,13 +118,11 @@ feature "As a consumer I want to check out my cart", js: true do
end
ActionMailer::Base.deliveries.length.should == 0
place_order
page.should have_content "Your order has been processed successfully"
ActionMailer::Base.deliveries.length.should == 2
email = ActionMailer::Base.deliveries.last
site_name = Spree::Config[:site_name]
email.subject.should include "#{site_name} Order Confirmation"
expect do
place_order
page.should have_content "Your order has been processed successfully"
end.to enqueue_job ConfirmOrderJob
o = Spree::Order.complete.first
expect(o.special_instructions).to eq "SpEcIaL NoTeS"
end
@@ -214,7 +210,6 @@ feature "As a consumer I want to check out my cart", js: true do
context "when the customer has a pre-set shipping and billing address" do
before do
ActionMailer::Base.deliveries.clear
# Load up the customer's order and give them a shipping and billing address
# This is equivalent to when the customer has ordered before and their addresses
# are pre-populated.
@@ -231,10 +226,10 @@ feature "As a consumer I want to check out my cart", js: true do
toggle_payment
choose pm1.name
expect(ActionMailer::Base.deliveries.length).to be 0
place_order
page.should have_content "Your order has been processed successfully"
expect(ActionMailer::Base.deliveries.length).to be 2
expect do
place_order
page.should have_content "Your order has been processed successfully"
end.to enqueue_job ConfirmOrderJob
end
end
end

View File

@@ -26,9 +26,9 @@ feature "shopping with variant overrides defined", js: true do
let(:ef) { create(:enterprise_fee, enterprise: hub, fee_type: 'packing', calculator: Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10)) }
before do
ActionMailer::Base.deliveries.clear
outgoing_exchange.variants = [v1, v2, v3, v4]
outgoing_exchange.enterprise_fees << ef
sm.calculator.preferred_amount = 0
visit shop_path
click_link hub.name
end
@@ -109,15 +109,9 @@ feature "shopping with variant overrides defined", js: true do
complete_checkout
ActionMailer::Base.deliveries.length.should == 2
email = ActionMailer::Base.deliveries.last
o = Spree::Order.complete.last
o.line_items.first.price.should == 55.55
o.total.should == 122.21
email.body.should include "$122.21"
end
it "subtracts stock from the override" do