Updated

spec/jobs / notify_creators_that_moderation_is_delayed_job_spec.rb

A
32 lines of codes
0 methods
N/A complexity/method
3 churn
33.59 complexity
0 duplications
require 'rails_helper' RSpec.describe NotifyCreatorsThatModerationIsDelayedJob, type: :job do let(:petition) { FactoryBot.create(:sponsored_petition, :overdue, sponsors_signed: true) } let(:signature) { petition.creator } let(:subject) { "Moderation of your petition is delayed" } let(:body) { "Sorry, but moderation of your petition is delayed for reasons." } let(:notify_creator_job) do { job: NotifyCreatorThatModerationIsDelayedJob, args: [ { "_aj_globalid" => "gid://epets/Signature/#{signature.id}" }, "Moderation of your petition is delayed", "Sorry, but moderation of your petition is delayed for reasons." ], queue: "low_priority" } end before do expect(Petition).to receive_message_chain(:overdue_in_moderation, :find_each).and_yield(petition) end it "enqueues a job for every petition that is open at dissolution" do expect { described_class.perform_now(subject, body) }.to change { enqueued_jobs }.from([]).to([notify_creator_job]) end end