<commit_before># frozen_string_literal: true

require 'rails_helper'

RSpec.describe OpenAccessEbookTrustJob, type: :job do
  describe "perform" do
    let(:mailer) { double("mailer", deliver_now: true) }
    let(:mock_zip) { double('mock_zip') }

    before do
      create(:press, subdomain: "michigan")
      allow(OpenAccessEbookTrustMailer).to receive(:send_report).with(mock_zip).and_return(mailer)
      # This is SUPER mocky, it's bad to mock the system under test, obvs.
      # Because the methods in this job are being tested individually I'm
      # justifiying this. But I agree, it's not great.
      # An alternative I experimented with was setting up the system state with like 100 variables,
      # monographs, file_sets, featured_reps, counter report counts, greensub institutions/products/components
      # and then zipping all the results. I don't know. I didn't like that either.
      allow_any_instance_of(described_class).to receive(:zipup).and_return(mock_zip)
    end

    it "calls the mailer" do
      described_class.perform_now
      expect(OpenAccessEbookTrustMailer).to have_received(:send_report).with(mock_zip)
    end<commit_msg>HELIO-3962 OpenAccessEbookTrustJob spec should not file  in July and January<commit_after># frozen_string_literal: true

require 'rails_helper'

RSpec.describe OpenAccessEbookTrustJob, type: :job do
  describe "perform" do
    let(:mailer) { double("mailer", deliver_now: true) }
    let(:mock_zip) { double('mock_zip') }

    before do
      create(:press, subdomain: "michigan")
      allow(OpenAccessEbookTrustMailer).to receive(:send_report).with(mock_zip).and_return(mailer)
      # This is SUPER mocky, it's bad to mock the system under test, obvs.
      # Because the methods in this job are being tested individually I'm
      # justifiying this. But I agree, it's not great.
      # An alternative I experimented with was setting up the system state with like 100 variables,
      # monographs, file_sets, featured_reps, counter report counts, greensub institutions/products/components
      # and then zipping all the results. I don't know. I didn't like that either.
      allow_any_instance_of(described_class).to receive(:zipup).and_return(mock_zip)
    end

    it "calls the mailer" do
      travel_to(Time.parse("2020-05-01")) do
        described_class.perform_now
        expect(OpenAccessEbookTrustMailer).to have_received(:send_report).with(mock_zip)
      end
    end
{'fraction_non_alphanumeric': 0.08557457212713937, 'fraction_numerical': 0.007334963325183374, 'mean_word_length': 3.9898373983739837, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2549800', 'n_tokens_mistral': 767, 'n_tokens_neox': 719, 'n_words': 225}