From f26b571a428ee6615f04bc26d7870029aa7a6f2a Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Mon, 16 Oct 2023 08:03:37 -0500 Subject: [PATCH] Support for multiple string arguments to frame helper This fixes a regression in 1.5.0 Fixes #503 --- app/helpers/turbo/frames_helper.rb | 2 +- test/frames/frames_helper_test.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/turbo/frames_helper.rb b/app/helpers/turbo/frames_helper.rb index bda33c3f..ea64d06e 100644 --- a/app/helpers/turbo/frames_helper.rb +++ b/app/helpers/turbo/frames_helper.rb @@ -36,7 +36,7 @@ module Turbo::FramesHelper # <%= turbo_frame_tag(Article.find(1), Comment.new) %> # # => def turbo_frame_tag(*ids, src: nil, target: nil, **attributes, &block) - id = ids.first.respond_to?(:to_key) ? ActionView::RecordIdentifier.dom_id(*ids) : ids.first + id = ids.first.respond_to?(:to_key) ? ActionView::RecordIdentifier.dom_id(*ids) : ids.join('_') src = url_for(src) if src.present? tag.turbo_frame(**attributes.merge(id: id, src: src, target: target).compact, &block) diff --git a/test/frames/frames_helper_test.rb b/test/frames/frames_helper_test.rb index f284bc01..ef062ec1 100644 --- a/test/frames/frames_helper_test.rb +++ b/test/frames/frames_helper_test.rb @@ -21,12 +21,16 @@ class Turbo::FramesHelperTest < ActionView::TestCase assert_dom_equal %(), turbo_frame_tag(record) end - test "string frame nested withing a model frame" do + test "string frame with a model frame" do record = Article.new(id: 1) assert_dom_equal %(), turbo_frame_tag(record, "comments") end + test "string frame with non-record array" do + assert_dom_equal %(), turbo_frame_tag(['foo', 1, 2]) + end + test "block style" do assert_dom_equal(%(

tray!

), turbo_frame_tag("tray") { tag.p("tray!") }) end