blacklight 8.2.2 → 8.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/.github/workflows/ruby.yml +60 -62
- data/.rubocop.yml +229 -21
- data/.rubocop_todo.yml +22 -55
- data/Gemfile +2 -10
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +5 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +5 -1
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +30 -0
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -4
- data/app/assets/stylesheets/blacklight/_constraints.scss +15 -9
- data/app/assets/stylesheets/blacklight/_controls.scss +0 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +33 -37
- data/app/assets/stylesheets/blacklight/_header.scss +2 -35
- data/app/assets/stylesheets/blacklight/_icons.scss +3 -2
- data/app/assets/stylesheets/blacklight/_layout.scss +3 -0
- data/app/assets/stylesheets/blacklight/_mixins.scss +6 -21
- data/app/assets/stylesheets/blacklight/_search_form.scss +3 -8
- data/app/assets/stylesheets/blacklight/_search_history.scss +5 -5
- data/app/assets/stylesheets/blacklight/_search_results.scss +5 -2
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +16 -10
- data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +6 -0
- data/app/components/blacklight/constraint_layout_component.html.erb +2 -9
- data/app/components/blacklight/constraint_layout_component.rb +8 -0
- data/app/components/blacklight/constraints_component.rb +3 -3
- data/app/components/blacklight/document/action_component.rb +2 -1
- data/app/components/blacklight/document/bookmark_component.html.erb +2 -1
- data/app/components/blacklight/document/bookmark_component.rb +6 -0
- data/app/components/blacklight/document/page_header_component.html.erb +7 -0
- data/app/components/blacklight/document/page_header_component.rb +85 -0
- data/app/components/blacklight/document_component.rb +1 -1
- data/app/components/blacklight/facet_component.rb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
- data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +1 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
- data/app/components/blacklight/facet_item_component.rb +1 -1
- data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
- data/app/components/blacklight/icons/bookmark_icon_component.rb +17 -0
- data/app/components/blacklight/icons/icon_component.rb +9 -4
- data/app/components/blacklight/icons/remove_component.rb +16 -0
- data/app/components/blacklight/metadata_field_component.html.erb +1 -1
- data/app/components/blacklight/metadata_field_component.rb +5 -0
- data/app/components/blacklight/response/facet_group_component.rb +1 -1
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/sort_component.html.erb +1 -6
- data/app/components/blacklight/response/sort_component.rb +15 -0
- data/app/components/blacklight/search/per_page_component.html.erb +2 -0
- data/app/components/blacklight/search/per_page_component.rb +50 -0
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/components/blacklight/search_context/server_item_pagination_component.html.erb +4 -7
- data/app/components/blacklight/skip_link_component.html.erb +7 -0
- data/app/components/blacklight/skip_link_component.rb +17 -0
- data/app/components/blacklight/system/dropdown_button_component.rb +18 -0
- data/app/components/blacklight/system/dropdown_component.rb +4 -7
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/top_navbar_component.html.erb +2 -2
- data/app/components/blacklight/top_navbar_component.rb +4 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -5
- data/app/helpers/blacklight/component_helper_behavior.rb +4 -4
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
- data/app/javascript/blacklight/checkbox_submit.js +5 -1
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -1
- data/app/presenters/blacklight/facet_checkbox_item_presenter.rb +11 -0
- data/app/presenters/blacklight/facet_field_presenter.rb +9 -1
- data/app/services/blacklight/search_service.rb +9 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -10
- data/app/views/catalog/_search_results.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +1 -1
- data/app/views/catalog/show.html.erb +0 -2
- data/app/views/catalog/suggest.html.erb +1 -1
- data/app/views/kaminari/blacklight/_page.html.erb +14 -8
- data/app/views/layouts/blacklight/base.html.erb +3 -4
- data/app/views/shared/_flash_messages.html.erb +1 -1
- data/blacklight.gemspec +4 -0
- data/{docker-compose.yml → compose.yaml} +1 -1
- data/config/locales/blacklight.ar.yml +3 -0
- data/config/locales/blacklight.de.yml +3 -0
- data/config/locales/blacklight.en.yml +216 -229
- data/config/locales/blacklight.es.yml +3 -0
- data/config/locales/blacklight.fr.yml +3 -0
- data/config/locales/blacklight.hu.yml +3 -0
- data/config/locales/blacklight.it.yml +3 -0
- data/config/locales/blacklight.nl.yml +3 -0
- data/config/locales/blacklight.pt-BR.yml +3 -0
- data/config/locales/blacklight.sq.yml +3 -0
- data/config/locales/blacklight.zh.yml +3 -0
- data/lib/blacklight/abstract_repository.rb +6 -0
- data/lib/blacklight/configuration.rb +33 -19
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +2 -2
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/solr/repository.rb +11 -4
- data/lib/blacklight/solr/request.rb +1 -1
- data/lib/blacklight/solr/response/facets.rb +1 -1
- data/lib/blacklight/solr/response/params.rb +1 -1
- data/lib/blacklight/solr/response.rb +0 -12
- data/lib/blacklight/solr/search_builder_behavior.rb +2 -2
- data/lib/blacklight/solr.rb +0 -6
- data/lib/blacklight.rb +4 -14
- data/lib/generators/blacklight/assets/propshaft_generator.rb +2 -2
- data/lib/generators/blacklight/models_generator.rb +1 -1
- data/package.json +1 -1
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +2 -2
- data/spec/components/blacklight/constraint_layout_component_spec.rb +11 -11
- data/spec/components/blacklight/constraints_component_spec.rb +9 -9
- data/spec/components/blacklight/document/action_component_spec.rb +1 -1
- data/spec/components/blacklight/document/group_component_spec.rb +3 -3
- data/spec/components/blacklight/document/page_header_component_spec.rb +92 -0
- data/spec/components/blacklight/document/sidebar_component_spec.rb +3 -4
- data/spec/components/blacklight/document_component_spec.rb +41 -25
- data/spec/components/blacklight/facet_component_spec.rb +2 -2
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +5 -5
- data/spec/components/blacklight/facet_field_list_component_spec.rb +13 -13
- data/spec/components/blacklight/facet_item_component_spec.rb +5 -5
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +6 -6
- data/spec/components/blacklight/header_component_spec.rb +1 -2
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +6 -6
- data/spec/components/blacklight/icons/icon_component_spec.rb +42 -0
- data/spec/components/blacklight/metadata_field_component_spec.rb +3 -3
- data/spec/components/blacklight/response/pagination_component_spec.rb +4 -4
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +2 -4
- data/spec/components/blacklight/system/flash_message_component_spec.rb +5 -5
- data/spec/controllers/blacklight/catalog_spec.rb +2 -2
- data/spec/controllers/blacklight/{catalog/component_configuration_spec.rb → configurable_spec.rb} +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +10 -10
- data/spec/controllers/catalog_controller_spec.rb +29 -31
- data/spec/features/advanced_search_spec.rb +30 -16
- data/spec/features/alternate_controller_spec.rb +9 -9
- data/spec/features/axe_spec.rb +4 -4
- data/spec/features/bookmarks_spec.rb +34 -19
- data/spec/features/citation_spec.rb +1 -1
- data/spec/features/did_you_mean_spec.rb +23 -23
- data/spec/features/facet_missing_spec.rb +9 -9
- data/spec/features/facets_spec.rb +21 -20
- data/spec/features/modal_spec.rb +4 -4
- data/spec/features/record_view_spec.rb +2 -2
- data/spec/features/search_context_spec.rb +6 -6
- data/spec/features/search_crawler_spec.rb +5 -5
- data/spec/features/search_filters_spec.rb +65 -65
- data/spec/features/search_history_spec.rb +12 -12
- data/spec/features/search_pagination_spec.rb +10 -10
- data/spec/features/search_results_spec.rb +1 -1
- data/spec/features/search_sort_spec.rb +4 -4
- data/spec/features/search_spec.rb +25 -25
- data/spec/features/sitelinks_search_box_spec.rb +2 -2
- data/spec/features/sms_spec.rb +1 -1
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +2 -2
- data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +2 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -8
- data/spec/helpers/blacklight_helper_spec.rb +13 -15
- data/spec/helpers/catalog_helper_spec.rb +3 -6
- data/spec/i18n_spec.rb +2 -1
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +1 -1
- data/spec/lib/blacklight/search_state_spec.rb +4 -4
- data/spec/lib/tasks/blacklight_task_spec.rb +2 -1
- data/spec/models/blacklight/configurable_spec.rb +1 -1
- data/spec/models/blacklight/configuration/context_spec.rb +1 -1
- data/spec/models/blacklight/configuration_spec.rb +14 -14
- data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -1
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -1
- data/spec/models/blacklight/document_spec.rb +1 -1
- data/spec/models/blacklight/facet_paginator_spec.rb +14 -14
- data/spec/models/blacklight/icon_spec.rb +1 -1
- data/spec/models/blacklight/search_builder_spec.rb +1 -1
- data/spec/models/blacklight/solr/document_spec.rb +3 -3
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -1
- data/spec/models/blacklight/solr/repository_spec.rb +33 -15
- data/spec/models/blacklight/solr/request_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/facets_spec.rb +3 -3
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_spec.rb +2 -2
- data/spec/models/blacklight/solr/response_spec.rb +3 -3
- data/spec/models/blacklight/solr/{search_builder_spec.rb → search_builder_behavior_spec.rb} +10 -20
- data/spec/models/blacklight/suggest/response_spec.rb +1 -1
- data/spec/models/blacklight/suggest_search_spec.rb +1 -1
- data/spec/models/blacklight/user_spec.rb +1 -1
- data/spec/models/bookmark_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +1 -1
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -4
- data/spec/presenters/blacklight/facet_checkbox_item_presenter_spec.rb +42 -0
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +14 -0
- data/spec/presenters/blacklight/field_presenter_spec.rb +1 -1
- data/spec/presenters/blacklight/index_presenter_spec.rb +2 -3
- data/spec/presenters/blacklight/json_presenter_spec.rb +1 -1
- data/spec/presenters/{pipeline_spec.rb → blacklight/rendering/pipeline_spec.rb} +1 -1
- data/spec/presenters/blacklight/show_presenter_spec.rb +5 -6
- data/spec/presenters/{thumbnail_presenter_spec.rb → blacklight/thumbnail_presenter_spec.rb} +5 -3
- data/spec/requests/load_suggestions_spec.rb +5 -5
- data/spec/routing/catalog_routing_spec.rb +1 -1
- data/spec/services/blacklight/field_retriever_spec.rb +1 -1
- data/spec/services/blacklight/search_service_spec.rb +11 -11
- data/spec/spec_helper.rb +2 -2
- data/spec/support/features/search_helpers.rb +2 -2
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +3 -3
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -4
- data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -6
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -2
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -7
- data/spec/views/catalog/email_success.html.erb_spec.rb +1 -1
- data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -1
- data/spec/views/catalog/index.atom.builder_spec.rb +18 -19
- data/spec/views/catalog/index.html.erb_spec.rb +2 -4
- data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -8
- data/spec/views/catalog/show.html.erb_spec.rb +3 -5
- data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -2
- data/spec/views/catalog/sms_success.html.erb_spec.rb +1 -1
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +2 -3
- data/tasks/blacklight.rake +5 -5
- metadata +84 -12
@@ -11,8 +11,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
11
11
|
let(:parameter_class) { ActionController::Parameters }
|
12
12
|
|
13
13
|
before do
|
14
|
-
allow(controller).to
|
15
|
-
allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
|
14
|
+
allow(controller).to receive_messages(controller_name: 'test', search_state_class: Blacklight::SearchState)
|
16
15
|
allow(helper).to receive(:search_action_path) do |*args|
|
17
16
|
search_catalog_url *args
|
18
17
|
end
|
@@ -112,18 +111,18 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
112
111
|
end
|
113
112
|
|
114
113
|
it "consists of the document title wrapped in a <a>" do
|
115
|
-
expect(helper.link_to_document(document)).to
|
114
|
+
expect(helper.link_to_document(document)).to have_css("a", text: '654321', count: 1)
|
116
115
|
end
|
117
116
|
|
118
117
|
it "accepts and returns a string label" do
|
119
|
-
expect(helper.link_to_document(document, 'This is the title')).to
|
118
|
+
expect(helper.link_to_document(document, 'This is the title')).to have_css("a", text: 'This is the title', count: 1)
|
120
119
|
end
|
121
120
|
|
122
121
|
context 'when label is missing' do
|
123
122
|
let(:data) { { 'id' => id } }
|
124
123
|
|
125
124
|
it "returns id" do
|
126
|
-
expect(helper.link_to_document(document)).to
|
125
|
+
expect(helper.link_to_document(document)).to have_css("a", text: '123456', count: 1)
|
127
126
|
end
|
128
127
|
|
129
128
|
it "is html safe" do
|
@@ -142,7 +141,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
142
141
|
let(:id) { 123_456 }
|
143
142
|
|
144
143
|
it "has a link" do
|
145
|
-
expect(helper.link_to_document(document)).to
|
144
|
+
expect(helper.link_to_document(document)).to have_css("a")
|
146
145
|
end
|
147
146
|
end
|
148
147
|
end
|
@@ -154,14 +153,14 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
154
153
|
|
155
154
|
it "includes the data- attributes from the options" do
|
156
155
|
link = helper.link_to_document document, data: { x: 1 }
|
157
|
-
expect(link).to
|
156
|
+
expect(link).to have_css '[data-x]'
|
158
157
|
end
|
159
158
|
|
160
159
|
it 'adds a controller-specific tracking attribute' do
|
161
160
|
expect(helper.main_app).to receive(:track_test_path).and_return('/asdf')
|
162
161
|
link = helper.link_to_document document, data: { x: 1 }
|
163
162
|
|
164
|
-
expect(link).to
|
163
|
+
expect(link).to have_css '[data-context-href="/asdf"]'
|
165
164
|
end
|
166
165
|
end
|
167
166
|
|
@@ -73,8 +73,7 @@ RSpec.describe BlacklightHelper do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
before do
|
76
|
-
allow(helper).to
|
77
|
-
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
76
|
+
allow(helper).to receive_messages(document_presenter: presenter, blacklight_config: blacklight_config)
|
78
77
|
end
|
79
78
|
|
80
79
|
it "generates <link rel=alternate> tags" do
|
@@ -109,8 +108,8 @@ RSpec.describe BlacklightHelper do
|
|
109
108
|
it "renders partials" do
|
110
109
|
buff = String.new
|
111
110
|
helper.render_nav_actions { |_config, item| buff << "<foo>#{item}</foo>" }
|
112
|
-
expect(buff).to
|
113
|
-
expect(buff).to
|
111
|
+
expect(buff).to have_css "foo a#bookmarks_nav[href=\"/bookmarks\"]"
|
112
|
+
expect(buff).to have_css "foo a span[data-role='bookmark-counter']", text: '0'
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
@@ -118,7 +117,7 @@ RSpec.describe BlacklightHelper do
|
|
118
117
|
it "renders partials" do
|
119
118
|
allow(controller).to receive(:render_bookmarks_control?).and_return(true)
|
120
119
|
response = helper.render_index_doc_actions(document)
|
121
|
-
expect(response).to
|
120
|
+
expect(response).to have_css(".bookmark-toggle")
|
122
121
|
end
|
123
122
|
|
124
123
|
it "is nil if no partials are renderable" do
|
@@ -138,27 +137,28 @@ RSpec.describe BlacklightHelper do
|
|
138
137
|
subject { helper.opensearch_description_tag 'title', 'href' }
|
139
138
|
|
140
139
|
it "has a search rel" do
|
141
|
-
expect(subject).to
|
140
|
+
expect(subject).to have_css "link[rel='search']", visible: false
|
142
141
|
end
|
143
142
|
|
144
143
|
it "has the correct mime type" do
|
145
|
-
expect(subject).to
|
144
|
+
expect(subject).to have_css "link[type='application/opensearchdescription+xml']", visible: false
|
146
145
|
end
|
147
146
|
|
148
147
|
it "has a title attribute" do
|
149
|
-
expect(subject).to
|
148
|
+
expect(subject).to have_css "link[title='title']", visible: false
|
150
149
|
end
|
151
150
|
|
152
151
|
it "has an href attribute" do
|
153
|
-
expect(subject).to
|
152
|
+
expect(subject).to have_css "link[href='href']", visible: false
|
154
153
|
end
|
155
154
|
end
|
156
155
|
|
157
156
|
describe "#render_document_index" do
|
158
157
|
it "renders the document index with the current view type" do
|
159
158
|
allow(helper).to receive_messages(document_index_view_type: :current_view)
|
160
|
-
allow(helper).to receive(:render_document_index_with_view)
|
159
|
+
allow(helper).to receive(:render_document_index_with_view)
|
161
160
|
helper.render_document_index [], a: 1, b: 2
|
161
|
+
expect(helper).to have_received(:render_document_index_with_view).with(:current_view, [], { a: 1, b: 2 })
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -167,17 +167,15 @@ RSpec.describe BlacklightHelper do
|
|
167
167
|
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
168
168
|
|
169
169
|
before do
|
170
|
-
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
171
170
|
assign(:response, instance_double(Blacklight::Solr::Response, grouped?: false, start: 0))
|
172
|
-
allow(helper).to
|
173
|
-
allow(helper).to receive(:render_index_doc_actions).and_return('<div/>')
|
171
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config, link_to_document: '<a/>', render_index_doc_actions: '<div/>')
|
174
172
|
end
|
175
173
|
|
176
174
|
it "ignores missing templates" do
|
177
175
|
blacklight_config.view.view_type(partials: %w[index_header a b])
|
178
176
|
|
179
177
|
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
180
|
-
expect(response).to
|
178
|
+
expect(response).to have_css "div#documents"
|
181
179
|
end
|
182
180
|
|
183
181
|
context 'with a template partial provided by the view config' do
|
@@ -191,7 +189,7 @@ RSpec.describe BlacklightHelper do
|
|
191
189
|
# https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
|
192
190
|
# https://github.com/rspec/rspec-rails/issues/2696
|
193
191
|
replace_hash = { 'my/_partial.html.erb' => 'some content' }
|
194
|
-
if
|
192
|
+
if Rails.version.to_f >= 7.1
|
195
193
|
controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
196
194
|
else
|
197
195
|
view.view_paths.unshift(ActionView::FixtureResolver.new(replace_hash))
|
@@ -267,8 +267,7 @@ RSpec.describe CatalogHelper do
|
|
267
267
|
subject { helper.render_search_to_page_title(Blacklight::SearchState.new(params, blacklight_config)) }
|
268
268
|
|
269
269
|
before do
|
270
|
-
allow(helper).to
|
271
|
-
allow(helper).to receive(:default_search_field).and_return(Blacklight::Configuration::SearchField.new(key: 'default_search_field', display_label: 'Default'))
|
270
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config, default_search_field: Blacklight::Configuration::SearchField.new(key: 'default_search_field', display_label: 'Default'))
|
272
271
|
allow(helper).to receive(:label_for_search_field).with(nil).and_return('')
|
273
272
|
end
|
274
273
|
|
@@ -299,8 +298,7 @@ RSpec.describe CatalogHelper do
|
|
299
298
|
|
300
299
|
describe "#document_index_view_type" do
|
301
300
|
it "defaults to the default view" do
|
302
|
-
allow(helper).to
|
303
|
-
allow(helper).to receive(:default_document_index_view_type).and_return(:xyz)
|
301
|
+
allow(helper).to receive_messages(document_index_views: { a: 1, b: 2 }, default_document_index_view_type: :xyz)
|
304
302
|
expect(helper.document_index_view_type).to eq :xyz
|
305
303
|
end
|
306
304
|
|
@@ -310,8 +308,7 @@ RSpec.describe CatalogHelper do
|
|
310
308
|
end
|
311
309
|
|
312
310
|
it "uses the default view if the requested view is not available" do
|
313
|
-
allow(helper).to
|
314
|
-
allow(helper).to receive(:document_index_views).and_return(a: 1, b: 2)
|
311
|
+
allow(helper).to receive_messages(default_document_index_view_type: :xyz, document_index_views: { a: 1, b: 2 })
|
315
312
|
expect(helper.document_index_view_type(view: :c)).to eq :xyz
|
316
313
|
end
|
317
314
|
|
data/spec/i18n_spec.rb
CHANGED
@@ -12,7 +12,8 @@ RSpec.describe 'I18n', type: :i18n do
|
|
12
12
|
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
it 'does not have unused keys' do
|
16
|
+
pending 'Many unused keys are detected'
|
16
17
|
expect(unused_keys).to be_empty,
|
17
18
|
"#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
|
18
19
|
end
|
@@ -23,7 +23,7 @@ RSpec.describe Blacklight::NestedOpenStructWithHashAccess do
|
|
23
23
|
|
24
24
|
describe "#deep_dup" do
|
25
25
|
it "preserves the current class" do
|
26
|
-
expect(described_class.new(described_class).deep_dup).to
|
26
|
+
expect(described_class.new(described_class).deep_dup).to be_a described_class
|
27
27
|
end
|
28
28
|
|
29
29
|
it "preserves the default proc" do
|
@@ -37,7 +37,7 @@ RSpec.describe Blacklight::SearchState do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'with HashWithIndifferentAccess' do
|
40
|
-
let(:parameter_class) { HashWithIndifferentAccess }
|
40
|
+
let(:parameter_class) { ActiveSupport::HashWithIndifferentAccess }
|
41
41
|
|
42
42
|
it 'returns the hash data' do
|
43
43
|
expect(search_state.to_h).to eq data.with_indifferent_access
|
@@ -356,7 +356,7 @@ RSpec.describe Blacklight::SearchState do
|
|
356
356
|
end
|
357
357
|
|
358
358
|
describe "#url_for_document" do
|
359
|
-
let(:controller_class) {
|
359
|
+
let(:controller_class) { CatalogController.new }
|
360
360
|
let(:doc) { SolrDocument.new }
|
361
361
|
|
362
362
|
before do
|
@@ -375,7 +375,7 @@ RSpec.describe Blacklight::SearchState do
|
|
375
375
|
end
|
376
376
|
|
377
377
|
context "within bookmarks" do
|
378
|
-
let(:controller_class) {
|
378
|
+
let(:controller_class) { BookmarksController.new }
|
379
379
|
|
380
380
|
it "uses polymorphic routing" do
|
381
381
|
expect(search_state.url_for_document(doc)).to eq doc
|
@@ -383,7 +383,7 @@ RSpec.describe Blacklight::SearchState do
|
|
383
383
|
end
|
384
384
|
|
385
385
|
context "within an alternative catalog controller" do
|
386
|
-
let(:controller_class) {
|
386
|
+
let(:controller_class) { AlternateController.new }
|
387
387
|
|
388
388
|
before do
|
389
389
|
search_state.blacklight_config.show.route = { controller: :current }
|
@@ -13,7 +13,8 @@ RSpec.describe "blacklight:delete_old_searches" do
|
|
13
13
|
|
14
14
|
it "calls Search.delete_old_searches" do
|
15
15
|
days_old = 7
|
16
|
-
allow(Search).to receive(:delete_old_searches)
|
16
|
+
allow(Search).to receive(:delete_old_searches)
|
17
17
|
@rake[@task_name].invoke(days_old)
|
18
|
+
expect(Search).to have_received(:delete_old_searches).with(days_old)
|
18
19
|
end
|
19
20
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe "Blacklight::Configuration", api
|
3
|
+
RSpec.describe "Blacklight::Configuration", :api do
|
4
4
|
let(:config) do
|
5
5
|
Blacklight::Configuration.new
|
6
6
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
14
14
|
|
15
15
|
describe "initialization" do
|
16
16
|
it "is an OpenStructWithHashAccess" do
|
17
|
-
expect(config).to
|
17
|
+
expect(config).to be_a Blacklight::OpenStructWithHashAccess
|
18
18
|
end
|
19
19
|
|
20
20
|
it "accepts a block for configuration" do
|
@@ -30,22 +30,22 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
30
30
|
|
31
31
|
describe "defaults" do
|
32
32
|
it "has a hash of default rsolr query parameters" do
|
33
|
-
expect(config.default_solr_params).to
|
33
|
+
expect(config.default_solr_params).to be_a Hash
|
34
34
|
end
|
35
35
|
|
36
36
|
it "has openstruct values for show and index parameters" do
|
37
|
-
expect(config.show).to
|
38
|
-
expect(config.index).to
|
37
|
+
expect(config.show).to be_a OpenStruct
|
38
|
+
expect(config.index).to be_a OpenStruct
|
39
39
|
end
|
40
40
|
|
41
41
|
it "has ordered hashes for field configuration" do
|
42
|
-
expect(config.facet_fields).to
|
43
|
-
expect(config.index_fields).to
|
44
|
-
expect(config.show_fields).to
|
45
|
-
expect(config.search_fields).to
|
46
|
-
expect(config.show_fields).to
|
47
|
-
expect(config.search_fields).to
|
48
|
-
expect(config.sort_fields).to
|
42
|
+
expect(config.facet_fields).to be_a Hash
|
43
|
+
expect(config.index_fields).to be_a Hash
|
44
|
+
expect(config.show_fields).to be_a Hash
|
45
|
+
expect(config.search_fields).to be_a Hash
|
46
|
+
expect(config.show_fields).to be_a Hash
|
47
|
+
expect(config.search_fields).to be_a Hash
|
48
|
+
expect(config.sort_fields).to be_a Hash
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -197,7 +197,7 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
197
197
|
config.add_my_custom_facet_field 'qwerty', label: "asdf"
|
198
198
|
end
|
199
199
|
|
200
|
-
expect(config.my_custom_facet_fields['qwerty']).to
|
200
|
+
expect(config.my_custom_facet_fields['qwerty']).to be_a(Blacklight::Configuration::FacetField)
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
@@ -352,7 +352,7 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
352
352
|
expect(config.index_fields.keys).to eq %w[some_field_display another_field_display]
|
353
353
|
end
|
354
354
|
|
355
|
-
it "queries solr and get live values for match fields", integration
|
355
|
+
it "queries solr and get live values for match fields", :integration do
|
356
356
|
config.add_index_field match: /title.+sim/
|
357
357
|
expect(config.index_fields.keys).to include "subtitle_tsim", "subtitle_vern_ssim", "title_tsim", "title_vern_ssim"
|
358
358
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe 'Blacklight::Document::ActiveModelShim', api
|
3
|
+
RSpec.describe 'Blacklight::Document::ActiveModelShim', :api do
|
4
4
|
class MockDocument
|
5
5
|
include Blacklight::Document
|
6
6
|
include Blacklight::Document::ActiveModelShim
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Blacklight::FacetPaginator, api
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:
|
8
|
-
let(:
|
9
|
-
let(:
|
10
|
-
let(:
|
11
|
-
let(:seven_facet_values) { [
|
12
|
-
let(:six_facet_values) { [
|
3
|
+
RSpec.describe Blacklight::FacetPaginator, :api do
|
4
|
+
let(:book) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
|
5
|
+
let(:musical_score) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') }
|
6
|
+
let(:serial) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '58', value: 'Serial') }
|
7
|
+
let(:musical_recording) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '48', value: 'Musical Recording') }
|
8
|
+
let(:microform) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '37', value: 'Microform') }
|
9
|
+
let(:thesis) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '27', value: 'Thesis') }
|
10
|
+
let(:blank) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '0') }
|
11
|
+
let(:seven_facet_values) { [book, musical_score, serial, musical_recording, microform, thesis, blank] }
|
12
|
+
let(:six_facet_values) { [book, musical_score, serial, musical_recording, microform, thesis] }
|
13
13
|
let(:limit) { 6 }
|
14
14
|
|
15
15
|
context 'on the first page of two pages' do
|
@@ -42,7 +42,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'on the last page of two pages' do
|
45
|
-
subject(:paginator) { described_class.new([
|
45
|
+
subject(:paginator) { described_class.new([blank], offset: 6, limit: limit) }
|
46
46
|
|
47
47
|
it { is_expected.not_to be_first_page }
|
48
48
|
it { is_expected.to be_last_page }
|
@@ -124,7 +124,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
|
|
124
124
|
context 'when sorting by "count"' do
|
125
125
|
subject { described_class.new([]) }
|
126
126
|
|
127
|
-
let(:params) { HashWithIndifferentAccess.new 'facet.prefix': 'A' }
|
127
|
+
let(:params) { ActiveSupport::HashWithIndifferentAccess.new 'facet.prefix': 'A' }
|
128
128
|
|
129
129
|
it 'includes the prefix filter for "index" sorting' do
|
130
130
|
expect(subject.params_for_resort_url('index', params)).to include 'facet.prefix': 'A'
|
@@ -159,7 +159,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
describe "#as_json" do
|
162
|
-
subject { described_class.new([
|
162
|
+
subject { described_class.new([book], offset: 0, limit: nil).as_json }
|
163
163
|
|
164
164
|
it "is well structured" do
|
165
165
|
expect(subject).to eq("items" => [{ "hits" => "792", "value" => "Book" }], "limit" => nil,
|
@@ -169,7 +169,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
|
|
169
169
|
|
170
170
|
describe "#total_pages" do
|
171
171
|
# this method is just for API compatability with kaminari 0.16.1
|
172
|
-
subject { described_class.new([
|
172
|
+
subject { described_class.new([book], offset: 0, limit: nil).total_pages }
|
173
173
|
|
174
174
|
it { is_expected.to eq -1 }
|
175
175
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe "Blacklight::Solr::Document", api
|
3
|
+
RSpec.describe "Blacklight::Solr::Document", :api do
|
4
4
|
class MockDocument
|
5
5
|
include Blacklight::Solr::Document
|
6
6
|
end
|
@@ -231,7 +231,7 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
231
231
|
end
|
232
232
|
|
233
233
|
it "returns an array even for a single-value field" do
|
234
|
-
expect(@doc1.to_semantic_values[:title]).to
|
234
|
+
expect(@doc1.to_semantic_values[:title]).to be_a(Array)
|
235
235
|
end
|
236
236
|
|
237
237
|
it "returns complete array for a multi-value field" do
|
@@ -290,7 +290,7 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
290
290
|
|
291
291
|
it "plucks the MoreLikeThis results from the Solr Response" do
|
292
292
|
expect(result).to have(1).item
|
293
|
-
expect(result.first).to
|
293
|
+
expect(result.first).to be_a(MockDocument)
|
294
294
|
expect(result.first.id).to eq 'abc'
|
295
295
|
expect(result.first.solr_response).to eq response
|
296
296
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Blacklight::Solr::FacetPaginator, api
|
3
|
+
RSpec.describe Blacklight::Solr::FacetPaginator, :api do
|
4
4
|
let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
|
5
5
|
|
6
6
|
describe "#as_json" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Blacklight::Solr::Repository, api
|
3
|
+
RSpec.describe Blacklight::Solr::Repository, :api do
|
4
4
|
subject(:repository) do
|
5
5
|
described_class.new blacklight_config
|
6
6
|
end
|
@@ -24,12 +24,12 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
24
24
|
blacklight_config.document_solr_path = 'abc'
|
25
25
|
blacklight_config.solr_path = 'xyz'
|
26
26
|
allow(subject.connection).to receive(:send_and_receive).with('abc', anything).and_return(mock_response)
|
27
|
-
expect(subject.find("123")).to
|
27
|
+
expect(subject.find("123")).to be_a Blacklight::Solr::Response
|
28
28
|
end
|
29
29
|
|
30
30
|
it "uses a default :qt param" do
|
31
31
|
allow(subject.connection).to receive(:send_and_receive).with('get', hash_including(params: hash_including(ids: '123'))).and_return(mock_response)
|
32
|
-
expect(subject.find("123", {})).to
|
32
|
+
expect(subject.find("123", {})).to be_a Blacklight::Solr::Response
|
33
33
|
end
|
34
34
|
|
35
35
|
context "without a document solr path configured" do
|
@@ -40,7 +40,7 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
40
40
|
it "uses the default solr path" do
|
41
41
|
blacklight_config.solr_path = 'xyz'
|
42
42
|
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
43
|
-
expect(subject.find("123")).to
|
43
|
+
expect(subject.find("123")).to be_a Blacklight::Solr::Response
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -53,14 +53,14 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
53
53
|
it "uses the provided :qt param" do
|
54
54
|
blacklight_config.document_solr_request_handler = 'xyz'
|
55
55
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc' })).and_return(mock_response)
|
56
|
-
expect(subject.find("123", qt: 'abc')).to
|
56
|
+
expect(subject.find("123", qt: 'abc')).to be_a Blacklight::Solr::Response
|
57
57
|
end
|
58
58
|
|
59
59
|
it "uses the :qt parameter from the default_document_solr_params" do
|
60
60
|
blacklight_config.default_document_solr_params[:qt] = 'abc'
|
61
61
|
blacklight_config.document_solr_request_handler = 'xyz'
|
62
62
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc' })).and_return(mock_response)
|
63
|
-
expect(subject.find("123")).to
|
63
|
+
expect(subject.find("123")).to be_a Blacklight::Solr::Response
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -68,8 +68,26 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
68
68
|
doc_params = ActiveSupport::HashWithIndifferentAccess.new
|
69
69
|
allow(subject.connection).to receive(:send_and_receive).with('get', anything).and_return(mock_response)
|
70
70
|
response = subject.find("123", doc_params)
|
71
|
-
expect(response).to
|
72
|
-
expect(response.params).to
|
71
|
+
expect(response).to be_a Blacklight::Solr::Response
|
72
|
+
expect(response.params).to be_a ActiveSupport::HashWithIndifferentAccess
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#find_many' do
|
77
|
+
context 'with a configured fetch_many_documents_path' do
|
78
|
+
it 'uses the path' do
|
79
|
+
blacklight_config.fetch_many_documents_path = 'documents'
|
80
|
+
allow(subject.connection).to receive(:send_and_receive).with('documents', anything).and_return(mock_response)
|
81
|
+
expect(subject.find_many({})).to be_a Blacklight::Solr::Response
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'without a configured fetch_many_documents_path' do
|
86
|
+
it 'falls back to the search path' do
|
87
|
+
blacklight_config.solr_path = 'xyz'
|
88
|
+
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
89
|
+
expect(subject.find_many({})).to be_a Blacklight::Solr::Response
|
90
|
+
end
|
73
91
|
end
|
74
92
|
end
|
75
93
|
|
@@ -77,24 +95,24 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
77
95
|
it "uses the search-specific solr path" do
|
78
96
|
blacklight_config.solr_path = 'xyz'
|
79
97
|
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
80
|
-
expect(subject.search({})).to
|
98
|
+
expect(subject.search({})).to be_a Blacklight::Solr::Response
|
81
99
|
end
|
82
100
|
|
83
101
|
it "uses the default solr path" do
|
84
102
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
85
|
-
expect(subject.search({})).to
|
103
|
+
expect(subject.search({})).to be_a Blacklight::Solr::Response
|
86
104
|
end
|
87
105
|
|
88
106
|
it "uses a default :qt param" do
|
89
107
|
blacklight_config.qt = 'xyz'
|
90
108
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'xyz' })).and_return(mock_response)
|
91
|
-
expect(subject.search({})).to
|
109
|
+
expect(subject.search({})).to be_a Blacklight::Solr::Response
|
92
110
|
end
|
93
111
|
|
94
112
|
it "uses the provided :qt param" do
|
95
113
|
blacklight_config.qt = 'xyz'
|
96
114
|
allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc' })).and_return(mock_response)
|
97
|
-
expect(subject.search(qt: 'abc')).to
|
115
|
+
expect(subject.search(qt: 'abc')).to be_a Blacklight::Solr::Response
|
98
116
|
end
|
99
117
|
|
100
118
|
it "preserves the class of the incoming params" do
|
@@ -103,8 +121,8 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
103
121
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
104
122
|
|
105
123
|
response = subject.search(search_params)
|
106
|
-
expect(response).to
|
107
|
-
expect(response.params).to
|
124
|
+
expect(response).to be_a Blacklight::Solr::Response
|
125
|
+
expect(response.params).to be_a ActiveSupport::HashWithIndifferentAccess
|
108
126
|
end
|
109
127
|
|
110
128
|
it "calls send_and_receive with params returned from request factory method" do
|
@@ -183,7 +201,7 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
|
|
183
201
|
end
|
184
202
|
end
|
185
203
|
|
186
|
-
describe "http_method configuration", integration
|
204
|
+
describe "http_method configuration", :integration do
|
187
205
|
let (:blacklight_config) { config = Blacklight::Configuration.new; config.http_method = :post; config }
|
188
206
|
|
189
207
|
it "sends a post request to solr and get a response back" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Blacklight::Solr::Response::Facets, api
|
3
|
+
RSpec.describe Blacklight::Solr::Response::Facets, :api do
|
4
4
|
describe Blacklight::Solr::Response::Facets::FacetField do
|
5
5
|
describe "A field with default options" do
|
6
6
|
subject(:field) { described_class.new "my_field", [] }
|
@@ -247,7 +247,7 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
247
247
|
it "converts the query facets into a double RSolr FacetField" do
|
248
248
|
field = subject.aggregations['my_query_facet_field']
|
249
249
|
|
250
|
-
expect(field).to
|
250
|
+
expect(field).to be_a Blacklight::Solr::Response::Facets::FacetField
|
251
251
|
|
252
252
|
expect(field.name).to eq 'my_query_facet_field'
|
253
253
|
expect(field.items.size).to eq 3
|
@@ -316,7 +316,7 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
316
316
|
it "converts the pivot facet into a double RSolr FacetField" do
|
317
317
|
field = subject.aggregations['my_pivot_facet_field']
|
318
318
|
|
319
|
-
expect(field).to
|
319
|
+
expect(field).to be_a Blacklight::Solr::Response::Facets::FacetField
|
320
320
|
|
321
321
|
expect(field.name).to eq 'my_pivot_facet_field'
|
322
322
|
|