diff --git a/README.md b/README.md index 21b9312..5a1c2cf 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ import 'controllers' ### Browser History Actions +* `turbo_stream.history_back(**attributes)` * `turbo_stream.history_go(delta, **attributes)` * `turbo_stream.push_state(url, title = nil, state = nil, **attributes)` * `turbo_stream.replace_state(url, title = nil, state = nil, **attributes)` diff --git a/lib/turbo_power/stream_helper.rb b/lib/turbo_power/stream_helper.rb index 91b1c6d..c458a05 100644 --- a/lib/turbo_power/stream_helper.rb +++ b/lib/turbo_power/stream_helper.rb @@ -167,6 +167,10 @@ def set_title(title, **attributes) # Browser History Actions + def history_back(**attributes) + custom_action :history_back, attributes: attributes + end + def history_go(delta, **attributes) custom_action :history_go, attributes: attributes.merge(delta: delta) end diff --git a/test/turbo_power/stream_helper/history_back_test.rb b/test/turbo_power/stream_helper/history_back_test.rb new file mode 100644 index 0000000..6e362eb --- /dev/null +++ b/test/turbo_power/stream_helper/history_back_test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "test_helper" + +module TurboPower + module StreamHelper + class HistoryBackTest < StreamHelperTestCase + test "history_back" do + stream = %() + + assert_dom_equal stream, turbo_stream.history_back + end + end + end +end