Add spec for CanonicalEmailBlock.matching_email scope (#35692)

This commit is contained in:
Matt Jankowski 2025-08-06 08:19:43 -04:00 committed by GitHub
parent 55a98580aa
commit 6e48322055
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,36 @@
require 'rails_helper'
RSpec.describe CanonicalEmailBlock do
describe 'Associations' do
it { is_expected.to belong_to(:reference_account).class_name('Account').optional }
end
describe 'Scopes' do
describe '.matching_email' do
subject { described_class.matching_email(email) }
let!(:block) { Fabricate :canonical_email_block, email: 'test@example.com' }
context 'when email is exact match' do
let(:email) { 'test@example.com' }
it { is_expected.to contain_exactly(block) }
end
context 'when email does not match' do
let(:email) { 'test@example.ORG' }
it { is_expected.to be_empty }
end
context 'when email is different but normalizes to same hash' do
let(:email) { 'te.st+more@EXAMPLE.com' }
it { is_expected.to contain_exactly(block) }
end
end
end
describe '#email=' do
let(:target_hash) { '973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b' }