-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Turbo Drive
<meta>
across navigations
Closes [#549] Add System Test level coverage to ensure that Turbo Drive navigations will re-render any `<meta>` elements nested within the document's `<head>`. To achieve this coverage, introduce the `PagesController#show` action that links to HTML pages that render their `<head>` based on the `turbo_refresh_method` and `turbo_refresh_scroll` query parameters. [#549]: #549
- Loading branch information
1 parent
41e8561
commit 9da91e9
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class PagesController < ApplicationController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%= turbo_refreshes_with method: params.fetch(:turbo_refresh_method, :replace).to_sym, scroll: params.fetch(:turbo_refresh_scroll, :reset).to_sym %> | ||
|
||
<h1><%= params[:id].titleize %></h1> | ||
|
||
<% { | ||
classic: { | ||
turbo_refresh_method: :replace, | ||
turbo_refresh_scroll: :reset, | ||
}, | ||
morph: { | ||
turbo_refresh_method: :morph, | ||
turbo_refresh_scroll: :preserve, | ||
} | ||
}.each do |id, refresh| %> | ||
<%= link_to_unless_current id.to_s.titleize, page_path(id, refresh) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "application_system_test_case" | ||
|
||
class NavigationsTest < ApplicationSystemTestCase | ||
test "navigation updates Turbo Refresh meta tags" do | ||
visit page_path(:classic) | ||
|
||
within "head", visible: false do | ||
assert_selector :element, "meta", name: "turbo-refresh-method", content: "replace", visible: false, count: 1 | ||
assert_selector :element, "meta", name: "turbo-refresh-scroll", content: "reset", visible: false, count: 1 | ||
end | ||
|
||
click_link "Morph" | ||
|
||
within "head", visible: false do | ||
assert_selector :element, "meta", name: "turbo-refresh-method", content: "morph", visible: false, count: 1 | ||
assert_selector :element, "meta", name: "turbo-refresh-scroll", content: "preserve", visible: false, count: 1 | ||
end | ||
|
||
click_link "Classic" | ||
|
||
within "head", visible: false do | ||
assert_selector :element, "meta", name: "turbo-refresh-method", content: "replace", visible: false, count: 1 | ||
assert_selector :element, "meta", name: "turbo-refresh-scroll", content: "reset", visible: false, count: 1 | ||
end | ||
end | ||
end |