Skip to content

Commit

Permalink
Update document_presenter_spec to use Blacklight::SearchState instead…
Browse files Browse the repository at this point in the history
… of stubbing url helpers
  • Loading branch information
cbeer committed Nov 7, 2015
1 parent b81e56a commit 07b28b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spec/presenters/document_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe Blacklight::DocumentPresenter do
include Capybara::RSpecMatchers
let(:request_context) { double(:add_facet_params => '') }
let(:request_context) { double }
let(:config) { Blacklight::Configuration.new }

subject { presenter }
Expand All @@ -16,6 +16,10 @@
'mnbv' => 'document mnbv value')
end

before do
allow(request_context).to receive(:search_state).and_return(Blacklight::SearchState.new({}, config))
end

describe "link_rel_alternates" do
before do
class MockDocument
Expand Down Expand Up @@ -116,15 +120,13 @@ def mock_document_app_helper_url *args
end

it "should check for a link_to_search" do
allow(request_context).to receive(:add_facet_params).and_return(:f => { :link_to_search_true => ['x'] })
allow(request_context).to receive(:search_action_path).with(:f => { :link_to_search_true => ['x'] }).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
value = subject.render_index_field_value 'link_to_search_true'
expect(value).to eq 'bar'
end

it "should check for a link_to_search with a field name" do
allow(request_context).to receive(:add_facet_params).and_return(:f => { :some_field => ['x'] })
allow(request_context).to receive(:search_action_path).with(:f => { :some_field => ['x'] }).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
value = subject.render_index_field_value 'link_to_search_named'
Expand Down Expand Up @@ -211,14 +213,14 @@ def mock_document_app_helper_url *args
end

it "should check for a link_to_search" do
allow(request_context).to receive(:search_action_path).with('').and_return('/foo')
allow(request_context).to receive(:search_action_path).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
value = subject.render_document_show_field_value 'link_to_search_true'
expect(value).to eq 'bar'
end

it "should check for a link_to_search with a field name" do
allow(request_context).to receive(:search_action_path).with('').and_return('/foo')
allow(request_context).to receive(:search_action_path).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
value = subject.render_document_show_field_value 'link_to_search_named'
expect(value).to eq 'bar'
Expand Down

0 comments on commit 07b28b9

Please sign in to comment.