File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ def create
44 cloned_puzzle = original_puzzle . clone_puzzle
55
66 if cloned_puzzle . persisted?
7- redirect_to puzzles_path , notice : "Puzzle cloned. You can now edit the new puzzle."
7+ redirect_back fallback_location : puzzles_path , notice : "Puzzle cloned. You can now edit the new puzzle."
88 else
9- redirect_to puzzles_path , alert : "Failed to clone puzzle."
9+ redirect_back fallback_location : puzzles_path , alert : "Failed to clone puzzle."
1010 end
1111 end
1212end
Original file line number Diff line number Diff line change @@ -22,6 +22,16 @@ class Puzzles::ClonesControllerTest < ActionDispatch::IntegrationTest
2222 assert_equal "pending" , cloned . state
2323 end
2424
25+ test "redirects back to referer to preserve filters" do
26+ original = puzzles ( :one )
27+ referer = puzzles_path ( hide_cloned_puzzles : true , low_success_rate : true )
28+
29+ sign_in
30+ post puzzle_clone_path ( original ) , headers : { "HTTP_REFERER" => referer }
31+
32+ assert_redirected_to referer
33+ end
34+
2535 test "does not allow unauthenticated users to create a clone" do
2636 original = puzzles ( :one )
2737
You can’t perform that action at this time.
0 commit comments