From ad68686bece98a3bc5509bc796e8d435a5d39d1b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 11 Dec 2024 04:55:35 -0500 Subject: [PATCH] Simplify model validation specs for `CustomFilter` (#33248) --- spec/models/custom_filter_spec.rb | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/spec/models/custom_filter_spec.rb b/spec/models/custom_filter_spec.rb index 18b791a73a..517cc4f6ae 100644 --- a/spec/models/custom_filter_spec.rb +++ b/spec/models/custom_filter_spec.rb @@ -7,19 +7,8 @@ RSpec.describe CustomFilter do it { is_expected.to validate_presence_of(:title) } it { is_expected.to validate_presence_of(:context) } - it 'requires non-empty of context' do - record = described_class.new(context: []) - record.valid? - - expect(record).to model_have_error_on_field(:context) - end - - it 'requires valid context value' do - record = described_class.new(context: ['invalid']) - record.valid? - - expect(record).to model_have_error_on_field(:context) - end + it { is_expected.to_not allow_values([], %w(invalid)).for(:context) } + it { is_expected.to allow_values(%w(home)).for(:context) } end describe 'Normalizations' do