blacklight 5.5.1 → 5.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +8 -16
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +5 -1
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/blacklight.gemspec +2 -1
- data/gemfiles/rails3.gemfile +1 -1
- data/gemfiles/rails4.1.gemfile +1 -1
- data/gemfiles/rails4.gemfile +1 -1
- data/lib/blacklight/catalog.rb +0 -1
- data/lib/blacklight/solr/facet_paginator.rb +22 -10
- data/lib/generators/blacklight/install_generator.rb +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +6 -6
- data/spec/controllers/catalog_controller_spec.rb +48 -48
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/record_view_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +4 -4
- data/spec/features/search_results_spec.rb +12 -12
- data/spec/helpers/blacklight_helper_spec.rb +83 -83
- data/spec/helpers/catalog_helper_spec.rb +37 -37
- data/spec/helpers/configuration_helper_spec.rb +39 -39
- data/spec/helpers/facets_helper_spec.rb +37 -37
- data/spec/helpers/render_constraints_helper_spec.rb +6 -1
- data/spec/helpers/search_history_constraints_helper_spec.rb +9 -9
- data/spec/helpers/url_helper_spec.rb +49 -39
- data/spec/lib/blacklight/configurable_spec.rb +5 -5
- data/spec/lib/blacklight/configuration_spec.rb +8 -8
- data/spec/lib/blacklight/facet_paginator_spec.rb +25 -0
- data/spec/lib/blacklight/routes_spec.rb +4 -4
- data/spec/lib/blacklight/search_fields_spec.rb +3 -3
- data/spec/lib/blacklight/solr/document_spec.rb +2 -2
- data/spec/lib/blacklight/solr_helper_spec.rb +37 -37
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +1 -1
- data/spec/lib/blacklight/solr_response_spec.rb +31 -31
- data/spec/lib/document_presenter_spec.rb +41 -41
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/models/record_mailer_spec.rb +1 -1
- data/spec/models/search_spec.rb +1 -1
- data/spec/routing/catalog_routing_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/support/include_text.rb +2 -3
- data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_facets.html.erb_spec.rb +6 -6
- data/spec/views/catalog/_index_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_show_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +5 -5
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +4 -4
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +5 -2
- data/spec/views/catalog/facet.html.erb_spec.rb +5 -5
- data/spec/views/catalog/index.atom.builder_spec.rb +2 -2
- data/spec/views/catalog/index.html.erb_spec.rb +5 -5
- data/spec/views/catalog/show.html.erb_spec.rb +8 -8
- data/tasks/blacklight.rake +1 -2
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6f521c7766d2dd6e7b718a222296f2d0dad680a
|
4
|
+
data.tar.gz: 324a81ef36346eca1526cbe54ccbfc604703a7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d826574a0c0c6562857e3e846f323bd9e9bcc27d29b4f7efdb394c8c7a9c8372a43be6ea7972cdce406fc57d3f373616be37c54f1aa35edcbaad45c5703e690
|
7
|
+
data.tar.gz: 5aa333a5d25378061b79c61d0c94e07a912b197a6234e6ef9153749b7b8a04ff8eb65fd21d9e68b928ffb510885bcdcebad0bcbc157fb4605e7e5cf0209f2669
|
data/Gemfile
CHANGED
@@ -9,7 +9,7 @@ gemspec path: File.expand_path('..', __FILE__)
|
|
9
9
|
gem 'simplecov', '~> 0.7.1', require: false
|
10
10
|
gem 'coveralls', require: false
|
11
11
|
|
12
|
-
gem 'engine_cart', '~> 0.
|
12
|
+
gem 'engine_cart', '~> 0.4'
|
13
13
|
|
14
14
|
group :test do
|
15
15
|
gem "blacklight-marc", "~> 5.0", github: "projectblacklight/blacklight_marc"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.5.
|
1
|
+
5.5.2
|
@@ -410,13 +410,10 @@ module Blacklight::BlacklightHelperBehavior
|
|
410
410
|
# @return [String]
|
411
411
|
def render_document_index_with_view view, documents, locals = {}
|
412
412
|
document_index_path_templates.each do |str|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
rescue ActionView::MissingTemplate
|
418
|
-
nil
|
419
|
-
end
|
413
|
+
partial = str % { index_view_type: view }
|
414
|
+
logger.debug "Looking for document index partial #{partial}"
|
415
|
+
template = lookup_context.find_all(partial, lookup_context.prefixes, true, locals.keys + [:documents], {}).first
|
416
|
+
return template.render(self, locals.merge(documents: documents)) if template
|
420
417
|
end
|
421
418
|
|
422
419
|
return ""
|
@@ -502,15 +499,10 @@ module Blacklight::BlacklightHelperBehavior
|
|
502
499
|
end
|
503
500
|
|
504
501
|
document_partial_path_templates.each do |str|
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
logger.debug "Looking for document partial #{partial}"
|
510
|
-
return render partial: partial, locals: locals.merge(document: doc)
|
511
|
-
rescue ActionView::MissingTemplate
|
512
|
-
nil
|
513
|
-
end
|
502
|
+
partial = str % { action_name: base_name, format: format, index_view_type: document_index_view_type }
|
503
|
+
logger.debug "Looking for document partial #{partial}"
|
504
|
+
template = lookup_context.find_all(partial, lookup_context.prefixes, true, locals.keys + [:document], {}).first
|
505
|
+
return template.render(self, locals.merge(document: doc)) if template
|
514
506
|
end
|
515
507
|
|
516
508
|
return ''
|
@@ -131,7 +131,7 @@ module Blacklight::CatalogHelperBehavior
|
|
131
131
|
# @param [SolrDocument]
|
132
132
|
# @return [Boolean]
|
133
133
|
def has_thumbnail? document
|
134
|
-
blacklight_config.view_config(document_index_view_type).thumbnail_method or
|
134
|
+
blacklight_config.view_config(document_index_view_type).thumbnail_method.present? or
|
135
135
|
blacklight_config.view_config(document_index_view_type).thumbnail_field && document.has?(blacklight_config.view_config(document_index_view_type).thumbnail_field)
|
136
136
|
end
|
137
137
|
|
@@ -33,12 +33,13 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
33
33
|
# @return [String]
|
34
34
|
def render_constraints_query(localized_params = params)
|
35
35
|
# So simple don't need a view template, we can just do it here.
|
36
|
+
scope = localized_params.delete(:route_set) || self
|
36
37
|
return "".html_safe if localized_params[:q].blank?
|
37
38
|
|
38
39
|
render_constraint_element(constraint_query_label(localized_params),
|
39
40
|
localized_params[:q],
|
40
41
|
:classes => ["query"],
|
41
|
-
:remove => url_for(localized_params.merge(:q=>nil, :action=>'index')))
|
42
|
+
:remove => scope.url_for(localized_params.merge(:q=>nil, :action=>'index')))
|
42
43
|
end
|
43
44
|
|
44
45
|
##
|
@@ -115,7 +115,11 @@ module Blacklight::UrlHelperBehavior
|
|
115
115
|
query_params[:page] = ((counter - 1)/ per_page) + 1
|
116
116
|
end
|
117
117
|
|
118
|
-
link_url =
|
118
|
+
link_url = if query_params.empty?
|
119
|
+
search_action_path(only_path: true)
|
120
|
+
else
|
121
|
+
scope.url_for(query_params)
|
122
|
+
end
|
119
123
|
label = opts.delete(:label)
|
120
124
|
|
121
125
|
if link_url =~ /bookmarks/
|
data/blacklight.gemspec
CHANGED
@@ -26,8 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_development_dependency "jettywrapper", ">= 1.7.0"
|
28
28
|
s.add_development_dependency "blacklight-marc", "~> 5.0"
|
29
|
-
s.add_development_dependency "rspec-rails", "~>
|
29
|
+
s.add_development_dependency "rspec-rails", "~> 3.0"
|
30
30
|
s.add_development_dependency "rspec-its"
|
31
|
+
s.add_development_dependency "rspec-collection_matchers", ">= 1.0"
|
31
32
|
s.add_development_dependency "capybara"
|
32
33
|
s.add_development_dependency "poltergeist"
|
33
34
|
s.add_development_dependency 'engine_cart', ">= 0.1.0"
|
data/gemfiles/rails3.gemfile
CHANGED
data/gemfiles/rails4.1.gemfile
CHANGED
data/gemfiles/rails4.gemfile
CHANGED
data/lib/blacklight/catalog.rb
CHANGED
@@ -25,7 +25,7 @@ module Blacklight::Solr
|
|
25
25
|
class << self; attr_accessor :request_keys end # create a class method
|
26
26
|
def request_keys ; self.class.request_keys ; end # shortcut
|
27
27
|
|
28
|
-
attr_reader :
|
28
|
+
attr_reader :offset, :limit, :sort
|
29
29
|
|
30
30
|
# all_facet_values is a list of facet value objects returned by solr,
|
31
31
|
# asking solr for n+1 facet values.
|
@@ -40,8 +40,17 @@ module Blacklight::Solr
|
|
40
40
|
@limit = arguments[:limit].to_s.to_i
|
41
41
|
# count is solr's default
|
42
42
|
@sort = arguments[:sort] || "count"
|
43
|
-
|
44
|
-
@
|
43
|
+
|
44
|
+
@all = all_facet_values
|
45
|
+
end
|
46
|
+
|
47
|
+
# The number of records solr gave us when we asked for limit + 1 records at the current offset
|
48
|
+
def total_count
|
49
|
+
@all.size
|
50
|
+
end
|
51
|
+
|
52
|
+
def items
|
53
|
+
items_for_limit(@all)
|
45
54
|
end
|
46
55
|
|
47
56
|
def prev_page
|
@@ -73,20 +82,19 @@ module Blacklight::Solr
|
|
73
82
|
deprecation_deprecate :has_next?
|
74
83
|
|
75
84
|
def last_page?
|
76
|
-
|
85
|
+
total_count <= limit
|
77
86
|
end
|
78
87
|
|
79
88
|
def first_page?
|
80
89
|
current_page == 1
|
81
90
|
end
|
82
91
|
|
92
|
+
# We're implementing total_pages so that this matches the API from kaminari, even though we can't
|
93
|
+
# know the total number of pages.
|
94
|
+
# https://github.com/amatsuda/kaminari/blob/v0.16.1/lib/kaminari/models/page_scope_methods.rb#L21
|
83
95
|
def total_pages
|
84
|
-
|
85
|
-
|
86
|
-
else
|
87
|
-
(total_count.to_f / limit).ceil
|
88
|
-
end
|
89
|
-
end
|
96
|
+
-1
|
97
|
+
end
|
90
98
|
|
91
99
|
# Pass in a desired solr facet solr key ('count' or 'index', see
|
92
100
|
# http://wiki.apache.org/solr/SimpleFacetParameters#facet.limit
|
@@ -99,6 +107,10 @@ module Blacklight::Solr
|
|
99
107
|
params.merge(request_keys[:sort] => sort_method, request_keys[:page] => nil)
|
100
108
|
end
|
101
109
|
|
110
|
+
def as_json(_ = nil)
|
111
|
+
{ 'items' => items.as_json, 'limit' => limit, 'offset' => offset, 'sort' => sort }
|
112
|
+
end
|
113
|
+
|
102
114
|
private
|
103
115
|
# setting limit to 0 implies no limit
|
104
116
|
# @return an array of facets on the page
|
@@ -27,7 +27,7 @@ module Blacklight
|
|
27
27
|
copy_file "config/jetty.yml"
|
28
28
|
|
29
29
|
append_to_file "Rakefile",
|
30
|
-
"\nZIP_URL = \"https://github.com/projectblacklight/blacklight-jetty/archive/v4.
|
30
|
+
"\nZIP_URL = \"https://github.com/projectblacklight/blacklight-jetty/archive/v4.9.0.zip\"\n" +
|
31
31
|
"require 'jettywrapper'\n"
|
32
32
|
end
|
33
33
|
|
@@ -10,10 +10,10 @@ describe BookmarksController do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "has a 500 status code when fails is success" do
|
13
|
-
@controller.
|
14
|
-
@controller.
|
15
|
-
@controller.
|
16
|
-
@controller.
|
13
|
+
allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false)
|
14
|
+
allow(@controller).to receive_message_chain(:current_or_guest_user, :persisted?).and_return(true)
|
15
|
+
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :where, :exists?).and_return(false)
|
16
|
+
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :create).and_return(false)
|
17
17
|
xhr :put, :update, :id => 'iamabooboo', :format => :js
|
18
18
|
expect(response.code).to eq "500"
|
19
19
|
end
|
@@ -33,8 +33,8 @@ describe BookmarksController do
|
|
33
33
|
|
34
34
|
it "has a 500 status code when delete is not success" do
|
35
35
|
bm = double(Bookmark)
|
36
|
-
@controller.
|
37
|
-
@controller.
|
36
|
+
allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(bm)
|
37
|
+
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :where, :first).and_return(double('bookmark', delete: nil, destroyed?: false))
|
38
38
|
|
39
39
|
xhr :delete, :destroy, :id => 'pleasekillme', :format => :js
|
40
40
|
|
@@ -22,7 +22,7 @@ describe CatalogController do
|
|
22
22
|
let(:user_query) { 'history' } # query that will get results
|
23
23
|
|
24
24
|
it "should have no search history if no search criteria" do
|
25
|
-
controller.
|
25
|
+
allow(controller).to receive(:get_search_results)
|
26
26
|
session[:history] = []
|
27
27
|
get :index
|
28
28
|
expect(session[:history]).to be_empty
|
@@ -70,7 +70,7 @@ describe CatalogController do
|
|
70
70
|
|
71
71
|
describe "session" do
|
72
72
|
before do
|
73
|
-
controller.
|
73
|
+
allow(controller).to receive(:get_search_results)
|
74
74
|
end
|
75
75
|
it "should include search hash with key :q" do
|
76
76
|
get :index, q: user_query
|
@@ -95,7 +95,7 @@ describe CatalogController do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should render index.html.erb" do
|
98
|
-
controller.
|
98
|
+
allow(controller).to receive(:get_search_results)
|
99
99
|
get :index
|
100
100
|
expect(response).to render_template(:index)
|
101
101
|
end
|
@@ -156,8 +156,8 @@ describe CatalogController do
|
|
156
156
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
157
157
|
|
158
158
|
before :each do
|
159
|
-
@controller.
|
160
|
-
@controller.
|
159
|
+
allow(@controller).to receive_messages blacklight_config: blacklight_config
|
160
|
+
allow(@controller).to receive_messages get_search_results: [double, double]
|
161
161
|
end
|
162
162
|
|
163
163
|
it "should not render when the config is false" do
|
@@ -185,7 +185,7 @@ describe CatalogController do
|
|
185
185
|
end
|
186
186
|
|
187
187
|
it "with a symbol, it should call a controller method" do
|
188
|
-
subject.
|
188
|
+
expect(subject).to receive(:render_some_yaml) do
|
189
189
|
subject.render nothing: true, layout: false
|
190
190
|
end
|
191
191
|
|
@@ -256,12 +256,12 @@ describe CatalogController do
|
|
256
256
|
before do
|
257
257
|
@mock_response = double()
|
258
258
|
@mock_document = double()
|
259
|
-
@mock_document.
|
260
|
-
controller.
|
259
|
+
allow(@mock_document).to receive_messages(:export_formats => {})
|
260
|
+
allow(controller).to receive_messages(:get_solr_response_for_doc_id => [@mock_response, @mock_document],
|
261
261
|
:get_previous_and_next_documents_for_search => [double(:total => 5), [double("a"), @mock_document, double("b")]])
|
262
262
|
|
263
263
|
current_search = Search.create(:query_params => { :q => ""})
|
264
|
-
controller.
|
264
|
+
allow(controller).to receive_messages(:current_search_session => current_search)
|
265
265
|
|
266
266
|
@search_session = { :id => current_search.id }
|
267
267
|
end
|
@@ -296,18 +296,18 @@ describe CatalogController do
|
|
296
296
|
it "should render show.html.erb" do
|
297
297
|
@mock_response = double()
|
298
298
|
@mock_document = double()
|
299
|
-
@mock_document.
|
300
|
-
controller.
|
299
|
+
allow(@mock_document).to receive_messages(:export_formats => {})
|
300
|
+
allow(controller).to receive_messages(:get_solr_response_for_doc_id => [@mock_response, @mock_document])
|
301
301
|
get :show, :id => doc_id
|
302
|
-
response.
|
302
|
+
expect(response).to render_template(:show)
|
303
303
|
end
|
304
304
|
|
305
305
|
describe "@document" do
|
306
306
|
before do
|
307
307
|
@mock_response = double()
|
308
|
-
@mock_response.
|
308
|
+
allow(@mock_response).to receive_messages(documents: [SolrDocument.new(id: 'my_fake_doc')])
|
309
309
|
@mock_document = double()
|
310
|
-
controller.
|
310
|
+
allow(controller).to receive_messages(:find => @mock_response )
|
311
311
|
end
|
312
312
|
before(:each) do
|
313
313
|
get :show, :id => doc_id
|
@@ -332,9 +332,9 @@ describe CatalogController do
|
|
332
332
|
|
333
333
|
before do
|
334
334
|
@mock_response = double()
|
335
|
-
@mock_response.
|
335
|
+
allow(@mock_response).to receive_messages(:docs => [{ :id => 'my_fake_doc' }])
|
336
336
|
@mock_document = double()
|
337
|
-
controller.
|
337
|
+
allow(controller).to receive_messages(find: @mock_response)
|
338
338
|
end
|
339
339
|
|
340
340
|
before(:each) do
|
@@ -351,12 +351,12 @@ describe CatalogController do
|
|
351
351
|
|
352
352
|
before do
|
353
353
|
@mock_response = double()
|
354
|
-
@mock_response.
|
354
|
+
allow(@mock_response).to receive_messages(:documents => [SolrDocument.new(id: 'my_fake_doc')])
|
355
355
|
@mock_document = double()
|
356
|
-
controller.
|
356
|
+
allow(controller).to receive_messages(:find => @mock_response,
|
357
357
|
:get_single_doc_via_search => @mock_document)
|
358
358
|
|
359
|
-
controller.
|
359
|
+
allow(controller).to receive_messages(:find => @mock_response,
|
360
360
|
:get_single_doc_via_search => @mock_document)
|
361
361
|
end
|
362
362
|
|
@@ -379,9 +379,9 @@ describe CatalogController do
|
|
379
379
|
before do
|
380
380
|
@mock_response = double()
|
381
381
|
@mock_document = double()
|
382
|
-
@mock_response.
|
382
|
+
allow(@mock_response).to receive_messages(documents: [SolrDocument.new(id: 'my_fake_doc'), SolrDocument.new(id: 'my_other_doc')])
|
383
383
|
@mock_document = double()
|
384
|
-
controller.
|
384
|
+
allow(controller).to receive_messages(find: @mock_response)
|
385
385
|
|
386
386
|
end
|
387
387
|
it "should return an opensearch description" do
|
@@ -398,7 +398,7 @@ describe CatalogController do
|
|
398
398
|
doc_id = '2007020969'
|
399
399
|
let(:mock_response) { double(documents: [SolrDocument.new(id: 'my_fake_doc'), SolrDocument.new(id: 'my_other_doc')]) }
|
400
400
|
before do
|
401
|
-
controller.
|
401
|
+
allow(controller).to receive_messages(find: mock_response)
|
402
402
|
request.env["HTTP_REFERER"] = "/catalog/#{doc_id}"
|
403
403
|
SolrDocument.use_extension( Blacklight::Solr::Document::Email )
|
404
404
|
SolrDocument.use_extension( Blacklight::Solr::Document::Sms )
|
@@ -418,8 +418,8 @@ describe CatalogController do
|
|
418
418
|
end
|
419
419
|
it "should redirect back to the record upon success" do
|
420
420
|
mock_mailer = double
|
421
|
-
mock_mailer.
|
422
|
-
RecordMailer.
|
421
|
+
allow(mock_mailer).to receive(:deliver)
|
422
|
+
allow(RecordMailer).to receive(:email_record).with(anything, { :to => 'test_email@projectblacklight.org', :message => 'xyz' }, hash_including(:host => 'test.host')).and_return mock_mailer
|
423
423
|
|
424
424
|
post :email, :id => doc_id, :to => 'test_email@projectblacklight.org', :message => 'xyz'
|
425
425
|
expect(request.flash[:error]).to be_nil
|
@@ -456,8 +456,8 @@ describe CatalogController do
|
|
456
456
|
end
|
457
457
|
it "should redirect back to the record upon success" do
|
458
458
|
post :sms, :id => doc_id, :to => '5555555555', :carrier => 'txt.att.net'
|
459
|
-
request.flash[:error].
|
460
|
-
request.
|
459
|
+
expect(request.flash[:error]).to eq nil
|
460
|
+
expect(request).to redirect_to(catalog_path(doc_id))
|
461
461
|
end
|
462
462
|
|
463
463
|
it "should render sms_sent template for XHR requests" do
|
@@ -471,14 +471,14 @@ describe CatalogController do
|
|
471
471
|
describe "errors" do
|
472
472
|
it "should return status 404 for a record that doesn't exist" do
|
473
473
|
@mock_response = double(documents: [])
|
474
|
-
controller.
|
474
|
+
allow(controller).to receive_messages(:find => @mock_response)
|
475
475
|
get :show, :id=>"987654321"
|
476
476
|
expect(response.status).to eq 404
|
477
477
|
expect(response.content_type).to eq Mime::HTML
|
478
478
|
end
|
479
479
|
it "should return status 404 for a record that doesn't exist even for non-html format" do
|
480
480
|
@mock_response = double(documents: [])
|
481
|
-
controller.
|
481
|
+
allow(controller).to receive_messages(:find => @mock_response)
|
482
482
|
|
483
483
|
get :show, :id=>"987654321", :format => "xml"
|
484
484
|
expect(response.status).to eq 404
|
@@ -489,9 +489,9 @@ describe CatalogController do
|
|
489
489
|
req = {}
|
490
490
|
res = {}
|
491
491
|
fake_error = RSolr::Error::Http.new(req, res)
|
492
|
-
Rails.env.
|
493
|
-
controller.
|
494
|
-
controller.logger.
|
492
|
+
allow(Rails.env).to receive_messages(:test? => false)
|
493
|
+
allow(controller).to receive(:get_search_results) { |*args| raise fake_error }
|
494
|
+
expect(controller.logger).to receive(:error).with(fake_error)
|
495
495
|
get :index, :q=>"+"
|
496
496
|
|
497
497
|
expect(response.redirect_url).to eq root_url
|
@@ -504,9 +504,9 @@ describe CatalogController do
|
|
504
504
|
req = {}
|
505
505
|
res = {}
|
506
506
|
fake_error = RSolr::Error::Http.new(req, res)
|
507
|
-
controller.
|
508
|
-
controller.flash.
|
509
|
-
controller.
|
507
|
+
allow(controller).to receive(:get_search_results) { |*args| raise fake_error }
|
508
|
+
allow(controller.flash).to receive(:sweep)
|
509
|
+
allow(controller).to receive(:flash).and_return(:notice => I18n.t('blacklight.search.errors.request_error'))
|
510
510
|
expect {
|
511
511
|
get :index, :q=>"+"
|
512
512
|
}.to raise_error
|
@@ -518,7 +518,7 @@ describe CatalogController do
|
|
518
518
|
render_views
|
519
519
|
|
520
520
|
before do
|
521
|
-
controller.
|
521
|
+
allow(controller).to receive(:has_user_authentication_provider?) { false }
|
522
522
|
end
|
523
523
|
|
524
524
|
it "should not show user util links" do
|
@@ -557,8 +557,8 @@ describe CatalogController do
|
|
557
557
|
describe 'render_search_results_as_json' do
|
558
558
|
before do
|
559
559
|
controller.instance_variable_set :@document_list, [{id: '123', title_t: 'Book1'}, {id: '456', title_t: 'Book2'}]
|
560
|
-
controller.
|
561
|
-
controller.
|
560
|
+
allow(controller).to receive(:pagination_info).and_return({current_page: 1, next_page: 2, prev_page: nil})
|
561
|
+
allow(controller).to receive(:search_facets_as_json).and_return(
|
562
562
|
[{name: "format", label: "Format", items: [{value: 'Book', hits: 30, label: 'Book'}]}])
|
563
563
|
end
|
564
564
|
|
@@ -595,7 +595,7 @@ describe CatalogController do
|
|
595
595
|
end
|
596
596
|
|
597
597
|
it "should remove searches from the list when the list gets too big" do
|
598
|
-
controller.
|
598
|
+
allow(controller).to receive(:blacklight_config).and_return(double(:search_history_window => 5))
|
599
599
|
session[:history] = (0..4).to_a.reverse
|
600
600
|
|
601
601
|
expect(session[:history]).to have(5).items
|
@@ -609,15 +609,15 @@ describe CatalogController do
|
|
609
609
|
|
610
610
|
describe "current_search_session" do
|
611
611
|
it "should create a session if we're on an search action" do
|
612
|
-
controller.
|
613
|
-
controller.
|
612
|
+
allow(controller).to receive_messages(:action_name => "index")
|
613
|
+
allow(controller).to receive_messages(:params => { :q => "x", :page => 5})
|
614
614
|
session = controller.send(:current_search_session)
|
615
615
|
expect(session.query_params).to include(:q => "x")
|
616
616
|
expect(session.query_params).to_not include(:page => 5)
|
617
617
|
end
|
618
618
|
|
619
619
|
it "should create a session if a search context was provided" do
|
620
|
-
controller.
|
620
|
+
allow(controller).to receive_messages(:params => { :search_context => JSON.dump(:q => "x")})
|
621
621
|
session = controller.send(:current_search_session)
|
622
622
|
expect(session.query_params).to include("q" => "x")
|
623
623
|
end
|
@@ -626,7 +626,7 @@ describe CatalogController do
|
|
626
626
|
s = Search.create(:query_params => { :q => "x" })
|
627
627
|
session[:history] ||= []
|
628
628
|
session[:history] << s.id
|
629
|
-
controller.
|
629
|
+
allow(controller).to receive_messages(:params => { :search_id => s.id})
|
630
630
|
session = controller.send(:current_search_session)
|
631
631
|
expect(session.query_params).to include(:q => "x")
|
632
632
|
expect(session).to eq(s)
|
@@ -647,16 +647,16 @@ describe CatalogController do
|
|
647
647
|
describe "#has_search_parameters?" do
|
648
648
|
subject { controller.has_search_parameters? }
|
649
649
|
describe "none" do
|
650
|
-
before { controller.
|
651
|
-
it { should
|
650
|
+
before { allow(controller).to receive_messages(params: { }) }
|
651
|
+
it { should be false }
|
652
652
|
end
|
653
653
|
describe "with a query" do
|
654
|
-
before { controller.
|
655
|
-
it { should
|
654
|
+
before { allow(controller).to receive_messages(params: { q: 'hello' }) }
|
655
|
+
it { should be true }
|
656
656
|
end
|
657
657
|
describe "with a facet" do
|
658
|
-
before { controller.
|
659
|
-
it { should
|
658
|
+
before { allow(controller).to receive_messages(params: { f: { "field" => ["value"]} }) }
|
659
|
+
it { should be true }
|
660
660
|
end
|
661
661
|
end
|
662
662
|
|