<commit_before>require 'spec_helper'

describe DumpMailer do
  let(:users) { create_list(:user, 2) }
  let(:owner) { users.sample }
  let(:resource) do
    double(id: 1, class: Workflow, communication_emails: [owner.email])
  end
  let(:metadata) { {"recipients" => users.map(&:id) } }
  let(:medium) { double(id: 2, get_url: nil, metadata: metadata) }
  let(:dump_mailer) { described_class.new(resource, medium, "classifications") }

  describe 'queueing notification emails' do
    let(:expected_emails) { users.map(&:email) }

    before do
      expect(ClassificationDataMailerWorker)
      .to receive(:perform_async)
      .with(resource.id, "workflow", nil, expected_emails)
      .once
      .and_call_original
    end

    it 'queues up an email job' do
      dump_mailer.send_email
    end

    context "with no specified recipients" do
      let(:metadata) { { } }
      let(:expected_emails) { [ owner.email ] }

      it 'queues an email to the owner' do
        dump_mailer.send_email
      end
    end
  end
end<commit_msg>ensure email order in specs (#2811)<commit_after>require 'spec_helper'

describe DumpMailer do
  let(:users) { create_list(:user, 2) }
  let(:owner) { users.sample }
  let(:resource) do
    double(id: 1, class: Workflow, communication_emails: [owner.email])
  end
  let(:metadata) { {"recipients" => users.map(&:id) } }
  let(:medium) { double(id: 2, get_url: nil, metadata: metadata) }
  let(:dump_mailer) { described_class.new(resource, medium, "classifications") }

  describe 'queueing notification emails' do
    let(:expected_emails) { users.map(&:email) }

    before do
      expect(ClassificationDataMailerWorker)
      .to receive(:perform_async)
      .with(resource.id, "workflow", nil, expected_emails)
      .once
      .and_call_original
    end

    it 'queues up an email job' do
      expected_emails = users.map(&:email)
      allow(dump_mailer).to receive(:emails).and_return(expected_emails)
      dump_mailer.send_email
    end

    context "with no specified recipients" do
      let(:metadata) { { } }
      let(:expected_emails) { [ owner.email ] }

      it 'queues an email to the owner' do
        dump_mailer.send_email
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12104787714543812, 'fraction_numerical': 0.004516711833785004, 'mean_word_length': 3.3602362204724407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7046964', 'n_tokens_mistral': 743, 'n_tokens_neox': 715, 'n_words': 174}