From e5be4bf8d887bffd6f660ec86b13515a593f21d4 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 25 Oct 2024 03:55:33 -0400 Subject: [PATCH] Simplify model validation specs for `PreviewCard` (#32469) --- spec/models/preview_card_spec.rb | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/spec/models/preview_card_spec.rb b/spec/models/preview_card_spec.rb index c0bc2b6e0e..0fe76c37b0 100644 --- a/spec/models/preview_card_spec.rb +++ b/spec/models/preview_card_spec.rb @@ -9,26 +9,10 @@ RSpec.describe PreviewCard do end end - describe 'validations' do - describe 'urls' do - it 'allows http schemes' do - record = described_class.new(url: 'http://example.host/path') - - expect(record).to be_valid - end - - it 'allows https schemes' do - record = described_class.new(url: 'https://example.host/path') - - expect(record).to be_valid - end - - it 'does not allow javascript: schemes' do - record = described_class.new(url: 'javascript:alert()') - - expect(record).to_not be_valid - expect(record).to model_have_error_on_field(:url) - end + describe 'Validations' do + describe 'url' do + it { is_expected.to allow_values('http://example.host/path', 'https://example.host/path').for(:url) } + it { is_expected.to_not allow_value('javascript:alert()').for(:url) } end end end