From b862d5909ac3badcc5d49ca2a79d1d38e0ebe5fb Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 26 Jun 2025 10:19:24 -0500 Subject: [PATCH] Keep the current filter params after deleting a saved filter so you can change your mind --- app/controllers/filters_controller.rb | 3 ++- test/controllers/filters_controller_test.rb | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/filters_controller.rb b/app/controllers/filters_controller.rb index e6255f19f..1d0ff6b47 100644 --- a/app/controllers/filters_controller.rb +++ b/app/controllers/filters_controller.rb @@ -7,12 +7,13 @@ class FiltersController < ApplicationController end def destroy + filter_params = @filter.as_params @filter.destroy! if request.referer == root_url redirect_to root_path else - redirect_to cards_path + redirect_to cards_path(filter_params) end end diff --git a/test/controllers/filters_controller_test.rb b/test/controllers/filters_controller_test.rb index cf3670800..7285c89ac 100644 --- a/test/controllers/filters_controller_test.rb +++ b/test/controllers/filters_controller_test.rb @@ -25,9 +25,12 @@ class FiltersControllerTest < ActionDispatch::IntegrationTest end test "destroy" do + filter = filters(:jz_assignments) + expected_params = filter.as_params + assert_difference "users(:david).filters.count", -1 do - delete filter_path(filters(:jz_assignments)) + delete filter_path(filter) end - assert_redirected_to cards_path + assert_redirected_to cards_path(expected_params) end end