<commit_before># We'll use the OrderMailer as a quick and easy way to test. IF it works here
# it works for all email (in theory.)
describe Spree::OrderMailer do
  let(:order) { Spree::Order.new(email: "<EMAIL>") }
  let(:message) { described_class.confirm_email(order) }

  before(:all) do
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries.clear
  end

  context "#deliver" do
    before do
      ActionMailer::Base.delivery_method = :test
    end

    after { ActionMailer::Base.deliveries.clear }

    it "should use the from address specified in the preference" do
      Spree::Config[:mails_from] = "no-<EMAIL>"
      message.deliver
      @email = ActionMailer::Base.deliveries.first
      expect(@email.from).to match_array ["<EMAIL>"]
    end

    it "should use the provided from address" do
      Spree::Config[:mails_from] = "<EMAIL>"
      message.from = "<EMAIL>"
      message.to = "<EMAIL>"
      message.deliver
      email = ActionMailer::Base.deliveries.first
      expect(email.from).to match_array ["<EMAIL>"]
      expect(email.to).to match_array ["<EMAIL>"]
    end

    it "should add the bcc email when provided" do
      Spree::Config[:mail_bcc] = "<EMAIL>"
      message.deliver
      @email = ActionMailer::Base.deliveries.first
      expect(@email.bcc).to match_array ["<EMAIL>-<EMAIL>"]
    end

    context "when intercept_email is provided" do
      it "should strip the bcc recipients" do
        expect(message.bcc).to be_blank
      end

      it "should strip the cc recipients" do
        expect(message.cc).to be_blank
      end

      it "should replace the receipient with the specified address" do
        Spree::Config[:intercept_email] = "<EMAIL>"
        message.deliver
        @email = ActionMailer::Base.deliveries.first
        expect(@email.to).to match_array ["<EMAIL>"]
      end

      it "should modify the subject to include the original email" do
        Spree::Config[:intercept_email] = "<EMAIL>"
        message.deliver
        @email = ActionMailer::Base.deliveries.first
        expect(@email.subject.match(/<EMAIL>\.<EMAIL>/)).to be_truthy
      end
    end

    context "when intercept_mode is not provided" do
      it "should not modify the recipient" do
        Spree::Config[:intercept_email] = ""
        message.deliver
        @email = ActionMailer::Base.deliveries.first
        expect(@email.to).to match_array ["<EMAIL>"]
      end
    end
  end
end<commit_msg>Remove deliver deprecation warnings in spec.<commit_after># We'll use the OrderMailer as a quick and easy way to test. IF it works here
# it works for all email (in theory.)
describe Spree::OrderMailer do
  let(:order) { Spree::Order.new(email: "<EMAIL>") }
  let(:message) { described_class.confirm_email(order) }

  before(:all) do
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries.clear
  end

  context "#deliver" do
    before do
      ActionMailer::Base.delivery_method = :test
    end

    after { ActionMailer::Base.deliveries.clear }

    it "should use the from address specified in the preference" do
      Spree::Config[:mails_from] = "<EMAIL>"
      deliver message
      expect(@email.from).to match_array ["<EMAIL>"]
    end

    it "should use the provided from address" do
      Spree::Config[:mails_from] = "<EMAIL>"
      message.from = "<EMAIL>"
      message.to = "<EMAIL>"
      deliver message
      expect(@email.from).to match_array ["<EMAIL>"]
      expect(@email.to).to match_array ["<EMAIL>"]
    end

    it "should add the bcc email when provided" do
      Spree::Config[:mail_bcc] = "<EMAIL>-<EMAIL>"
      deliver message
      expect(@email.bcc).to match_array ["bcc-<EMAIL>"]
    end

    context "when intercept_email is provided" do
      it "should strip the bcc recipients" do
        expect(message.bcc).to be_blank
      end

      it "should strip the cc recipients" do
        expect(message.cc).to be_blank
      end

      it "should replace the receipient with the specified address" do
        Spree::Config[:intercept_email] = "<EMAIL>"
        deliver message
        expect(@email.to).to match_array ["<EMAIL>"]
      end

      it "should modify the subject to include the original email" do
        Spree::Config[:intercept_email] = "<EMAIL>"
        deliver message
        expect(@email.subject.match(/customer@example\.com/)).to be_truthy
      end
    end

    context "when intercept_mode is not provided" do
      it "should not modify the recipient" do
        Spree::Config[:intercept_email] = ""
        deliver message
        expect(@email.to).to match_array ["<EMAIL>"]
      end
    end

    def deliver(message)
      message.deliver_now
      @email = ActionMailer::Base.deliveries.first
    end
  end
end
{'fraction_non_alphanumeric': 0.1119731599916125, 'fraction_numerical': 0.0, 'mean_word_length': 2.8970588235294117, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7299792', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1443, 'n_words': 404}