Skip to content

Commit 00efd3d

Browse files
committed
Incorporate code review feedback
1 parent 4a46861 commit 00efd3d

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

app/controllers/search_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def results
1616
# inject session preference for boolean type if it is present
1717
params[:booleanType] = cookies[:boolean_type] || 'AND'
1818

19-
# inject queryMode from cookie if not provided in URL params
19+
# inject hybrid queryMode if opted-in and no queryMode param provided
2020
params[:queryMode] = 'hybrid' if params[:queryMode].blank? && cookies[:natural_language_search_optin] == 'true'
2121

2222
@enhanced_query = Enhancer.new(params).enhanced_query

app/views/search/results.html.erb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<% elsif @results.present? && @errors.blank? %>
1919

2020
<h2 class="results-context" data-matomo-seen="Search, Results Found, Tab: {{getActiveTabName}}"><%= results_summary(@pagination[:hits]) %></h2>
21-
<p class="results-context-description"><%= tab_description %></p>
2221
<% if @show_nls_warning %>
2322
<%= render partial: 'search/nls_alert' %>
2423
<% end %>

test/controllers/natural_language_search_optin_test.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ def mock_primo_success
8585
assert_redirected_to root_path
8686
end
8787

88+
test 'external URLs redirect to route' do
89+
get '/natural_language_search_optin?natural_language_search_optin=true&return_to=https://example.com/evil'
90+
assert_response :redirect
91+
assert_redirected_to root_path
92+
end
93+
8894
test 'toggle shows toggled-off by default (no cookie)' do
8995
mock_timdex_success
9096
get '/results?q=test&tab=timdex'
@@ -240,7 +246,7 @@ def mock_primo_success
240246
assert_select 'aside.nls-alert', count: 0
241247
end
242248

243-
test 'warning does not show on articles tab when opted-out' do
249+
test 'warning does not show on cdi tab when opted-out' do
244250
get '/natural_language_search_optin?natural_language_search_optin=false'
245251

246252
mock_primo_success
@@ -250,7 +256,7 @@ def mock_primo_success
250256
assert_select 'aside.nls-alert', count: 0
251257
end
252258

253-
test 'warning does not show on articles tab with no opt-in cookie' do
259+
test 'warning does not show on cdi tab with no opt-in cookie' do
254260
mock_primo_success
255261
get '/results?q=test&tab=cdi'
256262

0 commit comments

Comments
 (0)