Skip to content

Commit b7cea37

Browse files
committed
Fix to avoid prefetches that break tests.
1 parent a044ada commit b7cea37

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

app/components/search/item_result_component.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<% component.with_caption do %>
66
<%= render Search::ResultHeadingComponent.new(index:) do |component| %>
77
<%= component.with_link do %>
8-
<%= helpers.link_to(title, object_path(druid:), data: { turbo_frame: '_top' }) %>
8+
<%# Pre-fetch here breaks tests because can be triggered unintentionally. %>
9+
<%= helpers.link_to(title, object_path(druid:), data: { turbo_frame: '_top', turbo_prefetch: !Rails.env.test? }) %>
910
<% end %>
1011
<% end %>
1112
<% end %>

app/components/search/item_result_component.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ def content_type_values
2424
end
2525

2626
def admin_policy_values
27+
# Pre-fetch here breaks tests because can be triggered unintentionally.
2728
[helpers.link_to(result.apo_title, object_path(druid: result.apo_druid),
28-
data: { turbo_frame: '_top' })]
29+
data: { turbo_frame: '_top', turbo_prefetch: !Rails.env.test? })]
2930
end
3031

3132
def collections_values
@@ -65,7 +66,7 @@ def access_rights_values
6566
def collection_links
6667
result.collection_druids.map.with_index do |collection_druid, index|
6768
helpers.link_to(result.collection_titles[index], object_path(druid: collection_druid),
68-
data: { turbo_frame: '_top' })
69+
data: { turbo_frame: '_top', turbo_prefetch: false })
6970
end
7071
end
7172

spec/spec_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
SKIPPABLE_TEST_COVERAGE_CONCERNS = %w[assets javascript views].freeze
2121

2222
SimpleCov.start(:rails) do
23-
add_filter '/lib/tasks/'
23+
skip '/lib/tasks/'
2424

2525
# Use SimpleCov groups to break down test coverage per application concern, e.g.,
2626
# controllers, models, & jobs. See https://github.com/simplecov-ruby/simplecov#groups
2727
Dir.glob('app/*').each do |concern_path|
2828
concern = File.basename(concern_path)
2929
next if SKIPPABLE_TEST_COVERAGE_CONCERNS.include?(concern)
3030

31-
add_group concern.capitalize, concern_path
31+
group concern.capitalize, concern_path
3232
end
3333

3434
if ENV['CI']

0 commit comments

Comments
 (0)