Sha256: 4fc2190e50e2742bd19ca299673e8639dc78e21e7bd542a18f092be9cc9bf68e

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'
require 'email_spec'

describe Spree::CartonMailer do
  include EmailSpec::Helpers
  include EmailSpec::Matchers

  let(:carton) { create(:carton) }
  let(:order) { carton.orders.first }

  # Regression test for https://github.com/spree/spree/issues/2196
  it "doesn't include out of stock in the email body" do
    shipment_email = Spree::CartonMailer.shipped_email(order: order, carton: carton)
    expect(shipment_email).not_to have_body_text(%{Out of Stock})
    expect(shipment_email).to have_body_text(%{Your order has been shipped})
    expect(shipment_email.subject).to eq "#{order.store.name} Shipment Notification ##{order.number}"
  end

  context "with resend option" do
    subject do
      Spree::CartonMailer.shipped_email(order: order, carton: carton, 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(order: order, carton: carton)
          expect(shipped_email).to have_body_text("Caro Cliente,")
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-2.3.1 spec/mailers/carton_mailer_spec.rb
solidus_core-2.3.0 spec/mailers/carton_mailer_spec.rb
solidus_core-2.3.0.rc3 spec/mailers/carton_mailer_spec.rb
solidus_core-2.3.0.rc2 spec/mailers/carton_mailer_spec.rb
solidus_core-2.3.0.rc1 spec/mailers/carton_mailer_spec.rb
solidus_core-2.3.0.beta1 spec/mailers/carton_mailer_spec.rb