From 1775e151ecc93ee21c993303a6b51f89f24fd2d1 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 25 Oct 2024 04:42:14 -0400 Subject: [PATCH] Simplify model validation specs for `DomainAllow` (#32496) --- spec/models/domain_allow_spec.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/models/domain_allow_spec.rb b/spec/models/domain_allow_spec.rb index d8f438f07..fbb324657 100644 --- a/spec/models/domain_allow_spec.rb +++ b/spec/models/domain_allow_spec.rb @@ -6,11 +6,10 @@ RSpec.describe DomainAllow do describe 'Validations' do it { is_expected.to validate_presence_of(:domain) } - it 'is invalid if the same normalized domain already exists' do - _domain_allow = Fabricate(:domain_allow, domain: 'にゃん') - domain_allow_with_normalized_value = Fabricate.build(:domain_allow, domain: 'xn--r9j5b5b') - domain_allow_with_normalized_value.valid? - expect(domain_allow_with_normalized_value).to model_have_error_on_field(:domain) + context 'when a normalized domain exists' do + before { Fabricate(:domain_allow, domain: 'にゃん') } + + it { is_expected.to_not allow_value('xn--r9j5b5b').for(:domain) } end end end