FIX: error when trying to block an IP address. Return a message when IP address matches an existing screened IP address, including ranges.

This commit is contained in:
Neil Lalonde
2018-03-19 14:34:43 -04:00
parent 6ca71e1319
commit 4d44024c82
4 changed files with 27 additions and 5 deletions

View File

@ -31,6 +31,13 @@ describe ScreenedIpAddress do
described_class.new(valid_params.merge(action_name: nil))
}.to raise_error(ArgumentError)
end
it 'returns a useful error if ip address matches an existing record' do
ScreenedIpAddress.create(ip_address: '2600:387:b:f::7a/128', action_name: :block)
r = ScreenedIpAddress.new(ip_address: '2600:387:b:f::7a', action_name: :block)
expect(r.save).to eq(false)
expect(r.errors[:ip_address]).to be_present
end
end
describe "ip_address_with_mask" do