From 67504dbf9c51f458a912d98106ef7b5ae79d63fc Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 24 Oct 2024 08:43:40 -0400 Subject: [PATCH] Simplify uniqueness validation spec for `IpBlock` (#32066) --- spec/models/ip_block_spec.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/spec/models/ip_block_spec.rb b/spec/models/ip_block_spec.rb index ac9f5db60..b85856780 100644 --- a/spec/models/ip_block_spec.rb +++ b/spec/models/ip_block_spec.rb @@ -3,18 +3,13 @@ require 'rails_helper' RSpec.describe IpBlock do - describe 'validations' do + describe 'Validations' do + subject { Fabricate.build :ip_block } + 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) - - ip_block = described_class.new(ip: '127.0.0.1', severity: :no_access) - - expect(ip_block).to_not be_valid - expect(ip_block).to model_have_error_on_field(:ip) - end + it { is_expected.to validate_uniqueness_of(:ip) } end describe '#to_log_human_identifier' do