From b16435e79f2b695a58effcadc5077ceedd559507 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 24 Oct 2024 08:44:13 -0400 Subject: [PATCH] Explore more resplendent model validation specs for `Form::AdminSettings` (#32465) --- spec/models/form/admin_settings_spec.rb | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/spec/models/form/admin_settings_spec.rb b/spec/models/form/admin_settings_spec.rb index 6080b9e08..73106f2b6 100644 --- a/spec/models/form/admin_settings_spec.rb +++ b/spec/models/form/admin_settings_spec.rb @@ -3,33 +3,17 @@ require 'rails_helper' RSpec.describe Form::AdminSettings do - describe 'validations' do + describe 'Validations' do describe 'site_contact_username' do context 'with no accounts' do - it 'is not valid' do - setting = described_class.new(site_contact_username: 'Test') - setting.valid? - - expect(setting).to model_have_error_on_field(:site_contact_username) - end + it { is_expected.to_not allow_value('Test').for(:site_contact_username) } end context 'with an account' do before { Fabricate(:account, username: 'Glorp') } - it 'is not valid when account doesnt match' do - setting = described_class.new(site_contact_username: 'Test') - setting.valid? - - expect(setting).to model_have_error_on_field(:site_contact_username) - end - - it 'is valid when account matches' do - setting = described_class.new(site_contact_username: 'Glorp') - setting.valid? - - expect(setting).to_not model_have_error_on_field(:site_contact_username) - end + it { is_expected.to_not allow_value('Test').for(:site_contact_username) } + it { is_expected.to allow_value('Glorp').for(:site_contact_username) } end end end