Sha256: 35ad8a0d34ebffb33d9cfaecdbee3cd6a126a2ecd922e4b7250d57e73d9b311c

Contents?: true

Size: 1.43 KB

Versions: 48

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require 'rails_helper'
RSpec.describe Spree::PromotionCodeBatchMailer, type: :mailer do
  let(:promotion) { create(:promotion, name: "Promotion Test") }
  let(:promotion_code_batch) do
    Spree::PromotionCodeBatch.create!(
      promotion_id: promotion.id,
      base_code: "test",
      number_of_codes: 10,
      email: "test@email.com"
    )
  end

  describe "#promotion_code_batch_finished" do
    subject { described_class.promotion_code_batch_finished(promotion_code_batch) }

    it "sends the email to the email attached to the promotion code batch " do
      expect(subject.to).to eq([promotion_code_batch.email])
    end

    it "contains the number of codes created" do
      expect(subject.body).to include("All 10 codes have been created")
    end

    it "contains the name of the promotion" do
      expect(subject.body).to include(promotion.name)
    end
  end

  describe "#promotion_code_batch_errored" do
    before { promotion_code_batch.update(error: "Test error") }
    subject { described_class.promotion_code_batch_errored(promotion_code_batch) }

    it "sends the email to the email attached to the promotion code batch " do
      expect(subject.to).to eq([promotion_code_batch.email])
    end

    it "contains the error" do
      expect(subject.body).to include("Test error")
    end

    it "contains the name of the promotion" do
      expect(subject.body).to include(promotion.name)
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
solidus_core-2.8.4 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.8.3 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.7.2 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.6.4 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.8.2 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.8.1 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.6.3 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.8.0 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.7.1 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core-2.6.2 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.10 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.9 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.8 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.7 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.6 spec/mailers/promotion_code_batch_mailer_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.5 spec/mailers/promotion_code_batch_mailer_spec.rb