From deb124524418c3eff5a9bb834bbe9164b515fe10 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sun, 22 Sep 2024 14:42:36 -0400 Subject: [PATCH] Add failure path cases --- spec/system/filters_spec.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/spec/system/filters_spec.rb b/spec/system/filters_spec.rb index 0cafcd96a0..e681c6940e 100644 --- a/spec/system/filters_spec.rb +++ b/spec/system/filters_spec.rb @@ -28,12 +28,22 @@ RSpec.describe 'Filters' do fill_in_filter_form expect(page).to have_content(filter_title) end + + it 'Does not save with invalid values' do + navigate_to_filters + click_on I18n.t('filters.new.title') + + expect { click_on I18n.t('filters.new.save') } + .to_not change(CustomFilter, :count) + expect(page) + .to have_content("can't be blank") + end end describe 'Editing an existing filter' do let(:new_title) { 'Change title value' } - before { Fabricate :custom_filter, account: user.account, title: filter_title } + let!(:custom_filter) { Fabricate :custom_filter, account: user.account, title: filter_title } it 'Updates the saved filter' do navigate_to_filters @@ -45,6 +55,18 @@ RSpec.describe 'Filters' do expect(page).to have_content(new_title) end + + it 'Does not save with invalid values' do + navigate_to_filters + click_on filter_title + + fill_in filter_title_field, with: '' + + expect { click_on submit_button } + .to_not(change { custom_filter.reload.updated_at }) + expect(page) + .to have_content("can't be blank") + end end describe 'Destroying an existing filter' do