Screened ip address can be edited, deleted, and changed to allow or block.

This commit is contained in:
Neil Lalonde
2013-10-22 16:30:30 -04:00
parent b8d586251c
commit 7d582fbee3
16 changed files with 259 additions and 16 deletions

View File

@ -30,4 +30,5 @@ describe AllowedIpAddressValidator do
record.errors[:ip_address].should_not be_present
end
end
end

View File

@ -0,0 +1,22 @@
require 'spec_helper'
describe IpAddressFormatValidator do
let(:record) { Fabricate.build(:screened_ip_address, 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) }
[nil, '99.232.23.123', '99.232.0.0/16', 'fd12:db8::ff00:42:8329', 'fc00::/7'].each do |arg|
it "should not add an error for #{arg}" do
record.ip_address = arg
validate
record.errors[:ip_address].should_not be_present
end
end
it 'should add an error for invalid IP address' do
record.ip_address = '99.99.99'
validate
record.errors[:ip_address].should be_present
end
end