mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
Add a way to add email to block list when nuking a user
This commit is contained in:
@ -6,18 +6,48 @@ describe BlockedEmail do
|
||||
|
||||
describe "new record" do
|
||||
it "sets a default action_type" do
|
||||
BlockedEmail.create(email: email).action_type.should == BlockedEmail.actions[:block]
|
||||
described_class.create(email: email).action_type.should == described_class.actions[:block]
|
||||
end
|
||||
|
||||
it "last_match_at is null" do
|
||||
# If we manually load the table with some emails, we can see whether those emails
|
||||
# have ever been blocked by looking at last_match_at.
|
||||
BlockedEmail.create(email: email).last_match_at.should be_nil
|
||||
described_class.create(email: email).last_match_at.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#should_block?" do
|
||||
subject { BlockedEmail.should_block?(email) }
|
||||
describe '#block' do
|
||||
context 'email is not being blocked' do
|
||||
it 'creates a new record with default action of :block' do
|
||||
record = described_class.block(email)
|
||||
record.should_not be_new_record
|
||||
record.email.should == email
|
||||
record.action_type.should == described_class.actions[:block]
|
||||
end
|
||||
|
||||
it 'lets action_type be overriden' do
|
||||
record = described_class.block(email, action_type: described_class.actions[:do_nothing])
|
||||
record.should_not be_new_record
|
||||
record.email.should == email
|
||||
record.action_type.should == described_class.actions[:do_nothing]
|
||||
end
|
||||
end
|
||||
|
||||
context 'email is already being blocked' do
|
||||
let!(:existing) { Fabricate(:blocked_email, email: email) }
|
||||
|
||||
it "doesn't create a new record" do
|
||||
expect { described_class.block(email) }.to_not change { described_class.count }
|
||||
end
|
||||
|
||||
it "returns the existing record" do
|
||||
described_class.block(email).should == existing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#should_block?' do
|
||||
subject { described_class.should_block?(email) }
|
||||
|
||||
it "returns false if a record with the email doesn't exist" do
|
||||
subject.should be_false
|
||||
|
Reference in New Issue
Block a user