-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ShipmentMailer to use Cartons
Conflicts: core/app/mailers/spree/shipment_mailer.rb core/app/models/spree/shipment.rb core/spec/mailers/shipment_mailer_spec.rb
- Loading branch information
Showing
11 changed files
with
146 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Spree | ||
class CartonMailer < BaseMailer | ||
# Send an email to customers to notify that an individual carton has been | ||
# shipped. | ||
def shipped_email(carton_id, resend: false) | ||
@carton = Spree::Carton.find(carton_id) | ||
subject = (resend ? "[#{Spree.t(:resend).upcase}] " : '') | ||
subject += "#{Spree::Config[:site_name]} #{Spree.t('shipment_mailer.shipped_email.subject')} ##{@carton.order_numbers.join(', ')}" | ||
mail(to: @carton.order_emails, from: from_address, subject: subject) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Spree::ShippingManifest | ||
ManifestItem = Struct.new(:line_item, :variant, :quantity, :states) | ||
|
||
def manifest | ||
# Grouping by the ID means that we don't have to call out to the association accessor | ||
# This makes the grouping by faster because it results in less SQL cache hits. | ||
inventory_units.group_by(&:variant_id).map do |variant_id, units| | ||
units.group_by(&:line_item_id).map do |line_item_id, units| | ||
|
||
states = {} | ||
units.group_by(&:state).each { |state, iu| states[state] = iu.count } | ||
|
||
line_item = units.first.line_item | ||
variant = units.first.variant | ||
ManifestItem.new(line_item, variant, units.length, states) | ||
end | ||
end.flatten | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'spec_helper' | ||
require 'email_spec' | ||
|
||
describe Spree::CartonMailer do | ||
include EmailSpec::Helpers | ||
include EmailSpec::Matchers | ||
|
||
let(:carton) { create(:carton) } | ||
|
||
context ":from not set explicitly" do | ||
it "falls back to spree config" do | ||
message = Spree::CartonMailer.shipped_email(carton.id) | ||
message.from.should == [Spree::Config[:mails_from]] | ||
end | ||
end | ||
|
||
# Regression test for #2196 | ||
it "doesn't include out of stock in the email body" do | ||
shipment_email = Spree::CartonMailer.shipped_email(carton.id) | ||
shipment_email.body.should_not include(%Q{Out of Stock}) | ||
end | ||
|
||
context "with resend option" do | ||
subject do | ||
Spree::CartonMailer.shipped_email(carton.id, resend: true).subject | ||
end | ||
it { is_expected.to match /^\[RESEND\] / } | ||
end | ||
|
||
context "emails must be translatable" do | ||
context "shipped_email" do | ||
context "pt-BR locale" do | ||
before do | ||
pt_br_shipped_email = { :spree => { :shipment_mailer => { :shipped_email => { :dear_customer => 'Caro Cliente,' } } } } | ||
I18n.backend.store_translations :'pt-BR', pt_br_shipped_email | ||
I18n.locale = :'pt-BR' | ||
end | ||
|
||
after do | ||
I18n.locale = I18n.default_locale | ||
end | ||
|
||
specify do | ||
shipped_email = Spree::CartonMailer.shipped_email(carton.id) | ||
shipped_email.body.should include("Caro Cliente,") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters