diff --git a/core/app/models/spree/order_shipping.rb b/core/app/models/spree/order_shipping.rb index 0908ea68a38..747074ee3ca 100644 --- a/core/app/models/spree/order_shipping.rb +++ b/core/app/models/spree/order_shipping.rb @@ -72,7 +72,7 @@ def ship(inventory_units:, stock_location:, address:, shipping_method:, end end - send_shipment_email(carton) if stock_location.fulfillable? && !suppress_mailer # e.g. digital gift cards that aren't actually shipped + send_shipment_emails(carton) if stock_location.fulfillable? && !suppress_mailer # e.g. digital gift cards that aren't actually shipped fulfill_order_stock_locations(stock_location) @order.update! @@ -85,7 +85,7 @@ def fulfill_order_stock_locations(stock_location) Spree::OrderStockLocation.fulfill_for_order_with_stock_location(@order, stock_location) end - def send_shipment_email(carton) + def send_shipment_emails(carton) carton.orders.each do |order| Spree::CartonMailer.shipped_email(order, carton).deliver_later end diff --git a/core/spec/models/spree/shipment_spec.rb b/core/spec/models/spree/shipment_spec.rb index 213314ae53f..926f31788fb 100644 --- a/core/spec/models/spree/shipment_spec.rb +++ b/core/spec/models/spree/shipment_spec.rb @@ -670,11 +670,12 @@ end it 'does not send a confirmation email' do - expect(unshippable_shipment).to_not receive(:send_shipment_email) - unshippable_shipment.ready! - unshippable_shipment.inventory_units(true).each do |unit| - expect(unit.state).to eq('shipped') - end + expect { + unshippable_shipment.ready! + unshippable_shipment.inventory_units(true).each do |unit| + expect(unit.state).to eq('shipped') + end + }.not_to change{ ActionMailer::Base.deliveries.count } end end