Keep the current filter params after deleting a saved filter so you can change your mind

This commit is contained in:
Jason Zimdars
2025-06-26 10:19:24 -05:00
parent 1382d8dcb4
commit b862d5909a
2 changed files with 7 additions and 3 deletions
+2 -1
View File
@@ -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
+5 -2
View File
@@ -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