Updated

spec/jobs / notify_everyone_of_moderation_decision_job_spec.rb

D
98 lines of codes
0 methods
N/A complexity/method
4 churn
198.64 complexity
122 duplications
require 'rails_helper' RSpec.describe NotifyEveryoneOfModerationDecisionJob, type: :job do let(:petition) { FactoryBot.create(:pending_petition, sponsor_count: 0) } let(:creator) { petition.creator } let(:validated_sponsor) { FactoryBot.create(:sponsor, :validated, petition: petition) } let(:pending_sponsor) { FactoryBot.create(:sponsor, :pending, petition: petition) } context "when the petition is published" do before do petition.publish end it "notifies the creator" do expect(PetitionMailer).to receive(:notify_creator_that_petition_is_published).with(creator).and_call_original perform_enqueued_jobs do described_class.perform_later(petition) end end it "notifies the validated sponsors" do expect(PetitionMailer).to receive(:notify_sponsor_that_petition_is_published).with(validated_sponsor).and_call_original perform_enqueued_jobs do described_class.perform_later(petition) end end it "doesn't notify the pending sponsors" do expect(PetitionMailer).not_to receive(:notify_sponsor_that_petition_is_published).with(pending_sponsor) perform_enqueued_jobs do described_class.perform_later(petition) end end end context "when the petition is rejected" do
  1. Similar code found in 2 nodes Locations: 0 1
before do petition.reject(code: "duplicate") end it "notifies the creator" do expect(PetitionMailer).to receive(:notify_creator_that_petition_was_rejected).with(creator).and_call_original perform_enqueued_jobs do described_class.perform_later(petition) end end it "notifies the validated sponsors" do expect(PetitionMailer).to receive(:notify_sponsor_that_petition_was_rejected).with(validated_sponsor).and_call_original perform_enqueued_jobs do described_class.perform_later(petition) end end it "doesn't notify the pending sponsors" do expect(PetitionMailer).not_to receive(:notify_sponsor_that_petition_was_rejected).with(pending_sponsor) perform_enqueued_jobs do described_class.perform_later(petition) end end end context "when the petition is hidden" do
  1. Similar code found in 2 nodes Locations: 0 1
before do petition.reject(code: "offensive") end it "notifies the creator" do expect(PetitionMailer).to receive(:notify_creator_that_petition_was_rejected).with(creator).and_call_original perform_enqueued_jobs do described_class.perform_later(petition) end end it "notifies the validated sponsors" do expect(PetitionMailer).to receive(:notify_sponsor_that_petition_was_rejected).with(validated_sponsor).and_call_original perform_enqueued_jobs do described_class.perform_later(petition) end end it "doesn't notify the pending sponsors" do expect(PetitionMailer).not_to receive(:notify_sponsor_that_petition_was_rejected).with(pending_sponsor) perform_enqueued_jobs do described_class.perform_later(petition) end end end end