Skip to content

Commit

Permalink
Remove unnecessary route
Browse files Browse the repository at this point in the history
This was already defined by `lib/blacklight/routes/searchable.rb`
  • Loading branch information
jcoyne committed Nov 20, 2018
1 parent 7253213 commit a1b174b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 23 deletions.
10 changes: 5 additions & 5 deletions app/helpers/blacklight/url_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def session_tracking_params document, counter
##
# Get the URL for tracking search sessions across pages using polymorphic routing
def session_tracking_path document, params = {}
return if document.nil?

if respond_to?(controller_tracking_method)
send(controller_tracking_method, params.merge(id: document))
return if document.nil? || controller_name == 'bookmarks'
if main_app.respond_to?(controller_tracking_method)
main_app.public_send(controller_tracking_method, params.merge(id: document))
else
blacklight.track_search_context_path(params.merge(id: document))
raise "Unable to find #{controller_tracking_method} route helper. " \
"Did you add `concerns :searchable` routing mixin to your `config/routes.rb`?"
end
end

Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
Blacklight::Engine.routes.draw do
get "search_history", to: "search_history#index", as: "search_history"
delete "search_history/clear", to: "search_history#clear", as: "clear_search_history"
post "/catalog/:id/track", to: 'catalog#track', as: 'track_search_context'
end
15 changes: 6 additions & 9 deletions spec/helpers/blacklight/url_helper_behavior_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@

before do
allow(controller).to receive(:action_name).and_return('index')
allow(helper.main_app).to receive(:track_test_path).and_return('tracking url')
allow(helper.main_app).to receive(:respond_to?).with('track_test_path').and_return(true)
end

it "consists of the document title wrapped in a <a>" do
Expand Down Expand Up @@ -248,9 +250,9 @@
end

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

it "includes the data- attributes from the options" do
Expand All @@ -259,16 +261,11 @@
end

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

expect(link).to have_selector '[data-context-href="/asdf"]'
end

it 'adds a global tracking attribute' do
link = helper.link_to_document document, data: { x: 1 }
expect(link).to have_selector '[data-context-href="/catalog/123456/track"]'
end
end

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

it "determines the correct route for the document class" do
allow(helper).to receive(:track_test_path).with(id: have_attributes(id: 1)).and_return('x')
allow(helper.main_app).to receive(:track_test_path).with(id: have_attributes(id: 1)).and_return('x')
expect(helper.session_tracking_path(document)).to eq 'x'
end

it "passes through tracking parameters" do
allow(helper).to receive(:track_test_path).with(id: have_attributes(id: 1), x: 1).and_return('x')
allow(helper.main_app).to receive(:track_test_path).with(id: have_attributes(id: 1), x: 1).and_return('x')
expect(helper.session_tracking_path(document, x: 1)).to eq 'x'
end
end
Expand Down
4 changes: 1 addition & 3 deletions spec/views/catalog/_index_header.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
let(:blacklight_config) { Blacklight::Configuration.new }

before do
allow(controller).to receive(:action_name).and_return('index')
assign :response, instance_double(Blacklight::Solr::Response, start: 0)
allow(view).to receive(:render_grouped_response?).and_return false
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
allow(view).to receive(:current_search_session).and_return nil
allow(view).to receive(:search_session).and_return({})
allow(view).to receive(:session_tracking_params).and_return({})
end

it "renders the document header" do
Expand Down
4 changes: 1 addition & 3 deletions spec/views/catalog/_show_sidebar.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
end

before do
allow(controller).to receive(:action_name).and_return('show')
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
allow(view).to receive(:has_user_authentication_provider?).and_return(false)
allow(view).to receive(:current_search_session).and_return nil
allow(view).to receive(:search_session).and_return({})
allow(view).to receive(:document_actions).and_return([])
allow(view).to receive(:session_tracking_params).and_return({})
end

it "shows more-like-this titles in the sidebar" do
Expand Down
3 changes: 1 addition & 2 deletions spec/views/catalog/_thumbnail.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
assign :response, instance_double(Blacklight::Solr::Response, start: 0)
allow(view).to receive(:render_grouped_response?).and_return false
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
allow(view).to receive(:current_search_session).and_return nil
allow(view).to receive(:search_session).and_return({})
allow(view).to receive(:session_tracking_params).and_return({})
end

it "renders the thumbnail if the document has one" do
Expand Down

0 comments on commit a1b174b

Please sign in to comment.