Updated

spec/jobs / enqueue_petition_statistics_updates_job_spec.rb

C
47 lines of codes
0 methods
N/A complexity/method
2 churn
95.9 complexity
24 duplications
require 'rails_helper' RSpec.describe EnqueuePetitionStatisticsUpdatesJob, type: :job do let(:timestamp) { 1.day.ago.iso8601 } it "only enqueues jobs for petitions signed in the last day" do
  1. it#only enqueues jobs for petitions signed in the last day has a flog score of 36
FactoryBot.create(:open_petition, last_signed_at: 6.hours.ago) FactoryBot.create(:open_petition, last_signed_at: 36.hours.ago) FactoryBot.create(:open_petition, last_signed_at: 18.hours.ago) expect { described_class.perform_now(timestamp) }.to change { enqueued_jobs.size }.from(0).to(2) end describe "configuration" do before do FactoryBot.create(:open_petition, last_signed_at: 6.hours.ago) end context "when the daily update job is disabled" do
  1. Similar code found in 2 nodes Locations: 0 1
before do allow(Site).to receive(:disable_daily_update_statistics_job?).and_return(true) end it "doesn't enqueue any jobs" do expect { described_class.perform_now(timestamp) }.not_to have_enqueued_job(UpdatePetitionStatisticsJob) end end context "when the daily update job is enabled" do before do allow(Site).to receive(:disable_daily_update_statistics_job?).and_return(false) end it "enqueues an UpdatePetitionStatisticsJob job" do expect { described_class.perform_now(timestamp) }.to have_enqueued_job(UpdatePetitionStatisticsJob) end end end end