Skip to content

Commit

Permalink
Fix issue with saving empty fields values on filter keyword updates (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored Jan 23, 2025
1 parent 4a9c49e commit 8eee7ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/filters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def set_filter
end

def resource_params
params.expect(custom_filter: [:title, :expires_in, :filter_action, context: [], keywords_attributes: [:id, :keyword, :whole_word, :_destroy]])
params.expect(custom_filter: [:title, :expires_in, :filter_action, context: [], keywords_attributes: [[:id, :keyword, :whole_word, :_destroy]]])
end

def set_cache_headers
Expand Down
9 changes: 8 additions & 1 deletion spec/system/filters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@
let(:new_title) { 'Change title value' }

let!(:custom_filter) { Fabricate :custom_filter, account: user.account, title: filter_title }
let!(:keyword_one) { Fabricate :custom_filter_keyword, custom_filter: custom_filter }
let!(:keyword_two) { Fabricate :custom_filter_keyword, custom_filter: custom_filter }

it 'Updates the saved filter' do
navigate_to_filters

click_on filter_title

fill_in filter_title_field, with: new_title
click_on submit_button
fill_in 'custom_filter_keywords_attributes_0_keyword', with: 'New value'
fill_in 'custom_filter_keywords_attributes_1_keyword', with: 'Wilderness'

expect { click_on submit_button }
.to change { keyword_one.reload.keyword }.to(/New value/)
.and(change { keyword_two.reload.keyword }.to(/Wilderness/))

expect(page).to have_content(new_title)
end
Expand Down

0 comments on commit 8eee7ae

Please sign in to comment.