mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 09:51:24 +00:00
Add spec for CanonicalEmailBlock.matching_email
scope (#35692)
This commit is contained in:
parent
55a98580aa
commit
6e48322055
|
@ -3,6 +3,36 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe CanonicalEmailBlock do
|
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
|
describe '#email=' do
|
||||||
let(:target_hash) { '973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b' }
|
let(:target_hash) { '973dfe463ec85785f5f95af5ba3906eedb2d931c24e69824a89ea65dba4e813b' }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user