blacklight 6.5.0 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +114 -213
- data/{.solr_wrapper → .solr_wrapper.yml} +0 -0
- data/.yardopts +3 -1
- data/Gemfile +0 -3
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/Vagrantfile +0 -2
- data/app/controllers/bookmarks_controller.rb +0 -2
- data/app/controllers/catalog_controller.rb +0 -2
- data/app/controllers/concerns/blacklight/base.rb +0 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +7 -11
- data/app/controllers/concerns/blacklight/controller.rb +11 -7
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +24 -37
- data/app/controllers/concerns/blacklight/facet.rb +2 -11
- data/app/controllers/concerns/blacklight/request_builders.rb +1 -3
- data/app/controllers/concerns/blacklight/search_context.rb +0 -1
- data/app/controllers/concerns/blacklight/search_fields.rb +2 -2
- data/app/controllers/concerns/blacklight/search_helper.rb +14 -24
- data/app/controllers/concerns/blacklight/token_based_user.rb +0 -2
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +27 -28
- data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -15
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -5
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -3
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +21 -25
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -2
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +8 -9
- data/app/helpers/blacklight/render_partials_helper.rb +14 -13
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -4
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/blacklight/facet_paginator.rb +2 -2
- data/app/models/concerns/blacklight/document.rb +1 -6
- data/app/models/concerns/blacklight/document/active_model_shim.rb +0 -1
- data/app/models/concerns/blacklight/document/cache_key.rb +3 -3
- data/app/models/concerns/blacklight/document/dublin_core.rb +0 -1
- data/app/models/concerns/blacklight/document/email.rb +0 -2
- data/app/models/concerns/blacklight/document/export.rb +1 -2
- data/app/models/concerns/blacklight/document/schema_org.rb +0 -2
- data/app/models/concerns/blacklight/document/sms.rb +0 -2
- data/app/models/concerns/blacklight/solr/document.rb +0 -1
- data/app/models/record_mailer.rb +0 -1
- data/app/models/solr_document.rb +0 -2
- data/app/presenters/blacklight/document_presenter.rb +14 -11
- data/app/presenters/blacklight/index_presenter.rb +5 -5
- data/app/presenters/blacklight/json_presenter.rb +0 -1
- data/app/presenters/blacklight/rendering/abstract_step.rb +0 -1
- data/app/presenters/blacklight/rendering/helper_method.rb +5 -5
- data/app/presenters/blacklight/rendering/link_to_facet.rb +1 -1
- data/app/presenters/blacklight/show_presenter.rb +4 -5
- data/app/services/blacklight/field_retriever.rb +8 -9
- data/app/views/catalog/_facet_limit.html.erb +1 -1
- data/blacklight.gemspec +4 -0
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/abstract_repository.rb +4 -3
- data/lib/blacklight/configuration.rb +57 -92
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/fields.rb +24 -7
- data/lib/blacklight/exceptions.rb +0 -2
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/search_builder.rb +92 -96
- data/lib/blacklight/search_state.rb +2 -1
- data/lib/blacklight/solr/repository.rb +3 -4
- data/lib/blacklight/solr/request.rb +0 -2
- data/lib/blacklight/solr/response/facets.rb +23 -28
- data/lib/blacklight/solr/response/group.rb +0 -1
- data/lib/blacklight/solr/response/group_response.rb +1 -5
- data/lib/blacklight/solr/response/pagination_methods.rb +0 -1
- data/lib/blacklight/solr/response/response.rb +1 -1
- data/lib/blacklight/solr/response/spelling.rb +0 -4
- data/lib/blacklight/solr/search_builder_behavior.rb +29 -41
- data/lib/blacklight/utils.rb +10 -7
- data/lib/generators/blacklight/assets_generator.rb +0 -1
- data/lib/generators/blacklight/document_generator.rb +0 -1
- data/lib/generators/blacklight/install_generator.rb +2 -6
- data/lib/generators/blacklight/models_generator.rb +0 -3
- data/lib/generators/blacklight/search_builder_generator.rb +0 -1
- data/lib/generators/blacklight/solr4_generator.rb +0 -2
- data/lib/generators/blacklight/solr5_generator.rb +15 -1
- data/lib/generators/blacklight/test_support_generator.rb +0 -1
- data/lib/railties/blacklight.rake +3 -3
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -4
- data/spec/controllers/blacklight/search_helper_spec.rb +5 -7
- data/spec/controllers/blacklight/suggest_search_spec.rb +2 -2
- data/spec/controllers/bookmarks_controller_spec.rb +2 -2
- data/spec/controllers/catalog_controller_spec.rb +6 -6
- data/spec/features/search_context_spec.rb +4 -5
- data/spec/features/search_formats_spec.rb +0 -6
- data/spec/helpers/blacklight_helper_spec.rb +7 -7
- data/spec/helpers/catalog_helper_spec.rb +10 -10
- data/spec/helpers/configuration_helper_spec.rb +3 -3
- data/spec/helpers/facets_helper_spec.rb +1 -2
- data/spec/helpers/render_constraints_helper_spec.rb +8 -0
- data/spec/integration/generators/blacklight/solr5_generator_spec.rb +60 -0
- data/spec/models/blacklight/document_spec.rb +1 -1
- data/spec/models/blacklight/search_builder_spec.rb +5 -4
- data/spec/models/blacklight/solr/search_builder_spec.rb +12 -18
- data/spec/presenters/pipeline_spec.rb +1 -1
- data/spec/spec_helper.rb +43 -0
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -1
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
- data/tasks/blacklight.rake +3 -0
- metadata +61 -3
@@ -29,10 +29,9 @@ module Blacklight
|
|
29
29
|
|
30
30
|
def add_solr_wrapper
|
31
31
|
generator_options = '--jettywrapper' if options[:jettywrapper]
|
32
|
-
solr_generator =
|
33
|
-
when options[:jettywrapper]
|
32
|
+
solr_generator = if options[:jettywrapper]
|
34
33
|
'blacklight:solr4'
|
35
|
-
|
34
|
+
elsif solr_version == 'latest'
|
36
35
|
'blacklight:solr5'
|
37
36
|
else
|
38
37
|
"blacklight:solr#{solr_version}"
|
@@ -66,7 +65,6 @@ module Blacklight
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def generate_blacklight_user
|
69
|
-
|
70
68
|
generator_args = [model_name]
|
71
69
|
if options[:devise]
|
72
70
|
generator_args << "--devise #{options[:devise]}"
|
@@ -84,9 +82,7 @@ module Blacklight
|
|
84
82
|
end
|
85
83
|
|
86
84
|
def add_sass_configuration
|
87
|
-
|
88
85
|
insert_into_file "config/application.rb", :after => "config.assets.enabled = true" do <<EOF
|
89
|
-
|
90
86
|
# Default SASS Configuration, check out https://github.com/rails/sass-rails for details
|
91
87
|
config.assets.compress = !Rails.env.development?
|
92
88
|
EOF
|
@@ -19,7 +19,6 @@ module Blacklight
|
|
19
19
|
copy_file "config/blacklight.yml", "config/blacklight.yml"
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
22
|
# Setup the database migrations
|
24
23
|
def copy_migrations
|
25
24
|
rake "blacklight:install:migrations"
|
@@ -43,7 +42,5 @@ module Blacklight
|
|
43
42
|
end
|
44
43
|
EOF
|
45
44
|
end
|
46
|
-
|
47
|
-
|
48
45
|
end
|
49
46
|
end
|
@@ -3,7 +3,6 @@ require 'rails/generators'
|
|
3
3
|
|
4
4
|
module Blacklight
|
5
5
|
class Solr4Generator < Rails::Generators::Base
|
6
|
-
|
7
6
|
source_root File.expand_path('../templates', __FILE__)
|
8
7
|
|
9
8
|
class_option :jettywrapper, type: :boolean, default: false, desc: "Use jettywrapper to download and control Jetty"
|
@@ -28,6 +27,5 @@ module Blacklight
|
|
28
27
|
def add_rsolr_gem
|
29
28
|
gem "rsolr".dup, "~> 1.0"
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
33
31
|
end
|
@@ -2,10 +2,16 @@ require 'rails/generators'
|
|
2
2
|
|
3
3
|
module Blacklight
|
4
4
|
class Solr5Generator < Rails::Generators::Base
|
5
|
+
# Set source_root to grab .solr_wrapper and solr config dir
|
6
|
+
# from the root of the blacklight gem
|
7
|
+
source_root Blacklight.root
|
8
|
+
|
5
9
|
desc <<-EOF
|
6
10
|
This generator makes the following changes to your application:
|
7
11
|
1. Installs solr_wrapper into your application
|
8
|
-
2.
|
12
|
+
2. Copies default blacklight solr config directory into your application
|
13
|
+
3. Copies default .solr_wrapper into your application
|
14
|
+
4. Adds rsolr to your Gemfile
|
9
15
|
EOF
|
10
16
|
|
11
17
|
def install_solrwrapper
|
@@ -16,6 +22,14 @@ module Blacklight
|
|
16
22
|
append_to_file "Rakefile", "\nrequire 'solr_wrapper/rake_task' unless Rails.env.production?\n"
|
17
23
|
end
|
18
24
|
|
25
|
+
def copy_solr_conf
|
26
|
+
directory 'solr', 'solr'
|
27
|
+
end
|
28
|
+
|
29
|
+
def solr_wrapper_config
|
30
|
+
copy_file '.solr_wrapper.yml', '.solr_wrapper.yml'
|
31
|
+
end
|
32
|
+
|
19
33
|
def add_rsolr_gem
|
20
34
|
gem 'rsolr', '~> 1.0'
|
21
35
|
end
|
@@ -56,7 +56,7 @@ namespace :blacklight do
|
|
56
56
|
|
57
57
|
begin
|
58
58
|
response = controller.find q: '{!lucene}*:*'
|
59
|
-
if response.header['status']
|
59
|
+
if response.header['status'].zero?
|
60
60
|
puts "OK"
|
61
61
|
else
|
62
62
|
errors += 1
|
@@ -78,7 +78,7 @@ namespace :blacklight do
|
|
78
78
|
begin
|
79
79
|
response, docs = controller.search_results(q: '{!lucene}*:*')
|
80
80
|
|
81
|
-
if response.header['status']
|
81
|
+
if response.header['status'].zero? and docs.any?
|
82
82
|
puts "OK"
|
83
83
|
else
|
84
84
|
errors += 1
|
@@ -101,7 +101,7 @@ namespace :blacklight do
|
|
101
101
|
doc_id = response.documents.first.id
|
102
102
|
response, doc = controller.fetch doc_id
|
103
103
|
|
104
|
-
if response.header['status']
|
104
|
+
if response.header['status'].zero? and doc
|
105
105
|
puts "OK"
|
106
106
|
else
|
107
107
|
errors += 1
|
@@ -370,23 +370,21 @@ describe Blacklight::SearchHelper do
|
|
370
370
|
|
371
371
|
describe "for 'true' configured values" do
|
372
372
|
let(:blacklight_config) do
|
373
|
-
|
374
|
-
|
375
|
-
|
373
|
+
Blacklight::Configuration.new do |config|
|
374
|
+
config.add_facet_field "language_facet", limit: true
|
375
|
+
end
|
376
376
|
end
|
377
377
|
it "returns nil if no @response available" do
|
378
378
|
expect(subject.facet_limit_for("some_unknown_field")).to be_nil
|
379
379
|
end
|
380
380
|
it "gets from @response facet.limit if available" do
|
381
|
-
@response = double()
|
382
|
-
allow(@response).to receive(:aggregations).and_return("language_facet" => double(limit: nil))
|
381
|
+
@response = instance_double(Blacklight::Solr::Response, aggregations: { "language_facet" => double(limit: nil) })
|
383
382
|
subject.instance_variable_set(:@response, @response)
|
384
383
|
blacklight_config.facet_fields['language_facet'].limit = 10
|
385
384
|
expect(subject.facet_limit_for("language_facet")).to eq 10
|
386
385
|
end
|
387
386
|
it "gets the limit from the facet field in @response" do
|
388
|
-
@response = double()
|
389
|
-
allow(@response).to receive(:aggregations).and_return("language_facet" => double(limit: 16))
|
387
|
+
@response = instance_double(Blacklight::Solr::Response, aggregations: { "language_facet" => double(limit: 16) })
|
390
388
|
subject.instance_variable_set(:@response, @response)
|
391
389
|
expect(subject.facet_limit_for("language_facet")).to eq 15
|
392
390
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
describe Blacklight::SuggestSearch do
|
4
4
|
let(:params) { {q: 'test'} }
|
5
5
|
let(:suggest_path) { 'suggest' }
|
6
|
-
let(:connection) {
|
7
|
-
let(:repository) {
|
6
|
+
let(:connection) { instance_double(RSolr::Client, send_and_receive: 'sent')}
|
7
|
+
let(:repository) { instance_double(Blacklight::Solr::Repository, connection: connection) }
|
8
8
|
let(:suggest_search) { described_class.new(params, repository)}
|
9
9
|
describe '#suggestions' do
|
10
10
|
it 'returns a Blacklight::Suggest::Response' do
|
@@ -40,9 +40,9 @@ describe BookmarksController do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "has a 500 status code when delete is not success" do
|
43
|
-
bm =
|
43
|
+
bm = instance_double(Bookmark)
|
44
44
|
allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(bm)
|
45
|
-
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :find_by).and_return(
|
45
|
+
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :find_by).and_return(instance_double(Bookmark, delete: nil, destroyed?: false))
|
46
46
|
|
47
47
|
delete :destroy, xhr: true, params: { id: 'pleasekillme', format: :js }
|
48
48
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
describe CatalogController do
|
3
3
|
let(:doc_id) { '2007020969' }
|
4
|
-
let(:mock_response) {
|
5
|
-
let(:mock_document) {
|
4
|
+
let(:mock_response) { instance_double(Blacklight::Solr::Response) }
|
5
|
+
let(:mock_document) { instance_double(SolrDocument) }
|
6
6
|
|
7
7
|
describe "index action" do
|
8
8
|
context "with format :html" do
|
@@ -370,7 +370,7 @@ describe CatalogController do
|
|
370
370
|
end
|
371
371
|
|
372
372
|
describe "email/sms" do
|
373
|
-
let(:mock_response) {
|
373
|
+
let(:mock_response) { instance_double(Blacklight::Solr::Response, documents: [SolrDocument.new(id: 'my_fake_doc'), SolrDocument.new(id: 'my_other_doc')]) }
|
374
374
|
before do
|
375
375
|
allow(controller).to receive_messages(find: mock_response)
|
376
376
|
request.env["HTTP_REFERER"] = "/catalog/#{doc_id}"
|
@@ -651,10 +651,10 @@ describe CatalogController do
|
|
651
651
|
end
|
652
652
|
end
|
653
653
|
|
654
|
-
describe "
|
655
|
-
it "is the same as the catalog
|
654
|
+
describe "search_facet_path" do
|
655
|
+
it "is the same as the catalog path" do
|
656
656
|
get :index, params: { page: 1 }
|
657
|
-
expect(controller.send(:
|
657
|
+
expect(controller.send(:search_facet_path, id: "some_facet", page: 5)).to eq facet_catalog_path(id: "some_facet")
|
658
658
|
end
|
659
659
|
end
|
660
660
|
end
|
@@ -34,11 +34,10 @@ describe "Search Results context", js: true do
|
|
34
34
|
context "navigating between search results using context pagination" do
|
35
35
|
it "updates the back to search link with the current search pagination context" do
|
36
36
|
search_for ''
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
expect(page).to have_content "1 - 10"
|
38
|
+
find_all('.index_title a').last.click
|
39
|
+
click_on "Next »"
|
40
|
+
|
42
41
|
click_on "Back to Search"
|
43
42
|
expect(page).to have_content "11 - 20"
|
44
43
|
end
|
@@ -1,12 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe "Search Formats" do
|
4
|
-
before do
|
5
|
-
# Get all the fields from Solr, so the #index documents have the MARC field (to trigger appropriate
|
6
|
-
# export formats)
|
7
|
-
CatalogController.blacklight_config.default_solr_params[:fl] = '*'
|
8
|
-
end
|
9
|
-
|
10
4
|
it "has an RSS XML response" do
|
11
5
|
visit "/catalog.rss?q="
|
12
6
|
expect(page).to have_content "Blacklight Search Results"
|
@@ -32,7 +32,7 @@ describe BlacklightHelper do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "render_link_rel_alternates" do
|
35
|
-
let(:document) {
|
35
|
+
let(:document) { instance_double(SolrDocument) }
|
36
36
|
let(:result) { double }
|
37
37
|
let(:presenter) { Blacklight::DocumentPresenter.new(document, self) }
|
38
38
|
let(:blacklight_config) do
|
@@ -153,8 +153,8 @@ describe BlacklightHelper do
|
|
153
153
|
|
154
154
|
context "render methods" do
|
155
155
|
let(:field) { "some_field" }
|
156
|
-
let(:doc) {
|
157
|
-
let(:presenter) {
|
156
|
+
let(:doc) { instance_double(SolrDocument) }
|
157
|
+
let(:presenter) { instance_double(Blacklight::ShowPresenter) }
|
158
158
|
before do
|
159
159
|
allow(Deprecation).to receive(:warn) # TODO: purge Deprecations
|
160
160
|
allow(helper).to receive(:presenter).with(doc).and_return(presenter)
|
@@ -196,7 +196,7 @@ describe BlacklightHelper do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
describe "#document_has_value?" do
|
199
|
-
let(:doc) { double() }
|
199
|
+
let(:doc) { double(SolrDocument) }
|
200
200
|
it "ifs the document has the field value" do
|
201
201
|
allow(doc).to receive(:has?).with('asdf').and_return(true)
|
202
202
|
field_config = double(:field => 'asdf')
|
@@ -218,12 +218,12 @@ describe BlacklightHelper do
|
|
218
218
|
|
219
219
|
describe "render_grouped_response?" do
|
220
220
|
it "checks if the response ivar contains grouped data" do
|
221
|
-
assign(:response,
|
221
|
+
assign(:response, instance_double(Blacklight::Solr::Response, grouped?: true))
|
222
222
|
expect(helper.render_grouped_response?).to be true
|
223
223
|
end
|
224
224
|
|
225
225
|
it "checks if the response param contains grouped data" do
|
226
|
-
response =
|
226
|
+
response = instance_double(Blacklight::Solr::Response, grouped?: true)
|
227
227
|
expect(helper.render_grouped_response?(response)).to be true
|
228
228
|
end
|
229
229
|
end
|
@@ -351,7 +351,7 @@ describe BlacklightHelper do
|
|
351
351
|
let(:obj1) { SolrDocument.new }
|
352
352
|
before do
|
353
353
|
allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
|
354
|
-
assign(:response,
|
354
|
+
assign(:response, instance_double(Blacklight::Solr::Response, grouped?: false, start: 0))
|
355
355
|
allow(helper).to receive(:link_to_document).and_return('<a/>')
|
356
356
|
allow(helper).to receive(:render_index_doc_actions).and_return('<div/>')
|
357
357
|
end
|
@@ -188,32 +188,32 @@ describe CatalogHelper do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
describe "has_thumbnail?" do
|
191
|
+
let(:document) { instance_double(SolrDocument) }
|
191
192
|
it "has a thumbnail if a thumbnail_method is configured" do
|
192
193
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
|
193
|
-
document = double()
|
194
194
|
expect(helper.has_thumbnail? document).to be true
|
195
195
|
end
|
196
196
|
|
197
197
|
it "has a thumbnail if a thumbnail_field is configured and it exists in the document" do
|
198
198
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
|
199
|
-
document
|
199
|
+
allow(document).to receive_messages(has?: true)
|
200
200
|
expect(helper.has_thumbnail? document).to be true
|
201
201
|
end
|
202
202
|
|
203
203
|
it "does not have a thumbnail if the thumbnail_field is missing from the document" do
|
204
204
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
|
205
|
-
document
|
205
|
+
allow(document).to receive_messages(has?: false)
|
206
206
|
expect(helper.has_thumbnail? document).to be false
|
207
207
|
end
|
208
208
|
|
209
209
|
it "does not have a thumbnail if none of the fields are configured" do
|
210
210
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new() ))
|
211
|
-
expect(helper.has_thumbnail?
|
211
|
+
expect(helper.has_thumbnail? document).to be_falsey
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
215
|
describe "render_thumbnail_tag" do
|
216
|
-
let(:document) {
|
216
|
+
let(:document) { instance_double(SolrDocument) }
|
217
217
|
it "calls the provided thumbnail method" do
|
218
218
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
|
219
219
|
expect(helper).to receive_messages(:xyz => "some-thumbnail")
|
@@ -273,7 +273,7 @@ describe CatalogHelper do
|
|
273
273
|
describe "thumbnail_url" do
|
274
274
|
it "pulls the configured thumbnail field out of the document" do
|
275
275
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
|
276
|
-
document =
|
276
|
+
document = instance_double(SolrDocument)
|
277
277
|
allow(document).to receive(:has?).with(:xyz).and_return(true)
|
278
278
|
allow(document).to receive(:first).with(:xyz).and_return("asdf")
|
279
279
|
expect(helper.thumbnail_url document).to eq("asdf")
|
@@ -281,7 +281,7 @@ describe CatalogHelper do
|
|
281
281
|
|
282
282
|
it "returns nil if the thumbnail field doesn't exist" do
|
283
283
|
allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
|
284
|
-
document =
|
284
|
+
document = instance_double(SolrDocument)
|
285
285
|
allow(document).to receive(:has?).with(:xyz).and_return(false)
|
286
286
|
expect(helper.thumbnail_url document).to be_nil
|
287
287
|
end
|
@@ -289,19 +289,19 @@ describe CatalogHelper do
|
|
289
289
|
|
290
290
|
describe "document_counter_with_offset" do
|
291
291
|
it "renders the document index with the appropriate offset" do
|
292
|
-
assign(:response,
|
292
|
+
assign(:response, instance_double(Blacklight::Solr::Response, start: 0, grouped?: false))
|
293
293
|
expect(helper.document_counter_with_offset(0)).to be(1)
|
294
294
|
expect(helper.document_counter_with_offset(1)).to be(2)
|
295
295
|
end
|
296
296
|
|
297
297
|
it "renders the document index with the appropriate offset" do
|
298
|
-
assign(:response,
|
298
|
+
assign(:response, instance_double(Blacklight::Solr::Response, start: 10, grouped?: false))
|
299
299
|
expect(helper.document_counter_with_offset(0)).to be(11)
|
300
300
|
expect(helper.document_counter_with_offset(1)).to be(12)
|
301
301
|
end
|
302
302
|
|
303
303
|
it "does not provide a counter for grouped responses" do
|
304
|
-
assign(:response,
|
304
|
+
assign(:response, instance_double(Blacklight::Solr::Response, start: 10, grouped?: true))
|
305
305
|
expect(helper.document_counter_with_offset(0)).to be_nil
|
306
306
|
end
|
307
307
|
end
|
@@ -111,7 +111,7 @@ describe BlacklightConfigurationHelper do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
describe "#index_field_label" do
|
114
|
-
let(:document) {
|
114
|
+
let(:document) { instance_double(SolrDocument) }
|
115
115
|
it "looks up the label to display for the given document and field" do
|
116
116
|
allow(helper).to receive(:index_fields).and_return({ "my_field" => double(label: "some label") })
|
117
117
|
allow(helper).to receive(:field_label).with(:"blacklight.search.fields.index.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
|
@@ -120,7 +120,7 @@ describe BlacklightConfigurationHelper do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
describe "#document_show_field_label" do
|
123
|
-
let(:document) {
|
123
|
+
let(:document) { instance_double(SolrDocument) }
|
124
124
|
it "looks up the label to display for the given document and field" do
|
125
125
|
allow(helper).to receive(:document_show_fields).and_return({ "my_field" => double(label: "some label") })
|
126
126
|
allow(helper).to receive(:field_label).with(:"blacklight.search.fields.show.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
|
@@ -129,7 +129,7 @@ describe BlacklightConfigurationHelper do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
describe "#facet_field_label" do
|
132
|
-
let(:document) {
|
132
|
+
let(:document) { instance_double(SolrDocument) }
|
133
133
|
it "looks up the label to display for the given document and field" do
|
134
134
|
allow(blacklight_config).to receive(:facet_fields).and_return({ "my_field" => double(label: "some label") })
|
135
135
|
allow(helper).to receive(:field_label).with(:"blacklight.search.fields.facet.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
|
@@ -107,8 +107,7 @@ describe FacetsHelper do
|
|
107
107
|
facet_config = double(query: nil, field: 'b', key: 'a')
|
108
108
|
facet_field = double()
|
109
109
|
allow(helper).to receive(:facet_configuration_for_field).with('b').and_return(facet_config)
|
110
|
-
@response =
|
111
|
-
allow(@response).to receive(:aggregations).and_return('b' => facet_field)
|
110
|
+
@response = instance_double(Blacklight::Solr::Response, aggregations: { 'b' => facet_field })
|
112
111
|
|
113
112
|
expect(helper.facet_by_field_name('b')).to eq facet_field
|
114
113
|
end
|
@@ -56,6 +56,14 @@ describe RenderConstraintsHelper do
|
|
56
56
|
expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
|
57
57
|
expect(subject).to have_selector ".filterName", text: 'Item Type'
|
58
58
|
end
|
59
|
+
|
60
|
+
context 'with string values' do
|
61
|
+
subject { helper.render_filter_element('type', 'journal', path) }
|
62
|
+
|
63
|
+
it "handles string values gracefully" do
|
64
|
+
expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
|
65
|
+
end
|
66
|
+
end
|
59
67
|
end
|
60
68
|
|
61
69
|
describe "#render_constraints_filters" do
|