diff --git a/app/mailers/spree/base_mailer.rb b/app/mailers/spree/base_mailer.rb index 5d6e616b1f..d0f86d8ace 100644 --- a/app/mailers/spree/base_mailer.rb +++ b/app/mailers/spree/base_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Spree class BaseMailer < ActionMailer::Base # Inline stylesheets diff --git a/app/mailers/spree/order_mailer.rb b/app/mailers/spree/order_mailer.rb index cb90f25b68..4cd6676c59 100644 --- a/app/mailers/spree/order_mailer.rb +++ b/app/mailers/spree/order_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Spree class OrderMailer < BaseMailer helper HtmlHelper diff --git a/app/mailers/spree/shipment_mailer.rb b/app/mailers/spree/shipment_mailer.rb index d9f00671a1..ccbac24efe 100644 --- a/app/mailers/spree/shipment_mailer.rb +++ b/app/mailers/spree/shipment_mailer.rb @@ -1,9 +1,12 @@ +# frozen_string_literal: true + module Spree class ShipmentMailer < BaseMailer def shipped_email(shipment, resend = false) @shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment) subject = (resend ? "[#{Spree.t(:resend).upcase}] " : '') - subject += "#{Spree::Config[:site_name]} #{Spree.t('shipment_mailer.shipped_email.subject')} ##{@shipment.order.number}" + base_subject = Spree.t('shipment_mailer.shipped_email.subject') + subject += "#{Spree::Config[:site_name]} #{base_subject} ##{@shipment.order.number}" mail(to: @shipment.order.email, from: from_address, subject: subject) end end diff --git a/app/mailers/spree/test_mailer.rb b/app/mailers/spree/test_mailer.rb index 8a54742722..1f41f55a52 100644 --- a/app/mailers/spree/test_mailer.rb +++ b/app/mailers/spree/test_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Spree class TestMailer < BaseMailer def test_email(user) diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb index 3af2b50339..2261edc802 100644 --- a/spec/mailers/order_mailer_spec.rb +++ b/spec/mailers/order_mailer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Spree::OrderMailer do @@ -6,12 +8,12 @@ describe Spree::OrderMailer do contect "original spree specs" do let(:order) do order = stub_model(Spree::Order) - product = stub_model(Spree::Product, :name => %Q{The "BEST" product}) - variant = stub_model(Spree::Variant, :product => product) - price = stub_model(Spree::Price, :variant => variant, :amount => 5.00) - line_item = stub_model(Spree::LineItem, :variant => variant, :order => order, :quantity => 1, :price => 4.99) - variant.stub(:default_price => price) - order.stub(:line_items => [line_item]) + product = stub_model(Spree::Product, name: %{The "BEST" product}) + variant = stub_model(Spree::Variant, product: product) + price = stub_model(Spree::Price, variant: variant, amount: 5.00) + line_item = stub_model(Spree::LineItem, variant: variant, order: order, quantity: 1, price: 4.99) + variant.stub(default_price: price) + order.stub(line_items: [line_item]) order end @@ -44,15 +46,15 @@ describe Spree::OrderMailer do context "only shows eligible adjustments in emails" do before do order.adjustments.create( - :label => "Eligible Adjustment", - :amount => 10, - :eligible => true + label: "Eligible Adjustment", + amount: 10, + eligible: true ) order.adjustments.create!( - :label => "Ineligible Adjustment", - :amount => -10, - :eligible => false + label: "Ineligible Adjustment", + amount: -10, + eligible: false ) end @@ -85,8 +87,8 @@ describe Spree::OrderMailer do context "emails must be translatable" do context "pt-BR locale" do before do - pt_br_confirm_mail = { :spree => { :order_mailer => { :confirm_email => { :dear_customer => 'Caro Cliente,' } } } } - pt_br_cancel_mail = { :spree => { :order_mailer => { :cancel_email => { :order_summary_canceled => 'Resumo da Pedido [CANCELADA]' } } } } + pt_br_confirm_mail = { spree: { order_mailer: { confirm_email: { dear_customer: 'Caro Cliente,' } } } } + pt_br_cancel_mail = { spree: { order_mailer: { cancel_email: { order_summary_canceled: 'Resumo da Pedido [CANCELADA]' } } } } I18n.backend.store_translations :'pt-BR', pt_br_confirm_mail I18n.backend.store_translations :'pt-BR', pt_br_cancel_mail I18n.locale = :'pt-BR' diff --git a/spec/mailers/shipment_mailer_spec.rb b/spec/mailers/shipment_mailer_spec.rb index c7a0da6172..994ec0b871 100644 --- a/spec/mailers/shipment_mailer_spec.rb +++ b/spec/mailers/shipment_mailer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'email_spec' @@ -7,12 +9,12 @@ describe Spree::ShipmentMailer do let(:shipment) do order = stub_model(Spree::Order) - product = stub_model(Spree::Product, :name => %Q{The "BEST" product}) - variant = stub_model(Spree::Variant, :product => product) - line_item = stub_model(Spree::LineItem, :variant => variant, :order => order, :quantity => 1, :price => 5) + product = stub_model(Spree::Product, name: %{The "BEST" product}) + variant = stub_model(Spree::Variant, product: product) + line_item = stub_model(Spree::LineItem, variant: variant, order: order, quantity: 1, price: 5) shipment = stub_model(Spree::Shipment) - shipment.stub(:line_items => [line_item], :order => order) - shipment.stub(:tracking_url => "TRACK_ME") + shipment.stub(line_items: [line_item], order: order) + shipment.stub(tracking_url: "TRACK_ME") shipment end @@ -26,7 +28,7 @@ describe Spree::ShipmentMailer do # Regression test for #2196 it "doesn't include out of stock in the email body" do shipment_email = Spree::ShipmentMailer.shipped_email(shipment) - shipment_email.body.should_not include(%Q{Out of Stock}) + shipment_email.body.should_not include(%{Out of Stock}) end it "shipment_email accepts an shipment id as an alternative to an Shipment object" do @@ -40,7 +42,9 @@ describe Spree::ShipmentMailer 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,' } } } } + 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 diff --git a/spec/mailers/test_mailer_spec.rb b/spec/mailers/test_mailer_spec.rb index 6ed147ad10..b758040547 100644 --- a/spec/mailers/test_mailer_spec.rb +++ b/spec/mailers/test_mailer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'email_spec' @@ -20,4 +22,4 @@ describe Spree::TestMailer do test_email = Spree::TestMailer.test_email(user.id) }.should_not raise_error end -end \ No newline at end of file +end