2016-04-01 05:33:25 +08:00
|
|
|
require 'rails_helper'
|
2013-05-31 23:41:40 +08:00
|
|
|
|
|
|
|
describe SpamRulesEnforcer do
|
|
|
|
|
2013-07-03 02:42:30 +08:00
|
|
|
before do
|
|
|
|
SystemMessage.stubs(:create)
|
|
|
|
end
|
|
|
|
|
2013-10-26 01:25:02 +08:00
|
|
|
describe 'enforce!' do
|
|
|
|
context 'post argument' do
|
|
|
|
subject(:enforce) { described_class.enforce!(Fabricate.build(:post)) }
|
2013-05-31 23:41:40 +08:00
|
|
|
|
2013-10-26 01:25:02 +08:00
|
|
|
it 'performs the FlagSockpuppetRule' do
|
|
|
|
SpamRule::FlagSockpuppets.any_instance.expects(:perform).once
|
|
|
|
enforce
|
2013-10-12 01:33:23 +08:00
|
|
|
end
|
2013-05-31 23:41:40 +08:00
|
|
|
end
|
|
|
|
|
2013-10-26 01:25:02 +08:00
|
|
|
context 'user argument' do
|
|
|
|
subject(:enforce) { described_class.enforce!(Fabricate.build(:user)) }
|
2013-05-31 23:41:40 +08:00
|
|
|
|
2013-10-26 01:25:02 +08:00
|
|
|
it 'performs the AutoBlock' do
|
|
|
|
SpamRule::AutoBlock.any_instance.expects(:perform).once
|
|
|
|
enforce
|
2013-05-31 23:41:40 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|