blacklight 7.0.0.rc1 → 7.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +30 -18
- data/.rubocop_todo.yml +308 -67
- data/.solr_wrapper.yml +8 -1
- data/.travis.yml +15 -13
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/Vagrantfile +2 -0
- data/app/assets/javascripts/blacklight/blacklight.js +17 -17
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +17 -16
- data/app/assets/stylesheets/blacklight/_facets.scss +2 -13
- data/app/assets/stylesheets/blacklight/_icons.scss +8 -2
- data/app/assets/stylesheets/blacklight/_search_form.scss +7 -0
- data/app/assets/stylesheets/blacklight/blacklight.scss +1 -1
- data/app/builders/blacklight/action_builder.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +19 -13
- data/app/controllers/concerns/blacklight/catalog.rb +19 -7
- data/app/controllers/concerns/blacklight/controller.rb +12 -18
- data/app/controllers/concerns/blacklight/facet.rb +3 -0
- data/app/controllers/concerns/blacklight/search_context.rb +7 -3
- data/app/controllers/concerns/blacklight/search_history.rb +1 -6
- data/app/controllers/concerns/blacklight/token_based_user.rb +3 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +5 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +5 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -12
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +29 -14
- data/app/javascript/blacklight/checkbox_submit.js +9 -8
- data/app/javascript/blacklight/core.js +8 -6
- data/app/javascript/blacklight/modal.js +1 -3
- data/app/javascript/blacklight/search_context.js +0 -1
- data/app/models/blacklight/icon.rb +3 -0
- data/app/models/blacklight/suggest_search.rb +3 -14
- data/app/models/bookmark.rb +1 -1
- data/app/models/concerns/blacklight/document.rb +3 -1
- data/app/models/concerns/blacklight/solr/document.rb +1 -0
- data/app/models/concerns/blacklight/suggest/response.rb +5 -3
- data/app/models/concerns/blacklight/user.rb +1 -0
- data/app/models/search.rb +1 -0
- data/app/presenters/blacklight/document_presenter.rb +38 -0
- data/app/presenters/blacklight/field_presenter.rb +2 -0
- data/app/presenters/blacklight/index_presenter.rb +13 -5
- data/app/presenters/blacklight/json_presenter.rb +5 -12
- data/app/presenters/blacklight/link_alternate_presenter.rb +2 -0
- data/app/presenters/blacklight/rendering/abstract_step.rb +2 -0
- data/app/presenters/blacklight/rendering/helper_method.rb +2 -0
- data/app/presenters/blacklight/rendering/join.rb +2 -0
- data/app/presenters/blacklight/rendering/link_to_facet.rb +4 -0
- data/app/presenters/blacklight/rendering/microdata.rb +3 -0
- data/app/presenters/blacklight/rendering/pipeline.rb +2 -0
- data/app/presenters/blacklight/rendering/terminator.rb +2 -0
- data/app/presenters/blacklight/search_bar_presenter.rb +2 -0
- data/app/presenters/blacklight/show_presenter.rb +8 -5
- data/app/presenters/blacklight/thumbnail_presenter.rb +2 -0
- data/app/services/blacklight/document_factory.rb +2 -0
- data/app/services/blacklight/field_retriever.rb +2 -0
- data/app/services/blacklight/search_service.rb +7 -9
- data/app/values/blacklight/types.rb +3 -0
- data/app/views/bookmarks/index.html.erb +12 -13
- data/app/views/catalog/_citation.html.erb +4 -4
- data/app/views/catalog/_constraints.html.erb +2 -0
- data/app/views/catalog/_did_you_mean.html.erb +1 -1
- data/app/views/catalog/_document.atom.builder +17 -16
- data/app/views/catalog/_document.rss.builder +2 -0
- data/app/views/catalog/_facet_index_navigation.html.erb +5 -4
- data/app/views/catalog/_facet_layout.html.erb +3 -5
- data/app/views/catalog/_facets.html.erb +5 -4
- data/app/views/catalog/_field.json.jbuilder +10 -0
- data/app/views/catalog/_group.html.erb +1 -1
- data/app/views/catalog/_home_text.html.erb +5 -5
- data/app/views/catalog/_index.html.erb +5 -7
- data/app/views/catalog/_index_header.html.erb +1 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_results_pagination.html.erb +2 -2
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/catalog/_search_results.html.erb +2 -2
- data/app/views/catalog/_show.html.erb +3 -5
- data/app/views/catalog/_show_more_like_this.html.erb +1 -1
- data/app/views/catalog/_show_sidebar.html.erb +1 -1
- data/app/views/catalog/_show_tools.html.erb +1 -1
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/catalog/_zero_results.html.erb +1 -1
- data/app/views/catalog/citation.js.erb +1 -1
- data/app/views/catalog/facet.html.erb +5 -4
- data/app/views/catalog/facet.json.jbuilder +2 -0
- data/app/views/catalog/index.atom.builder +4 -2
- data/app/views/catalog/index.json.jbuilder +29 -10
- data/app/views/catalog/index.rss.builder +2 -0
- data/app/views/catalog/opensearch.xml.builder +3 -1
- data/app/views/catalog/show.json.jbuilder +21 -0
- data/app/views/kaminari/blacklight/_first_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_last_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_next_page.html.erb +3 -3
- data/app/views/kaminari/blacklight/_page.html.erb +4 -2
- data/app/views/kaminari/blacklight/_prev_page.html.erb +2 -2
- data/app/views/layouts/blacklight.html.erb +4 -4
- data/app/views/layouts/blacklight/base.html.erb +1 -9
- data/app/views/search_history/index.html.erb +3 -3
- data/app/views/shared/_header_navbar.html.erb +1 -1
- data/app/views/shared/_modal.html.erb +2 -2
- data/blacklight.gemspec +7 -6
- data/config/i18n-tasks.yml +17 -0
- data/config/locales/blacklight.de.yml +72 -57
- data/config/locales/blacklight.en.yml +11 -1
- data/config/locales/blacklight.es.yml +15 -1
- data/config/locales/blacklight.fr.yml +17 -8
- data/config/locales/blacklight.hu.yml +3 -1
- data/config/locales/blacklight.it.yml +16 -1
- data/config/locales/blacklight.nl.yml +3 -1
- data/config/locales/blacklight.pt-BR.yml +19 -2
- data/config/locales/blacklight.sq.yml +3 -1
- data/config/locales/blacklight.zh.yml +3 -1
- data/config/routes.rb +0 -1
- data/lib/blacklight.rb +3 -0
- data/lib/blacklight/abstract_repository.rb +12 -0
- data/lib/blacklight/configuration.rb +21 -3
- data/lib/blacklight/configuration/context.rb +11 -0
- data/lib/blacklight/configuration/fields.rb +31 -26
- data/lib/blacklight/configuration/null_field.rb +2 -0
- data/lib/blacklight/engine.rb +4 -1
- data/lib/blacklight/routes/exportable.rb +1 -3
- data/lib/blacklight/routes/searchable.rb +2 -3
- data/lib/blacklight/runtime_registry.rb +2 -0
- data/lib/blacklight/search_builder.rb +2 -0
- data/lib/blacklight/search_state.rb +2 -0
- data/lib/blacklight/solr/repository.rb +34 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/generators/blacklight/assets_generator.rb +10 -9
- data/lib/generators/blacklight/controller_generator.rb +1 -1
- data/lib/generators/blacklight/install_generator.rb +7 -14
- data/lib/generators/blacklight/solr_generator.rb +8 -0
- data/lib/generators/blacklight/templates/alternate_controller.rb +4 -4
- data/lib/generators/blacklight/templates/catalog_controller.rb +7 -1
- data/lib/generators/blacklight/templates/solr/conf/schema.xml +20 -22
- data/lib/generators/blacklight/user_generator.rb +2 -0
- data/lib/railties/blacklight.rake +9 -13
- data/package-lock.json +544 -406
- data/package.json +3 -2
- data/spec/controllers/alternate_controller_spec.rb +4 -3
- data/spec/controllers/application_controller_spec.rb +0 -4
- data/spec/controllers/blacklight/base_spec.rb +5 -2
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +4 -4
- data/spec/controllers/blacklight/facet_spec.rb +0 -1
- data/spec/controllers/blacklight/search_fields_spec.rb +25 -22
- data/spec/controllers/bookmarks_controller_spec.rb +45 -10
- data/spec/controllers/catalog_controller_spec.rb +206 -138
- data/spec/controllers/search_history_controller_spec.rb +4 -4
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/autocomplete_spec.rb +2 -0
- data/spec/features/did_you_mean_spec.rb +4 -3
- data/spec/features/facets_spec.rb +7 -7
- data/spec/features/record_view_spec.rb +11 -12
- data/spec/features/search_context_spec.rb +4 -5
- data/spec/features/search_crawler_spec.rb +3 -5
- data/spec/features/search_filters_spec.rb +44 -44
- data/spec/features/search_history_spec.rb +5 -3
- data/spec/features/search_pagination_spec.rb +3 -1
- data/spec/features/search_results_spec.rb +11 -8
- data/spec/features/search_spec.rb +3 -3
- data/spec/features/sitelinks_search_box.rb +4 -4
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +30 -30
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +65 -59
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +8 -3
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +16 -4
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +21 -22
- data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +6 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +49 -43
- data/spec/helpers/blacklight_helper_spec.rb +28 -12
- data/spec/helpers/catalog_helper_spec.rb +50 -47
- data/spec/i18n_spec.rb +18 -0
- data/spec/integration/generators/blacklight/solr_generator_spec.rb +18 -10
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +2 -0
- data/spec/lib/blacklight/configuration/field_spec.rb +3 -0
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +15 -20
- data/spec/lib/blacklight/parameters_spec.rb +3 -1
- data/spec/lib/blacklight/search_state_spec.rb +51 -34
- data/spec/lib/blacklight_spec.rb +13 -14
- data/spec/lib/tasks/blacklight_task_spec.rb +3 -5
- data/spec/models/blacklight/configurable_spec.rb +11 -13
- data/spec/models/blacklight/configuration/context_spec.rb +9 -10
- data/spec/models/blacklight/configuration_spec.rb +103 -91
- data/spec/models/blacklight/document/active_model_shim_spec.rb +5 -6
- data/spec/models/blacklight/document/cache_key_spec.rb +9 -2
- data/spec/models/blacklight/document/dublin_core_spec.rb +16 -19
- data/spec/models/blacklight/document/email_spec.rb +9 -9
- data/spec/models/blacklight/document/sms_spec.rb +9 -9
- data/spec/models/blacklight/document_spec.rb +9 -8
- data/spec/models/blacklight/facet_paginator_spec.rb +40 -30
- data/spec/models/blacklight/icon_spec.rb +12 -2
- data/spec/models/blacklight/search_builder_spec.rb +12 -3
- data/spec/models/blacklight/solr/document_spec.rb +216 -219
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +6 -4
- data/spec/models/blacklight/solr/repository_spec.rb +37 -34
- data/spec/models/blacklight/solr/request_spec.rb +17 -18
- data/spec/models/blacklight/solr/response/facets_spec.rb +58 -58
- data/spec/models/blacklight/solr/response/group_response_spec.rb +16 -22
- data/spec/models/blacklight/solr/response/group_spec.rb +18 -25
- data/spec/models/blacklight/solr/response_spec.rb +48 -50
- data/spec/models/blacklight/solr/search_builder_spec.rb +120 -121
- data/spec/models/blacklight/suggest/response_spec.rb +6 -4
- data/spec/models/blacklight/suggest_search_spec.rb +9 -16
- data/spec/models/blacklight/user_spec.rb +9 -11
- data/spec/models/bookmark_spec.rb +6 -5
- data/spec/models/record_mailer_spec.rb +22 -20
- data/spec/models/search_spec.rb +18 -17
- data/spec/models/solr_document_spec.rb +6 -2
- data/spec/presenters/blacklight/document_presenter_spec.rb +86 -0
- data/spec/presenters/blacklight/index_presenter_spec.rb +186 -0
- data/spec/presenters/blacklight/json_presenter_spec.rb +59 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -0
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +7 -0
- data/spec/presenters/{show_presenter_spec.rb → blacklight/show_presenter_spec.rb} +138 -91
- data/spec/presenters/pipeline_spec.rb +15 -8
- data/spec/presenters/thumbnail_presenter_spec.rb +5 -2
- data/spec/routing/catalog_routing_spec.rb +12 -14
- data/spec/services/blacklight/search_service_spec.rb +112 -70
- data/spec/spec_helper.rb +6 -2
- data/spec/support/features.rb +1 -1
- data/spec/support/features/session_helpers.rb +4 -4
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -13
- data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -3
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +9 -5
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_facets.html.erb_spec.rb +8 -10
- data/spec/views/catalog/_index.html.erb_spec.rb +13 -14
- data/spec/views/catalog/_index_header.html.erb_spec.rb +5 -8
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_show.html.erb_spec.rb +12 -13
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +4 -7
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/catalog/_sort_widget.html.erb_spec.rb +3 -1
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +6 -8
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -9
- data/spec/views/catalog/email_success.html.erb_spec.rb +0 -1
- data/spec/views/catalog/facet.html.erb_spec.rb +3 -2
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +3 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +9 -4
- data/spec/views/catalog/index.html.erb_spec.rb +2 -1
- data/spec/views/catalog/index.json.jbuilder_spec.rb +84 -36
- data/spec/views/catalog/show.html.erb_spec.rb +6 -6
- data/spec/views/catalog/show.json.jbuilder_spec.rb +40 -0
- data/spec/views/catalog/sms_success.html.erb_spec.rb +0 -1
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +1 -4
- data/tasks/blacklight.rake +6 -4
- data/template.demo.rb +2 -0
- metadata +50 -24
- data/app/javascript/blacklight/autofocus.js +0 -20
- data/spec/presenters/index_presenter_spec.rb +0 -150
@@ -9,28 +9,35 @@ RSpec.describe Blacklight::Rendering::Pipeline do
|
|
9
9
|
|
10
10
|
describe "render" do
|
11
11
|
subject { presenter.render }
|
12
|
-
|
12
|
+
|
13
|
+
let(:values) { %w[a b] }
|
13
14
|
let(:field_config) { Blacklight::Configuration::NullField.new }
|
15
|
+
|
14
16
|
it { is_expected.to eq "a and b" }
|
15
17
|
|
16
18
|
context "when separator_options are in the config" do
|
17
|
-
let(:values) { [
|
18
|
-
let(:field_config) { Blacklight::Configuration::NullField.new(itemprop: nil, separator_options: { two_words_connector: '; '}) }
|
19
|
+
let(:values) { %w[c d] }
|
20
|
+
let(:field_config) { Blacklight::Configuration::NullField.new(itemprop: nil, separator_options: { two_words_connector: '; ' }) }
|
21
|
+
|
19
22
|
it { is_expected.to eq "c; d" }
|
20
23
|
end
|
21
24
|
|
22
25
|
context "when itemprop is in the config" do
|
23
26
|
let(:values) { ['a'] }
|
24
27
|
let(:field_config) { Blacklight::Configuration::NullField.new(itemprop: 'some-prop', separator_options: nil) }
|
25
|
-
|
28
|
+
|
29
|
+
it { is_expected.to have_selector("span[@itemprop='some-prop']", text: "a") }
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
33
|
describe "#operations" do
|
30
34
|
subject { described_class.operations }
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
|
36
|
+
it {
|
37
|
+
expect(subject).to eq [Blacklight::Rendering::HelperMethod,
|
38
|
+
Blacklight::Rendering::LinkToFacet,
|
39
|
+
Blacklight::Rendering::Microdata,
|
40
|
+
Blacklight::Rendering::Join]
|
41
|
+
}
|
35
42
|
end
|
36
43
|
end
|
@@ -14,6 +14,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
14
14
|
let(:config) do
|
15
15
|
Blacklight::OpenStructWithHashAccess.new(thumbnail_method: :xyz)
|
16
16
|
end
|
17
|
+
|
17
18
|
it { is_expected.to be true }
|
18
19
|
end
|
19
20
|
|
@@ -62,6 +63,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
62
63
|
|
63
64
|
describe "#thumbnail_tag" do
|
64
65
|
subject { presenter.thumbnail_tag }
|
66
|
+
|
65
67
|
context "when thumbnail_method is configured" do
|
66
68
|
let(:config) do
|
67
69
|
Blacklight::OpenStructWithHashAccess.new(thumbnail_method: :xyz)
|
@@ -75,7 +77,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
75
77
|
it "calls the provided thumbnail method" do
|
76
78
|
expect(view_context).to receive_messages(xyz: "some-thumbnail")
|
77
79
|
allow(view_context).to receive(:link_to_document).with(document, "some-thumbnail", {})
|
78
|
-
|
80
|
+
.and_return("link")
|
79
81
|
expect(subject).to eq "link"
|
80
82
|
end
|
81
83
|
|
@@ -92,6 +94,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
92
94
|
before do
|
93
95
|
allow(view_context).to receive_messages(xyz: nil)
|
94
96
|
end
|
97
|
+
|
95
98
|
it { is_expected.to be nil }
|
96
99
|
end
|
97
100
|
end
|
@@ -155,7 +158,7 @@ RSpec.describe Blacklight::ThumbnailPresenter do
|
|
155
158
|
|
156
159
|
context "and is a proc" do
|
157
160
|
let(:config) do
|
158
|
-
Blacklight::OpenStructWithHashAccess.new(default_thumbnail:
|
161
|
+
Blacklight::OpenStructWithHashAccess.new(default_thumbnail: ->(_, _) { '<img src="image.jpg">' })
|
159
162
|
end
|
160
163
|
|
161
164
|
it "calls that lambda" do
|
@@ -5,50 +5,48 @@ RSpec.describe "Routing" do
|
|
5
5
|
describe "Paths Generated by Custom Routes:" do
|
6
6
|
# paths generated by custom routes
|
7
7
|
it "has a path for showing the email form" do
|
8
|
-
expect(:
|
8
|
+
expect(get: "/catalog/email").to route_to(controller: 'catalog', action: 'email')
|
9
9
|
end
|
10
10
|
it "has a path for sending the email" do
|
11
|
-
expect(:
|
11
|
+
expect(post: "/catalog/email").to route_to(controller: 'catalog', action: 'email')
|
12
12
|
end
|
13
13
|
it "maps GET {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
|
14
|
-
expect(:
|
14
|
+
expect(get: "/catalog/sms").to route_to(controller: 'catalog', action: 'sms')
|
15
15
|
end
|
16
16
|
it "maps POST {:controller => 'catalog', :action => 'sms'} to /catalog/sms" do
|
17
|
-
expect(:
|
17
|
+
expect(post: "/catalog/sms").to route_to(controller: 'catalog', action: 'sms')
|
18
18
|
end
|
19
19
|
it "maps { :controller => 'catalog', :action => 'show', :id => 666 } to /catalog/666" do
|
20
|
-
expect(:
|
20
|
+
expect(get: "/catalog/666").to route_to(controller: 'catalog', action: 'show', id: "666")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
describe "solr_document_path for SolrDocument", :test => true do
|
24
|
+
describe "solr_document_path for SolrDocument", test: true do
|
26
25
|
it "routes correctly" do
|
27
|
-
expect(:
|
26
|
+
expect(get: solr_document_path(SolrDocument.new(id: 'asdf'))).to route_to(controller: 'catalog', action: 'show', id: 'asdf')
|
28
27
|
end
|
29
28
|
|
30
29
|
context "should escape solr document ids" do
|
31
|
-
|
32
30
|
it "pass-throughs url-valid ids" do
|
33
|
-
expect(:
|
31
|
+
expect(get: solr_document_path(SolrDocument.new(id: 'qwerty'))).to route_to(controller: 'catalog', action: 'show', id: 'qwerty')
|
34
32
|
end
|
35
33
|
|
36
34
|
it "routes url-like ids" do
|
37
35
|
skip "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
|
38
|
-
expect(:
|
36
|
+
expect(get: solr_document_path(SolrDocument.new(id: 'http://example.com'))).to route_to(controller: 'catalog', action: 'show', id: 'http://example.com')
|
39
37
|
end
|
40
38
|
|
41
39
|
it "routes ids with whitespace" do
|
42
|
-
expect(:
|
40
|
+
expect(get: solr_document_path(SolrDocument.new(id: 'mm 123'))).to route_to(controller: 'catalog', action: 'show', id: 'mm 123')
|
43
41
|
end
|
44
42
|
|
45
43
|
it "routes ids with a literal '+'" do
|
46
|
-
expect(:
|
44
|
+
expect(get: solr_document_path(SolrDocument.new(id: 'this+that'))).to route_to(controller: 'catalog', action: 'show', id: 'this+that')
|
47
45
|
end
|
48
46
|
|
49
47
|
it "routes ids with a literal '/" do
|
50
48
|
skip "This works if you configure your routing to have very liberal constraints on :id.. not sure how to go about testing it though"
|
51
|
-
expect(:
|
49
|
+
expect(get: solr_document_path(SolrDocument.new(id: 'and/or'))).to route_to(controller: 'catalog', action: 'show', id: 'and/or')
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
@@ -8,12 +8,13 @@
|
|
8
8
|
# to talk with solr and get results)? when we do a document request, does
|
9
9
|
# blacklight code get a single document returned?)
|
10
10
|
#
|
11
|
-
RSpec.describe Blacklight::SearchService do
|
11
|
+
RSpec.describe Blacklight::SearchService, api: true do
|
12
|
+
subject { service }
|
12
13
|
|
13
|
-
let(:service) { described_class.new(blacklight_config, user_params) }
|
14
|
+
let(:service) { described_class.new(config: blacklight_config, user_params: user_params) }
|
14
15
|
let(:repository) { Blacklight::Solr::Repository.new(blacklight_config) }
|
15
16
|
let(:user_params) { {} }
|
16
|
-
|
17
|
+
|
17
18
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
18
19
|
let(:copy_of_catalog_config) { ::CatalogController.blacklight_config.deep_copy }
|
19
20
|
let(:blacklight_solr) { RSolr.connect(Blacklight.connection_config.except(:adapter)) }
|
@@ -28,10 +29,28 @@ RSpec.describe Blacklight::SearchService do
|
|
28
29
|
service.repository.connection = blacklight_solr
|
29
30
|
end
|
30
31
|
|
31
|
-
#
|
32
|
-
|
32
|
+
describe '#search_builder_class' do
|
33
|
+
subject { service.send(:search_builder_class) }
|
34
|
+
|
35
|
+
it 'defaults to the value in the config' do
|
36
|
+
expect(subject).to eq SearchBuilder
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the search_builder_class is passed in' do
|
40
|
+
let(:klass) { double("Search builder") }
|
41
|
+
|
42
|
+
let(:service) { described_class.new(config: blacklight_config, user_params: user_params, search_builder_class: klass) }
|
33
43
|
|
44
|
+
it 'uses the passed value' do
|
45
|
+
expect(subject).to eq klass
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# SPECS FOR SEARCH RESULTS FOR QUERY
|
51
|
+
describe 'Search Results', integration: true do
|
34
52
|
let(:blacklight_config) { copy_of_catalog_config }
|
53
|
+
|
35
54
|
describe 'for a sample query returning results' do
|
36
55
|
let(:user_params) { { q: all_docs_query } }
|
37
56
|
|
@@ -40,13 +59,13 @@ RSpec.describe Blacklight::SearchService do
|
|
40
59
|
end
|
41
60
|
|
42
61
|
it "uses the configured request handler" do
|
43
|
-
allow(blacklight_config).to receive(:default_solr_params).and_return(
|
62
|
+
allow(blacklight_config).to receive(:default_solr_params).and_return(qt: 'custom_request_handler')
|
44
63
|
allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
|
45
64
|
expect(path).to eq 'select'
|
46
65
|
expect(params[:params]['facet.field']).to eq ["format", "{!ex=pub_date_ssim_single}pub_date_ssim", "subject_ssim", "language_ssim", "lc_1letter_ssim", "subject_geo_ssim", "subject_era_ssim"]
|
47
66
|
expect(params[:params]["facet.query"]).to eq ["pub_date_ssim:[#{5.years.ago.year} TO *]", "pub_date_ssim:[#{10.years.ago.year} TO *]", "pub_date_ssim:[#{25.years.ago.year} TO *]"]
|
48
|
-
expect(params[:params]).to include('rows' => 10, 'qt'=>"custom_request_handler", 'q'=>"", "f.subject_ssim.facet.limit"=>21, 'sort'=>"score desc, pub_date_si desc, title_si asc")
|
49
|
-
end.and_return(
|
67
|
+
expect(params[:params]).to include('rows' => 10, 'qt' => "custom_request_handler", 'q' => "", "f.subject_ssim.facet.limit" => 21, 'sort' => "score desc, pub_date_si desc, title_si asc")
|
68
|
+
end.and_return('response' => { 'docs' => [] })
|
50
69
|
service.search_results
|
51
70
|
end
|
52
71
|
|
@@ -71,6 +90,7 @@ RSpec.describe Blacklight::SearchService do
|
|
71
90
|
describe "for a query returning a grouped response" do
|
72
91
|
let(:blacklight_config) { copy_of_catalog_config }
|
73
92
|
let(:user_params) { { q: all_docs_query } }
|
93
|
+
|
74
94
|
before do
|
75
95
|
blacklight_config.default_solr_params[:group] = true
|
76
96
|
blacklight_config.default_solr_params[:'group.field'] = 'pub_date_si'
|
@@ -86,10 +106,11 @@ RSpec.describe Blacklight::SearchService do
|
|
86
106
|
describe "for a query returning multiple groups", integration: true do
|
87
107
|
let(:blacklight_config) { copy_of_catalog_config }
|
88
108
|
let(:user_params) { { q: all_docs_query } }
|
109
|
+
|
89
110
|
before do
|
90
111
|
allow(subject).to receive_messages grouped_key_for_results: 'title_si'
|
91
112
|
blacklight_config.default_solr_params[:group] = true
|
92
|
-
blacklight_config.default_solr_params[:'group.field'] = [
|
113
|
+
blacklight_config.default_solr_params[:'group.field'] = %w[pub_date_si title_si]
|
93
114
|
(@solr_response, @document_list) = service.search_results
|
94
115
|
end
|
95
116
|
|
@@ -100,9 +121,9 @@ RSpec.describe Blacklight::SearchService do
|
|
100
121
|
end
|
101
122
|
end
|
102
123
|
|
103
|
-
|
104
124
|
describe "for All Docs Query and One Facet" do
|
105
125
|
let(:user_params) { { q: all_docs_query, f: single_facet } }
|
126
|
+
|
106
127
|
it 'has results' do
|
107
128
|
(solr_response, document_list) = service.search_results
|
108
129
|
expect(solr_response.docs).to have(document_list.size).results
|
@@ -114,6 +135,7 @@ RSpec.describe Blacklight::SearchService do
|
|
114
135
|
|
115
136
|
describe "for Query Without Results and No Facet" do
|
116
137
|
let(:user_params) { { q: no_docs_query } }
|
138
|
+
|
117
139
|
it 'has no results and not raise error' do
|
118
140
|
(solr_response, document_list) = service.search_results
|
119
141
|
expect(document_list).to have(0).results
|
@@ -123,6 +145,7 @@ RSpec.describe Blacklight::SearchService do
|
|
123
145
|
|
124
146
|
describe "for Query Without Results and One Facet" do
|
125
147
|
let(:user_params) { { q: no_docs_query, f: single_facet } }
|
148
|
+
|
126
149
|
it 'has no results and not raise error' do
|
127
150
|
(solr_response, document_list) = service.search_results
|
128
151
|
expect(document_list).to have(0).results
|
@@ -140,17 +163,15 @@ RSpec.describe Blacklight::SearchService do
|
|
140
163
|
expect(solr_response.docs).to have(0).results
|
141
164
|
end
|
142
165
|
end
|
143
|
-
end
|
144
|
-
|
166
|
+
end # Search Results
|
145
167
|
|
146
168
|
# SPECS FOR SEARCH RESULTS FOR FACETS
|
147
|
-
describe 'Facets in Search Results for All Docs Query', :
|
148
|
-
|
169
|
+
describe 'Facets in Search Results for All Docs Query', integration: true do
|
149
170
|
let(:blacklight_config) { copy_of_catalog_config }
|
150
171
|
let(:user_params) { { q: all_docs_query } }
|
151
172
|
|
152
173
|
before do
|
153
|
-
(solr_response,
|
174
|
+
(solr_response,) = service.search_results
|
154
175
|
@facets = solr_response.aggregations
|
155
176
|
end
|
156
177
|
|
@@ -159,17 +180,17 @@ RSpec.describe Blacklight::SearchService do
|
|
159
180
|
end
|
160
181
|
it 'has all facets specified in initializer' do
|
161
182
|
expect(@facets.keys).to include *blacklight_config.facet_fields.keys
|
162
|
-
expect(@facets.none? { |
|
183
|
+
expect(@facets.none? { |_k, v| v.nil? }).to eq true
|
163
184
|
end
|
164
185
|
|
165
186
|
it 'has at least one value for each facet' do
|
166
|
-
@facets.each do |
|
187
|
+
@facets.each do |_key, facet|
|
167
188
|
expect(facet.items).to have_at_least(1).hit
|
168
189
|
end
|
169
190
|
end
|
170
191
|
it 'has multiple values for at least one facet' do
|
171
192
|
has_mult_values = false
|
172
|
-
@facets.each do |
|
193
|
+
@facets.each do |_key, facet|
|
173
194
|
if facet.items.size > 1
|
174
195
|
has_mult_values = true
|
175
196
|
break
|
@@ -178,7 +199,7 @@ RSpec.describe Blacklight::SearchService do
|
|
178
199
|
expect(has_mult_values).to eq true
|
179
200
|
end
|
180
201
|
it 'has all value counts > 0' do
|
181
|
-
@facets.each do |
|
202
|
+
@facets.each do |_key, facet|
|
182
203
|
facet.items.each do |facet_vals|
|
183
204
|
expect(facet_vals.hits).to be > 0
|
184
205
|
end
|
@@ -186,14 +207,13 @@ RSpec.describe Blacklight::SearchService do
|
|
186
207
|
end
|
187
208
|
end # facet specs
|
188
209
|
|
189
|
-
|
190
210
|
# SPECS FOR SEARCH RESULTS FOR PAGING
|
191
|
-
describe 'Paging', :
|
211
|
+
describe 'Paging', integration: true do
|
192
212
|
let(:blacklight_config) { copy_of_catalog_config }
|
193
213
|
let(:user_params) { { q: all_docs_query } }
|
194
214
|
|
195
215
|
it 'starts with first results by default' do
|
196
|
-
(solr_response,
|
216
|
+
(solr_response,) = service.search_results
|
197
217
|
expect(solr_response.params[:start].to_i).to eq 0
|
198
218
|
end
|
199
219
|
it 'has number of results (per page) set in initializer, by default' do
|
@@ -205,6 +225,7 @@ RSpec.describe Blacklight::SearchService do
|
|
205
225
|
context "with per page requested" do
|
206
226
|
let(:user_params) { { q: all_docs_query, per_page: num_results } }
|
207
227
|
let(:num_results) { 3 } # non-default value
|
228
|
+
|
208
229
|
it 'gets number of results per page requested' do
|
209
230
|
(solr_response1, document_list1) = service.search_results
|
210
231
|
expect(document_list1).to have(num_results).docs
|
@@ -215,6 +236,7 @@ RSpec.describe Blacklight::SearchService do
|
|
215
236
|
context "with rows requested" do
|
216
237
|
let(:user_params) { { q: all_docs_query, rows: num_results } }
|
217
238
|
let(:num_results) { 4 } # non-default value
|
239
|
+
|
218
240
|
it 'gets number of rows requested' do
|
219
241
|
(solr_response1, document_list1) = service.search_results
|
220
242
|
expect(document_list1).to have(num_results).docs
|
@@ -225,9 +247,10 @@ RSpec.describe Blacklight::SearchService do
|
|
225
247
|
context "with page requested" do
|
226
248
|
let(:user_params) { { q: all_docs_query, page: page } }
|
227
249
|
let(:page) { 3 }
|
250
|
+
|
228
251
|
it 'skips appropriate number of results when requested - default per page' do
|
229
|
-
(solr_response2,
|
230
|
-
expect(solr_response2.params[:start].to_i).to eq
|
252
|
+
(solr_response2,) = service.search_results
|
253
|
+
expect(solr_response2.params[:start].to_i).to eq blacklight_config[:default_solr_params][:rows] * (page - 1)
|
231
254
|
end
|
232
255
|
end
|
233
256
|
|
@@ -235,10 +258,11 @@ RSpec.describe Blacklight::SearchService do
|
|
235
258
|
let(:user_params) { { q: all_docs_query, page: page, per_page: num_results } }
|
236
259
|
let(:page) { 3 }
|
237
260
|
let(:num_results) { 3 } # non-default value
|
261
|
+
|
238
262
|
it 'skips appropriate number of results when requested - non-default per page' do
|
239
263
|
num_results = 3
|
240
|
-
(solr_response2a,
|
241
|
-
expect(solr_response2a.params[:start].to_i).to eq num_results * (page-1)
|
264
|
+
(solr_response2a,) = service.search_results
|
265
|
+
expect(solr_response2a.params[:start].to_i).to eq num_results * (page - 1)
|
242
266
|
end
|
243
267
|
end
|
244
268
|
|
@@ -246,6 +270,7 @@ RSpec.describe Blacklight::SearchService do
|
|
246
270
|
let(:page) { 5000 }
|
247
271
|
let(:rows) { 5000 }
|
248
272
|
let(:user_params) { { q: all_docs_query, page: page, rows: rows } }
|
273
|
+
|
249
274
|
it 'has no results when prompted for page after last result' do
|
250
275
|
(solr_response3, document_list3) = service.search_results
|
251
276
|
expect(document_list3).to have(0).docs
|
@@ -256,10 +281,11 @@ RSpec.describe Blacklight::SearchService do
|
|
256
281
|
context "with negative page" do
|
257
282
|
let(:page) { '-1' }
|
258
283
|
let(:user_params) { { q: all_docs_query, page: page } }
|
284
|
+
|
259
285
|
it 'shows first results when prompted for page before first result' do
|
260
286
|
# FIXME: should it show first results, or should it throw an error for view to deal w?
|
261
287
|
# Solr throws an error for a negative start value
|
262
|
-
(solr_response4,
|
288
|
+
(solr_response4,) = service.search_results
|
263
289
|
expect(solr_response4.params[:start].to_i).to eq 0
|
264
290
|
end
|
265
291
|
end
|
@@ -268,6 +294,7 @@ RSpec.describe Blacklight::SearchService do
|
|
268
294
|
let(:page) { 1 }
|
269
295
|
let(:rows) { 5000 }
|
270
296
|
let(:user_params) { { q: all_docs_query, page: page, rows: rows } }
|
297
|
+
|
271
298
|
it 'has results available when asked for more than are in response' do
|
272
299
|
(solr_response5, document_list5) = service.search_results
|
273
300
|
expect(solr_response5.docs).to have(document_list5.length).docs
|
@@ -277,7 +304,7 @@ RSpec.describe Blacklight::SearchService do
|
|
277
304
|
end # page specs
|
278
305
|
|
279
306
|
# SPECS FOR SINGLE DOCUMENT REQUESTS
|
280
|
-
describe 'Get Document By Id', :
|
307
|
+
describe 'Get Document By Id', integration: true do
|
281
308
|
let(:doc_id) { '2007020969' }
|
282
309
|
let(:bad_id) { 'redrum' }
|
283
310
|
|
@@ -286,15 +313,9 @@ RSpec.describe Blacklight::SearchService do
|
|
286
313
|
end
|
287
314
|
|
288
315
|
it "raises Blacklight::RecordNotFound for an unknown id" do
|
289
|
-
expect
|
316
|
+
expect do
|
290
317
|
service.fetch(bad_id)
|
291
|
-
|
292
|
-
end
|
293
|
-
|
294
|
-
it "uses a provided document solr path" do
|
295
|
-
allow(blacklight_config).to receive_messages(document_solr_path: 'get')
|
296
|
-
allow(blacklight_solr).to receive(:send_and_receive).with('get', kind_of(Hash)).and_return({'response'=>{'docs'=>[]}})
|
297
|
-
expect { service.fetch(doc_id)}.to raise_error Blacklight::Exceptions::RecordNotFound
|
318
|
+
end.to raise_error(Blacklight::Exceptions::RecordNotFound)
|
298
319
|
end
|
299
320
|
|
300
321
|
it "has a non-nil result for a known id" do
|
@@ -311,66 +332,86 @@ RSpec.describe Blacklight::SearchService do
|
|
311
332
|
end
|
312
333
|
end
|
313
334
|
|
314
|
-
|
315
|
-
|
335
|
+
describe 'Get multiple documents By Id', integration: true do
|
336
|
+
let(:doc_id) { '2007020969' }
|
337
|
+
let(:bad_id) { 'redrum' }
|
338
|
+
let(:response) { service.fetch([doc_id]).first }
|
339
|
+
|
340
|
+
before do
|
341
|
+
blacklight_config.fetch_many_document_params[:fl] = 'id,format'
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'has the expected value in the id field' do
|
345
|
+
expect(response.documents.first.id).to eq doc_id
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'returns all the requested fields' do
|
349
|
+
expect(response.documents.first['format']).to eq ['Book']
|
350
|
+
end
|
351
|
+
end
|
316
352
|
|
353
|
+
# SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
|
354
|
+
describe "Searches should return spelling suggestions", integration: true do
|
317
355
|
context "for just-poor-enough-query term" do
|
318
356
|
let(:user_params) { { q: 'boo' } }
|
357
|
+
|
319
358
|
it 'has (multiple) spelling suggestions' do
|
320
|
-
(solr_response,
|
359
|
+
(solr_response,) = service.search_results
|
321
360
|
expect(solr_response.spelling.words).to include('bon')
|
322
|
-
expect(solr_response.spelling.words).to include('bod')
|
361
|
+
expect(solr_response.spelling.words).to include('bod') # for multiple suggestions
|
323
362
|
end
|
324
363
|
end
|
325
364
|
|
326
365
|
context "for another just-poor-enough-query term" do
|
327
366
|
let(:user_params) { { q: 'politica' } }
|
367
|
+
|
328
368
|
it 'has multiple spelling suggestions' do
|
329
|
-
(solr_response,
|
369
|
+
(solr_response,) = service.search_results
|
330
370
|
expect(solr_response.spelling.words).to include('policy') # less freq
|
331
371
|
expect(solr_response.spelling.words).to include('politics') # more freq
|
332
372
|
expect(solr_response.spelling.words).to include('political') # more freq
|
333
|
-
|
334
|
-
#
|
335
|
-
|
336
|
-
solr_response.spelling.words).to include('
|
337
|
-
solr_response.spelling.words).to include('political') # more freq
|
338
|
-
=end
|
373
|
+
# # when we can have multiple suggestions
|
374
|
+
# expect(solr_response.spelling.words).to_not include('policy') # less freq
|
375
|
+
# solr_response.spelling.words).to include('politics') # more freq
|
376
|
+
# solr_response.spelling.words).to include('political') # more freq
|
339
377
|
end
|
340
378
|
end
|
341
379
|
|
342
380
|
context "for title search" do
|
343
|
-
let(:user_params) { { q: 'yehudiyam', qt: 'search',
|
381
|
+
let(:user_params) { { q: 'yehudiyam', qt: 'search', "spellcheck.dictionary": "title" } }
|
382
|
+
|
344
383
|
it 'has spelling suggestions' do
|
345
|
-
(solr_response,
|
384
|
+
(solr_response,) = service.search_results
|
346
385
|
expect(solr_response.spelling.words).to include('yehudiyim')
|
347
386
|
end
|
348
387
|
end
|
349
388
|
|
350
389
|
context "for author search" do
|
351
|
-
let(:user_params) { { q: 'shirma', qt: 'search',
|
390
|
+
let(:user_params) { { q: 'shirma', qt: 'search', "spellcheck.dictionary": "author" } }
|
391
|
+
|
352
392
|
it 'has spelling suggestions' do
|
353
|
-
(solr_response,
|
393
|
+
(solr_response,) = service.search_results
|
354
394
|
expect(solr_response.spelling.words).to include('sharma')
|
355
395
|
end
|
356
396
|
end
|
357
397
|
|
358
398
|
context "for subject search" do
|
359
|
-
let(:user_params) { { q: 'wome', qt: 'search',
|
399
|
+
let(:user_params) { { q: 'wome', qt: 'search', "spellcheck.dictionary": "subject" } }
|
400
|
+
|
360
401
|
it 'has spelling suggestions' do
|
361
|
-
(solr_response,
|
402
|
+
(solr_response,) = service.search_results
|
362
403
|
expect(solr_response.spelling.words).to include('women')
|
363
404
|
end
|
364
405
|
end
|
365
406
|
end
|
366
407
|
|
367
|
-
# TODO: more complex queries! phrases, offset into search results, non-latin, boosting(?)
|
368
|
-
# search within query building (?)
|
369
|
-
# search + facets (search done first; facet selected first, both selected)
|
408
|
+
# TODO: more complex queries! phrases, offset into search results, non-latin, boosting(?)
|
409
|
+
# search within query building (?)
|
410
|
+
# search + facets (search done first; facet selected first, both selected)
|
370
411
|
|
371
|
-
# TODO: maybe eventually check other types of solr requests
|
372
|
-
# more like this
|
373
|
-
# nearby on shelf
|
412
|
+
# TODO: maybe eventually check other types of solr requests
|
413
|
+
# more like this
|
414
|
+
# nearby on shelf
|
374
415
|
it "raises a Blacklight exception if RSolr can't connect to the Solr instance" do
|
375
416
|
allow(blacklight_solr).to receive(:send_and_receive).and_raise(Errno::ECONNREFUSED)
|
376
417
|
expect { service.repository.search }.to raise_exception(/Unable to connect to Solr instance/)
|
@@ -378,45 +419,46 @@ RSpec.describe Blacklight::SearchService do
|
|
378
419
|
|
379
420
|
describe "#previous_and_next_documents_for_search" do
|
380
421
|
let(:user_params) { { q: '', per_page: 100 } }
|
422
|
+
|
381
423
|
before do
|
382
424
|
@full_response, @all_docs = service.search_results
|
383
425
|
end
|
384
426
|
|
385
427
|
it "returns the previous and next documents for a search" do
|
386
|
-
|
428
|
+
_response, docs = service.previous_and_next_documents_for_search(4, q: '')
|
387
429
|
|
388
430
|
expect(docs.first.id).to eq @all_docs[3].id
|
389
431
|
expect(docs.last.id).to eq @all_docs[5].id
|
390
432
|
end
|
391
433
|
|
392
434
|
it "returns only the next document if the counter is 0" do
|
393
|
-
|
435
|
+
_response, docs = service.previous_and_next_documents_for_search(0, q: '')
|
394
436
|
|
395
437
|
expect(docs.first).to be_nil
|
396
438
|
expect(docs.last.id).to eq @all_docs[1].id
|
397
439
|
end
|
398
440
|
|
399
441
|
it "returns only the previous document if the counter is the total number of documents" do
|
400
|
-
|
442
|
+
_response, docs = service.previous_and_next_documents_for_search(@full_response.total - 1, q: '')
|
401
443
|
expect(docs.first.id).to eq @all_docs.slice(-2).id
|
402
444
|
expect(docs.last).to be_nil
|
403
445
|
end
|
404
446
|
|
405
447
|
it "returns an array of nil values if there is only one result" do
|
406
|
-
|
448
|
+
_response, docs = service.previous_and_next_documents_for_search(0, q: 'id:2007020969')
|
407
449
|
expect(docs.last).to be_nil
|
408
450
|
expect(docs.first).to be_nil
|
409
451
|
end
|
410
452
|
|
411
453
|
it 'returns only the unique key by default' do
|
412
|
-
|
454
|
+
_response, docs = service.previous_and_next_documents_for_search(0, q: '')
|
413
455
|
expect(docs.last.to_h).to eq 'id' => @all_docs[1].id
|
414
456
|
end
|
415
457
|
|
416
458
|
it 'allows the query parameters to be customized using configuration' do
|
417
459
|
blacklight_config.document_pagination_params[:fl] = 'id,format'
|
418
460
|
|
419
|
-
|
461
|
+
_response, docs = service.previous_and_next_documents_for_search(0, q: '')
|
420
462
|
|
421
463
|
expect(docs.last.to_h).to eq @all_docs[1].to_h.slice('id', 'format')
|
422
464
|
end
|
@@ -424,11 +466,11 @@ RSpec.describe Blacklight::SearchService do
|
|
424
466
|
|
425
467
|
describe '#opensearch_response' do
|
426
468
|
let(:user_params) { { q: 'Book' } }
|
427
|
-
let(:mock_response)
|
469
|
+
let(:mock_response) do
|
428
470
|
instance_double(Blacklight::Solr::Response, documents: [
|
429
|
-
|
430
|
-
|
431
|
-
|
471
|
+
{ field: 'A' }, { field: 'B' }, { field: 'C' }
|
472
|
+
])
|
473
|
+
end
|
432
474
|
|
433
475
|
before do
|
434
476
|
blacklight_config.view.opensearch.title_field = :field
|
@@ -440,7 +482,7 @@ RSpec.describe Blacklight::SearchService do
|
|
440
482
|
end
|
441
483
|
|
442
484
|
it 'contains the search suggestions as the second element in the response' do
|
443
|
-
expect(service.opensearch_response.last).to match_array %w
|
485
|
+
expect(service.opensearch_response.last).to match_array %w[A B C]
|
444
486
|
end
|
445
487
|
end
|
446
488
|
end
|