<commit_before>require 'spec_helper'
load 'lib/tasks/digests.rake'

describe Rake::Task['digests:send'] do
  it 'queues a job for each digest subscription with events' do
    email_subscription = create(:subscription, channel: 'email', email_address: '<EMAIL>')
    create(:event, publisher: email_subscription.publisher, geom: email_subscription.geom)

    sms_subscription = create(:subscription, channel: 'sms', phone_number: '1234567890')
    create(:event, publisher: sms_subscription.publisher, geom: sms_subscription.geom)

    subscription_no_event = create(:subscription, channel: 'email', email_address: '<EMAIL>')

    expect{ subject.invoke }.to change{ Citygram::Workers::Notifier.jobs.count }.by(+1)
  end
end

describe Rake::Task['digests:send_if_digest_day'] do
  before do
    allow(Citygram::DigestHelper).to receive(:digest_day?).and_return(digest_day?)
    allow(Citygram::DigestHelper).to receive(:send)
  end
<commit_msg>rake digest:send_if_digest_day<commit_after>require 'spec_helper'
load 'lib/tasks/digests.rake'

describe Rake::Task['digests:send'] do
  it 'queues a job for each digest subscription with events' do
    email_subscription = create(:subscription, channel: 'email', email_address: '<EMAIL>')
    create(:event, publisher: email_subscription.publisher, geom: email_subscription.geom)

    sms_subscription = create(:subscription, channel: 'sms', phone_number: '1234567890')
    create(:event, publisher: sms_subscription.publisher, geom: sms_subscription.geom)

    subscription_no_event = create(:subscription, channel: 'email', email_address: 'a@b.cc')

    expect{ subject.invoke }.to change{ Citygram::Workers::Notifier.jobs.count }.by(+1)
  end
end

describe Rake::Task['digests:send_if_digest_day'] do
  before :each do
    allow(Citygram::DigestHelper).to receive(:digest_day?).and_return(digest_day?)
    allow(Citygram::DigestHelper).to receive(:send)
  end

{'fraction_non_alphanumeric': 0.1278825995807128, 'fraction_numerical': 0.011530398322851153, 'mean_word_length': 6.39922480620155, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '7298435', 'n_tokens_mistral': 629, 'n_tokens_neox': 607, 'n_words': 130}