From 32f6b516cb19bccfe6534a32fef25faa0b1d85d6 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 17 Aug 2024 15:11:59 -0400 Subject: [PATCH] Fix `data` attribute in layout generator template --- lib/generators/phlex/install/templates/application_layout.rb | 2 +- test/dummy/app/views/layouts/application_layout.rb | 2 +- test/phlex/layout_test.rb | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/generators/phlex/install/templates/application_layout.rb b/lib/generators/phlex/install/templates/application_layout.rb index 14d451cb..457547e2 100644 --- a/lib/generators/phlex/install/templates/application_layout.rb +++ b/lib/generators/phlex/install/templates/application_layout.rb @@ -12,7 +12,7 @@ def view_template(&block) meta name: "viewport", content: "width=device-width,initial-scale=1" csp_meta_tag csrf_meta_tags - stylesheet_link_tag "application", data_turbo_track: "reload" + stylesheet_link_tag "application", data: { turbo_track: "reload" } javascript_importmap_tags end diff --git a/test/dummy/app/views/layouts/application_layout.rb b/test/dummy/app/views/layouts/application_layout.rb index 52fac842..49f39742 100644 --- a/test/dummy/app/views/layouts/application_layout.rb +++ b/test/dummy/app/views/layouts/application_layout.rb @@ -16,7 +16,7 @@ def view_template(&block) meta name: "viewport", content: "width=device-width,initial-scale=1" csp_meta_tag csrf_meta_tags - stylesheet_link_tag "application", data_turbo_track: "reload" + stylesheet_link_tag "application", data: { turbo_track: "reload" } end body(class: tokens(-> { @color == :blue } => { then: "bg-blue", else: "bg-black" })) do diff --git a/test/phlex/layout_test.rb b/test/phlex/layout_test.rb index 1c701c71..3eedfe2b 100644 --- a/test/phlex/layout_test.rb +++ b/test/phlex/layout_test.rb @@ -7,6 +7,7 @@ class LayoutTest < ActionDispatch::IntegrationTest get "/layout/with_erb_view" assert_response :success assert_select "body.bg-blue" + assert_select "link[rel=stylesheet][data-turbo-track=reload]" assert_select "title", "ERB View" assert_select "h1", "Hello from ERB" end @@ -14,6 +15,7 @@ class LayoutTest < ActionDispatch::IntegrationTest test "with phlex view" do get "/layout/with_phlex_view" assert_response :success + assert_select "link[rel=stylesheet][data-turbo-track=reload]" assert_select "title", "Phlex View" assert_select "h1", "Hello from Phlex" end