spec/presenters/document_presenter_spec.rb in blacklight-6.0.0.pre5 vs spec/presenters/document_presenter_spec.rb in blacklight-6.0.0
- old
+ new
@@ -1,25 +1,29 @@
+# frozen_string_literal: true
require 'spec_helper'
describe Blacklight::DocumentPresenter do
include Capybara::RSpecMatchers
let(:request_context) { double }
let(:config) { Blacklight::Configuration.new }
subject { presenter }
let(:presenter) { Blacklight::DocumentPresenter.new(document, request_context, config) }
+ let(:parameter_class) { ActionController::Parameters }
+ let(:params) { parameter_class.new }
+ let(:search_state) { Blacklight::SearchState.new(params, config) }
let(:document) do
SolrDocument.new(id: 1,
'link_to_search_true' => 'x',
'link_to_search_named' => 'x',
'qwer' => 'document qwer value',
'mnbv' => 'document mnbv value')
end
before do
- allow(request_context).to receive(:search_state).and_return(Blacklight::SearchState.new({}, config))
+ allow(request_context).to receive(:search_state).and_return(search_state)
end
describe "link_rel_alternates" do
before do
class MockDocument
@@ -118,17 +122,17 @@
value = subject.render_index_field_value 'asdf'
expect(value).to eq 'custom asdf value'
end
it "should check for a link_to_search" do
- allow(request_context).to receive(:search_action_path).with(:f => { :link_to_search_true => ['x'] }).and_return('/foo')
+ 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(:search_action_path).with(:f => { :some_field => ['x'] }).and_return('/foo')
+ 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'
expect(value).to eq 'bar'
end