Skip to content

Commit b89b8cc

Browse files
committed
Remove unnecessary route
This was already defined by `lib/blacklight/routes/searchable.rb`
1 parent 7253213 commit b89b8cc

File tree

7 files changed

+16
-24
lines changed

7 files changed

+16
-24
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ RSpec/MessageChain:
356356
# Configuration parameters: .
357357
# SupportedStyles: have_received, receive
358358
RSpec/MessageSpies:
359-
EnforcedStyle: receive
359+
Enabled: false
360360

361361
# Offense count: 339
362362
# Configuration parameters: AggregateFailuresByDefault.

app/helpers/blacklight/url_helper_behavior.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ def session_tracking_params document, counter
8181
##
8282
# Get the URL for tracking search sessions across pages using polymorphic routing
8383
def session_tracking_path document, params = {}
84-
return if document.nil?
84+
return if document.nil? || controller_name == 'bookmarks'
8585

86-
if respond_to?(controller_tracking_method)
87-
send(controller_tracking_method, params.merge(id: document))
88-
else
89-
blacklight.track_search_context_path(params.merge(id: document))
86+
if main_app.respond_to?(controller_tracking_method)
87+
return main_app.public_send(controller_tracking_method, params.merge(id: document))
9088
end
89+
90+
raise "Unable to find #{controller_tracking_method} route helper. " \
91+
"Did you add `concerns :searchable` routing mixin to your `config/routes.rb`?"
9192
end
9293

9394
def controller_tracking_method

config/routes.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
Blacklight::Engine.routes.draw do
33
get "search_history", to: "search_history#index", as: "search_history"
44
delete "search_history/clear", to: "search_history#clear", as: "clear_search_history"
5-
post "/catalog/:id/track", to: 'catalog#track', as: 'track_search_context'
65
end

spec/helpers/blacklight/url_helper_behavior_spec.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@
201201

202202
before do
203203
allow(controller).to receive(:action_name).and_return('index')
204+
allow(helper.main_app).to receive(:track_test_path).and_return('tracking url')
205+
allow(helper.main_app).to receive(:respond_to?).with('track_test_path').and_return(true)
204206
end
205207

206208
it "consists of the document title wrapped in a <a>" do
@@ -248,9 +250,9 @@
248250
end
249251

250252
it "converts the counter parameter into a data- attribute" do
251-
allow(helper).to receive(:track_test_path).with(hash_including(id: have_attributes(id: '123456'), counter: 5)).and_return('tracking url')
252253
expect(Deprecation).to receive(:warn)
253254
expect(helper.link_to_document(document, :title_tsim, counter: 5)).to include 'data-context-href="tracking url"'
255+
expect(helper.main_app).to have_received(:track_test_path).with(hash_including(id: have_attributes(id: '123456'), counter: 5))
254256
end
255257

256258
it "includes the data- attributes from the options" do
@@ -259,16 +261,11 @@
259261
end
260262

261263
it 'adds a controller-specific tracking attribute' do
262-
expect(helper).to receive(:track_test_path).and_return('/asdf')
264+
expect(helper.main_app).to receive(:track_test_path).and_return('/asdf')
263265
link = helper.link_to_document document, data: { x: 1 }
264266

265267
expect(link).to have_selector '[data-context-href="/asdf"]'
266268
end
267-
268-
it 'adds a global tracking attribute' do
269-
link = helper.link_to_document document, data: { x: 1 }
270-
expect(link).to have_selector '[data-context-href="/catalog/123456/track"]'
271-
end
272269
end
273270

274271
describe "link_to_previous_search" do
@@ -292,12 +289,12 @@
292289
let(:document) { SolrDocument.new(id: 1) }
293290

294291
it "determines the correct route for the document class" do
295-
allow(helper).to receive(:track_test_path).with(id: have_attributes(id: 1)).and_return('x')
292+
allow(helper.main_app).to receive(:track_test_path).with(id: have_attributes(id: 1)).and_return('x')
296293
expect(helper.session_tracking_path(document)).to eq 'x'
297294
end
298295

299296
it "passes through tracking parameters" do
300-
allow(helper).to receive(:track_test_path).with(id: have_attributes(id: 1), x: 1).and_return('x')
297+
allow(helper.main_app).to receive(:track_test_path).with(id: have_attributes(id: 1), x: 1).and_return('x')
301298
expect(helper.session_tracking_path(document, x: 1)).to eq 'x'
302299
end
303300
end

spec/views/catalog/_index_header.html.erb_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
let(:blacklight_config) { Blacklight::Configuration.new }
99

1010
before do
11-
allow(controller).to receive(:action_name).and_return('index')
1211
assign :response, instance_double(Blacklight::Solr::Response, start: 0)
1312
allow(view).to receive(:render_grouped_response?).and_return false
1413
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
15-
allow(view).to receive(:current_search_session).and_return nil
16-
allow(view).to receive(:search_session).and_return({})
14+
allow(view).to receive(:session_tracking_params).and_return({})
1715
end
1816

1917
it "renders the document header" do

spec/views/catalog/_show_sidebar.erb_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
end
1111

1212
before do
13-
allow(controller).to receive(:action_name).and_return('show')
1413
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
1514
allow(view).to receive(:has_user_authentication_provider?).and_return(false)
16-
allow(view).to receive(:current_search_session).and_return nil
17-
allow(view).to receive(:search_session).and_return({})
1815
allow(view).to receive(:document_actions).and_return([])
16+
allow(view).to receive(:session_tracking_params).and_return({})
1917
end
2018

2119
it "shows more-like-this titles in the sidebar" do

spec/views/catalog/_thumbnail.html.erb_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
assign :response, instance_double(Blacklight::Solr::Response, start: 0)
2121
allow(view).to receive(:render_grouped_response?).and_return false
2222
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
23-
allow(view).to receive(:current_search_session).and_return nil
24-
allow(view).to receive(:search_session).and_return({})
23+
allow(view).to receive(:session_tracking_params).and_return({})
2524
end
2625

2726
it "renders the thumbnail if the document has one" do

0 commit comments

Comments
 (0)