FEATURE: new 'maximum new user accounts per registration IP' site setting

This commit is contained in:
Régis Hanol
2014-11-17 12:04:29 +01:00
parent 78f6cea16c
commit 7641d88224
9 changed files with 67 additions and 18 deletions

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe AllowedIpAddressValidator do
let(:record) { Fabricate.build(:user, ip_address: '99.232.23.123') }
let(:record) { Fabricate.build(:user, trust_level: TrustLevel[0], ip_address: '99.232.23.123') }
let(:validator) { described_class.new({attributes: :ip_address}) }
subject(:validate) { validator.validate_each(record, :ip_address, record.ip_address) }
@ -14,6 +14,14 @@ describe AllowedIpAddressValidator do
end
end
context "ip address isn't allowed for registration" do
it 'should add an error' do
SpamHandler.stubs(:should_prevent_registration_from_ip?).returns(true)
validate
record.errors[:ip_address].should be_present
end
end
context "ip address should not be blocked" do
it "shouldn't add an error" do
ScreenedIpAddress.stubs(:should_block?).returns(false)
@ -31,4 +39,4 @@ describe AllowedIpAddressValidator do
end
end
end
end