mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:41:25 +08:00
FEATURE: new 'maximum new user accounts per registration IP' site setting
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user