Skip to content

Commit 05914c4

Browse files
committed
Make url argument for redirect_to action optional
1 parent 0fc10be commit 05914c4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/turbo_power/stream_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def notification(title = nil, **attributes)
197197

198198
# Turbo Actions
199199

200-
def redirect_to(url, turbo_action = "advance", **attributes)
200+
def redirect_to(url = nil, turbo_action = "advance", **attributes)
201201
custom_action :redirect_to, attributes: { url: url, turbo_action: turbo_action }.merge(attributes)
202202
end
203203

test/turbo_power/stream_helper/redirect_to_test.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ class RedirectToTest < StreamHelperTestCase
2323
assert_dom_equal stream, turbo_stream.redirect_to("http://localhost:8080", "replace")
2424
end
2525

26-
test "redirect_to with turbo_action=replace" do
26+
test "redirect_to with turbo_action=replace kwarg" do
2727
stream = %(<turbo-stream turbo-action="replace" url="http://localhost:8080" action="redirect_to"><template></template></turbo-stream>)
2828

2929
assert_dom_equal stream, turbo_stream.redirect_to("http://localhost:8080", turbo_action: "replace")
3030
end
31+
32+
test "redirect_to all kwargs" do
33+
stream = %(<turbo-stream turbo-action="replace" turbo="true" url="http://localhost:8080" action="redirect_to"><template></template></turbo-stream>)
34+
35+
assert_dom_equal stream, turbo_stream.redirect_to(url: "http://localhost:8080", turbo_action: "replace", turbo: true)
36+
end
3137
end
3238
end
3339
end

0 commit comments

Comments
 (0)