Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/script_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def render_javascript_pack_once_tags(...)
asset_sources.get_sources(name).each do |source|
integrity = asset_sources.get_integrity(source)

if attributes[:preload_links_header] != false
if attributes.delete(:preload_links_header) != false
AssetPreloadLinker.append(
headers: response.headers,
as: :script,
Expand Down
11 changes: 11 additions & 0 deletions spec/helpers/script_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@
javascript_packs_tag_once('application', preload_links_header: false)
end

it 'prints tags with expected attributes' do
output = render_javascript_pack_once_tags

expect(output).to have_css(
"script:not([preload_links_header]):not([crossorigin])[src^='/application.js'] ~ \
script:not([preload_links_header]):not([crossorigin])[src^='/document-capture.js']",
count: 1,
visible: :all,
)
end

it 'does not append preload header' do
render_javascript_pack_once_tags

Expand Down