Updated

spec/jobs / backfill_canonical_emails_job_spec.rb

D
47 lines of codes
0 methods
N/A complexity/method
1 churn
79.74 complexity
93 duplications
require 'rails_helper' RSpec.describe BackfillCanonicalEmailsJob, type: :job do before do allow(Site).to receive(:disable_plus_address_check?).and_return(true) end context "when the canonical_email column is nil" do
  1. Similar code found in 2 nodes Locations: 0 1
let(:signature) { FactoryBot.create(:signature, email: "alice+foo@example.com") } let(:canonical_email) { "alice@example.com" } before do signature.update_column(:canonical_email, nil) signature.reload expect_any_instance_of(Signature).to receive(:update_canonical_email).and_call_original end it "updates the canonical_email column" do expect { described_class.perform_now }.to change { signature.reload.canonical_email }.from(nil).to(canonical_email) end end context "when the canonical_email column is not nil" do
  1. Similar code found in 2 nodes Locations: 0 1
let(:signature) { FactoryBot.create(:signature, email: "bob+foo@example.com") } let(:canonical_email) { "bob@example.com" } before do signature.update_column(:uuid, canonical_email) signature.reload expect_any_instance_of(Signature).not_to receive(:update_canonical_email) end it "skips updating the canonical_email column" do expect { described_class.perform_now }.not_to change { signature.reload.canonical_email } end end end