Sha256: 8c74d60d69328f89061c10592a91470d4286421505ab5145c2052410f6f6fda9

Contents?: true

Size: 1.51 KB

Versions: 16

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'
require 'email_spec'

describe Spree::ReimbursementMailer, :type => :mailer do
  include EmailSpec::Helpers
  include EmailSpec::Matchers

  let(:reimbursement) { create(:reimbursement) }

  context ":from not set explicitly" do
    it "falls back to spree config" do
      message = Spree::ReimbursementMailer.reimbursement_email(reimbursement)
      expect(message.from).to eq [Spree::Store.current.mail_from_address]
    end
  end

  it "accepts a reimbursement id as an alternative to a Reimbursement object" do
    expect(Spree::Reimbursement).to receive(:find).with(reimbursement.id).and_return(reimbursement)

    expect {
      Spree::ReimbursementMailer.reimbursement_email(reimbursement.id).body
    }.not_to raise_error
  end

  context "emails must be translatable" do
    context "reimbursement_email" do
      context "pt-BR locale" do
        before do
          I18n.enforce_available_locales = false
          pt_br_shipped_email = { :spree => { :reimbursement_mailer => { :reimbursement_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
          I18n.enforce_available_locales = true
        end

        specify do
          reimbursement_email = Spree::ReimbursementMailer.reimbursement_email(reimbursement)
          expect(reimbursement_email.body).to include("Caro Cliente,")
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spree_core-3.1.5 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.4 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.3 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.2 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.0.10 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.1 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.0 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.0.rc4 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.0.9 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.0.rc3 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.0.rc2 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.1.0.rc1 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.0.8 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.0.7 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.0.6.1 spec/mailers/reimbursement_mailer_spec.rb
spree_core-3.0.6 spec/mailers/reimbursement_mailer_spec.rb