Skip to content

Commit

Permalink
Disable Turbo's prefetch, which became the default in turbo-rails 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Oct 6, 2024
1 parent 586db0c commit 1575489
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/views/layouts/rails_admin/_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width, initial-scale=1" name="viewport; charset=utf-8">
<meta content="NONE,NOARCHIVE" name="robots">
<meta content="false" name="turbo-prefetch">
<%= csrf_meta_tag %>
<% case RailsAdmin::config.asset_source
when :webpacker %>
Expand Down
7 changes: 7 additions & 0 deletions spec/integration/rails_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@
is_expected.to have_content 'Player failed to be updated'
is_expected.to have_css '.filtering-select[data-input-for="player_team_id"]'
end

it 'does not prefetch pages' do
allow_any_instance_of(RailsAdmin::Config::Actions::Index).to receive(:controller).and_raise('index prefetched')
visit dashboard_path
find('.sidebar a.nav-link[href$="/player"]').hover
sleep 0.3 # Turbo waits 100ms before prefetch
end
end

describe 'dom_ready events', js: true do
Expand Down

0 comments on commit 1575489

Please sign in to comment.