Simplify basic presence validations (#29664)
This commit is contained in:
parent
bc435c63bd
commit
5acec087ca
16 changed files with 28 additions and 159 deletions
|
@ -4,19 +4,8 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe IpBlock do
|
||||
describe 'validations' do
|
||||
it 'validates ip presence', :aggregate_failures do
|
||||
ip_block = described_class.new(ip: nil, severity: :no_access)
|
||||
|
||||
expect(ip_block).to_not be_valid
|
||||
expect(ip_block).to model_have_error_on_field(:ip)
|
||||
end
|
||||
|
||||
it 'validates severity presence', :aggregate_failures do
|
||||
ip_block = described_class.new(ip: '127.0.0.1', severity: nil)
|
||||
|
||||
expect(ip_block).to_not be_valid
|
||||
expect(ip_block).to model_have_error_on_field(:severity)
|
||||
end
|
||||
it { is_expected.to validate_presence_of(:ip) }
|
||||
it { is_expected.to validate_presence_of(:severity) }
|
||||
|
||||
it 'validates ip uniqueness', :aggregate_failures do
|
||||
described_class.create!(ip: '127.0.0.1', severity: :no_access)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue