Updated

spec/jobs / deliver_debate_outcome_email_job_spec.rb

F
48 lines of codes
0 methods
N/A complexity/method
6 churn
98.35 complexity
133 duplications
require 'rails_helper' require_relative 'shared_examples' RSpec.describe DeliverDebateOutcomeEmailJob, type: :job do
  1. Similar code found in 3 nodes Locations: 0 1 2
let(:requested_at) { Time.current.change(usec: 0) } let(:requested_at_as_string) { requested_at.getutc.iso8601(6) } let(:petition) { FactoryBot.create(:debated_petition) } let(:signature) { FactoryBot.create(:validated_signature, petition: petition) } let(:timestamp_name) { 'debate_outcome' } let :arguments do { signature: signature, timestamp_name: timestamp_name, petition: petition, requested_at: requested_at_as_string } end before do petition.set_email_requested_at_for(timestamp_name, to: requested_at) end it_behaves_like "a job to send an signatory email" context "when the signature is the creator" do before do allow(signature).to receive(:creator?).and_return(true) end it "uses the correct mailer method to generate the email" do
  1. context(when the signature is the creator)::it#uses the correct mailer method to generate the email has a flog score of 25
expect(subject).to receive_message_chain(:mailer, :notify_creator_of_debate_outcome).with(petition, signature).and_return double.as_null_object subject.perform(**arguments) end end context "when the signature is not the creator" do before do allow(signature).to receive(:creator?).and_return(false) end it "uses the correct mailer method to generate the email" do
  1. context(when the signature is not the creator)::it#uses the correct mailer method to generate the email has a flog score of 25
expect(subject).to receive_message_chain(:mailer, :notify_signer_of_debate_outcome).with(petition, signature).and_return double.as_null_object subject.perform(**arguments) end end end