blacklight 9.0.0.beta1 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.docker/app/Dockerfile +2 -1
- data/.github/matrix.json +55 -0
- data/.github/workflows/build.yml +16 -0
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/main.yml +22 -0
- data/.github/workflows/release_7_x_scheduled.yml +39 -0
- data/.github/workflows/release_8_x_scheduled.yml +39 -0
- data/.github/workflows/test.yml +53 -0
- data/.rubocop.yml +81 -3
- data/.rubocop_todo.yml +46 -71
- data/.solr_wrapper.yml +3 -1
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +51 -38
- data/app/assets/javascripts/blacklight/blacklight.esm.js +62 -77
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +62 -77
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +0 -1
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +4 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +37 -29
- data/app/assets/stylesheets/blacklight/_header.scss +4 -0
- data/app/assets/stylesheets/blacklight/_modal.scss +9 -8
- data/app/assets/stylesheets/blacklight/_pagination.scss +1 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -4
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +3 -0
- data/app/components/blacklight/advanced_search_form_component.html.erb +4 -4
- data/app/components/blacklight/advanced_search_form_component.rb +6 -5
- data/app/components/blacklight/constraint_component.html.erb +1 -5
- data/app/components/blacklight/constraint_component.rb +11 -0
- data/app/components/blacklight/constraint_layout_component.html.erb +1 -6
- data/app/components/blacklight/constraint_layout_component.rb +9 -0
- data/app/components/blacklight/constraints_component.html.erb +3 -8
- data/app/components/blacklight/constraints_component.rb +59 -14
- data/app/components/blacklight/document/action_component.rb +1 -3
- data/app/components/blacklight/document/bookmark_component.html.erb +3 -3
- data/app/components/blacklight/document/bookmark_component.rb +10 -4
- data/app/components/blacklight/document/group_component.html.erb +1 -1
- data/app/components/blacklight/document/more_like_this_component.rb +2 -2
- data/app/components/blacklight/document/page_header_component.rb +3 -3
- data/app/components/blacklight/document/thumbnail_component.html.erb +3 -7
- data/app/components/blacklight/document/thumbnail_component.rb +7 -6
- data/app/components/blacklight/document_component.html.erb +3 -3
- data/app/components/blacklight/document_component.rb +22 -26
- data/app/components/blacklight/document_title_component.rb +6 -10
- data/app/components/blacklight/facet_field_checkboxes_component.rb +4 -18
- data/app/components/blacklight/facet_field_component.rb +4 -15
- data/app/components/blacklight/facet_field_filter_component.rb +4 -19
- data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +4 -23
- data/app/components/blacklight/facet_field_list_component.rb +4 -30
- data/app/components/blacklight/facet_field_no_layout_component.rb +4 -8
- data/app/components/blacklight/facet_field_pagination_component.html.erb +2 -2
- data/app/components/blacklight/facet_item_component.rb +4 -72
- data/app/components/blacklight/facet_item_pivot_component.rb +8 -4
- data/app/components/blacklight/{facet_field_checkboxes_component.html.erb → facets/checkboxes_component.html.erb} +4 -4
- data/app/components/blacklight/facets/checkboxes_component.rb +26 -0
- data/app/components/blacklight/facets/count_component.rb +23 -0
- data/app/components/blacklight/{facet_field_component.html.erb → facets/field_component.html.erb} +1 -3
- data/app/components/blacklight/facets/field_component.rb +23 -0
- data/app/components/blacklight/facets/filters_component.html.erb +4 -0
- data/app/components/blacklight/facets/filters_component.rb +39 -0
- data/app/components/blacklight/{facet_field_inclusive_constraint_component.html.erb → facets/inclusive_constraint_component.html.erb} +1 -1
- data/app/components/blacklight/facets/inclusive_constraint_component.rb +31 -0
- data/app/components/blacklight/{facet_field_filter_component.html.erb → facets/index_navigation_component.html.erb} +1 -1
- data/app/components/blacklight/facets/index_navigation_component.rb +32 -0
- data/app/components/blacklight/facets/item_component.rb +76 -0
- data/app/components/blacklight/facets/list_component.html.erb +11 -0
- data/app/components/blacklight/facets/list_component.rb +46 -0
- data/app/components/blacklight/facets/no_layout_component.rb +16 -0
- data/app/components/blacklight/facets/pivot_list_component.rb +14 -0
- data/app/components/blacklight/facets/selected_value_component.rb +29 -0
- data/app/components/blacklight/facets/suggest_component.html.erb +17 -0
- data/app/components/blacklight/facets/suggest_component.rb +21 -0
- data/app/components/blacklight/header_component.rb +2 -2
- data/app/components/blacklight/icons/remove_component.rb +2 -2
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +2 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
- data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +2 -2
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -3
- data/app/components/blacklight/response/facet_group_component.rb +9 -1
- data/app/components/blacklight/search_bar_component.html.erb +2 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +1 -1
- data/app/components/blacklight/system/dropdown_component.rb +1 -1
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +0 -9
- data/app/components/blacklight/system/modal_component.html.erb +1 -2
- data/app/components/blacklight/top_navbar_component.html.erb +2 -2
- data/app/controllers/concerns/blacklight/bookmarks.rb +13 -3
- data/app/controllers/concerns/blacklight/catalog.rb +27 -30
- data/app/controllers/concerns/blacklight/controller.rb +1 -1
- data/app/controllers/concerns/blacklight/search_context.rb +1 -1
- data/app/controllers/concerns/blacklight/searchable.rb +1 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +5 -3
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/document_helper_behavior.rb +3 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +7 -12
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -2
- data/app/javascript/blacklight-frontend/bookmark_toggle.js +7 -2
- data/app/javascript/blacklight-frontend/button_focus.js +1 -1
- data/app/javascript/blacklight-frontend/checkbox_submit.js +9 -2
- data/app/javascript/blacklight-frontend/debounce.js +1 -1
- data/app/javascript/blacklight-frontend/facet_suggest.js +27 -3
- data/app/javascript/blacklight-frontend/index.js +0 -2
- data/app/javascript/blacklight-frontend/modal.js +15 -8
- data/app/javascript/blacklight-frontend/search_context.js +3 -2
- data/app/presenters/blacklight/constraint_presenter.rb +22 -0
- data/app/presenters/blacklight/document_presenter.rb +6 -5
- data/app/presenters/blacklight/facet_field_presenter.rb +18 -2
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +6 -0
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_presenter.rb +5 -18
- data/app/presenters/blacklight/field_presenter.rb +4 -2
- data/app/presenters/blacklight/json_presenter.rb +8 -4
- data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
- data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
- data/app/presenters/blacklight/rendering/join.rb +11 -7
- data/app/presenters/blacklight/rendering/terminator.rb +1 -1
- data/app/services/blacklight/field_retriever.rb +1 -1
- data/app/services/blacklight/search_service.rb +10 -8
- data/app/values/blacklight/types.rb +2 -2
- data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
- data/app/views/catalog/_document.atom.builder +1 -1
- data/app/views/catalog/_document.html.erb +1 -1
- data/app/views/catalog/_email_form.html.erb +4 -4
- data/app/views/catalog/_home_text.html.erb +2 -2
- data/app/views/catalog/_show_main_content.html.erb +9 -5
- data/app/views/catalog/_sms_form.html.erb +4 -4
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/advanced_search.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +8 -10
- data/app/views/catalog/index.html.erb +0 -1
- data/app/views/catalog/index.json.jbuilder +5 -3
- data/app/views/catalog/show.html.erb +2 -2
- data/app/views/layouts/blacklight/base.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.ar.yml +14 -14
- data/config/locales/blacklight.ca.yml +2 -2
- data/config/locales/blacklight.de.yml +13 -13
- data/config/locales/blacklight.en.yml +3 -3
- data/config/locales/blacklight.es.yml +13 -13
- data/config/locales/blacklight.fr.yml +14 -14
- data/config/locales/blacklight.hu.yml +15 -15
- data/config/locales/blacklight.it.yml +16 -16
- data/config/locales/blacklight.nl.yml +13 -13
- data/config/locales/blacklight.pt-BR.yml +15 -15
- data/config/locales/blacklight.sq.yml +14 -14
- data/config/locales/blacklight.zh.yml +12 -12
- data/lib/blacklight/abstract_repository.rb +2 -2
- data/lib/blacklight/component.rb +7 -1
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/facet_field.rb +11 -6
- data/lib/blacklight/configuration/field.rb +4 -4
- data/lib/blacklight/configuration/fields.rb +0 -1
- data/lib/blacklight/configuration/search_field.rb +1 -1
- data/lib/blacklight/configuration/view_config.rb +32 -18
- data/lib/blacklight/configuration.rb +64 -10
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
- data/lib/blacklight/open_struct_with_hash_access.rb +2 -2
- data/lib/blacklight/routes/searchable.rb +1 -1
- data/lib/blacklight/search_builder.rb +2 -1
- data/lib/blacklight/search_state/filter_field.rb +4 -4
- data/lib/blacklight/search_state/pivot_filter_field.rb +5 -5
- data/lib/blacklight/search_state.rb +2 -0
- data/lib/blacklight/solr/abstract_filter_query_builder.rb +77 -0
- data/lib/blacklight/solr/default_filter_query_builder.rb +20 -0
- data/lib/blacklight/solr/field_reflection_search_builder.rb +11 -0
- data/lib/blacklight/solr/repository.rb +17 -15
- data/lib/blacklight/solr/response/facets.rb +2 -2
- data/lib/blacklight/solr/response/params.rb +0 -4
- data/lib/blacklight/solr/response.rb +5 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +48 -97
- data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
- data/lib/blacklight.rb +6 -4
- data/lib/generators/blacklight/assets/importmap_generator.rb +3 -5
- data/lib/generators/blacklight/assets_generator.rb +1 -1
- data/lib/generators/blacklight/search_builder_generator.rb +1 -1
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +3 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -71
- data/package.json +3 -3
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +18 -22
- data/spec/components/blacklight/constraint_layout_component_spec.rb +8 -8
- data/spec/components/blacklight/constraints_component_spec.rb +11 -11
- data/spec/components/blacklight/document/action_component_spec.rb +23 -15
- data/spec/components/blacklight/document/group_component_spec.rb +10 -15
- data/spec/components/blacklight/document/page_header_component_spec.rb +35 -28
- data/spec/components/blacklight/document/sidebar_component_spec.rb +5 -11
- data/spec/components/blacklight/document_component_spec.rb +105 -79
- data/spec/components/blacklight/facet_component_spec.rb +12 -8
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +12 -12
- data/spec/components/blacklight/{facet_field_checkboxes_component_spec.rb → facets/checkboxes_component_spec.rb} +13 -13
- data/spec/components/blacklight/facets/filters_component_spec.rb +36 -0
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +41 -0
- data/spec/components/blacklight/{facet_item_component_spec.rb → facets/item_component_spec.rb} +10 -10
- data/spec/components/blacklight/{facet_field_list_component_spec.rb → facets/list_component_spec.rb} +34 -23
- data/spec/components/blacklight/facets/pivot_list_component_spec.rb +53 -0
- data/spec/components/blacklight/facets/suggest_component_spec.rb +82 -0
- data/spec/components/blacklight/header_component_spec.rb +2 -4
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +7 -7
- data/spec/components/blacklight/metadata_field_component_spec.rb +17 -15
- data/spec/components/blacklight/response/facet_group_component_spec.rb +37 -0
- data/spec/components/blacklight/response/pagination_component_spec.rb +1 -1
- data/spec/components/blacklight/response/spellcheck_component_spec.rb +1 -1
- data/spec/components/blacklight/search_bar_component_spec.rb +28 -5
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +2 -2
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +3 -5
- data/spec/components/blacklight/skip_link_component_spec.rb +8 -11
- data/spec/components/blacklight/start_over_button_component_spec.rb +4 -4
- data/spec/components/blacklight/system/dropdown_component_spec.rb +26 -0
- data/spec/components/blacklight/system/flash_message_component_spec.rb +7 -11
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +12 -20
- data/spec/features/advanced_search_spec.rb +42 -21
- data/spec/features/facets_spec.rb +84 -12
- data/spec/features/modal_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +6 -4
- data/spec/features/search_spec.rb +3 -3
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +10 -0
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +2 -2
- data/spec/lib/blacklight/parameters_spec.rb +12 -1
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +18 -0
- data/spec/models/blacklight/configuration_spec.rb +178 -28
- data/spec/models/blacklight/solr/default_filter_query_builder_spec.rb +72 -0
- data/spec/models/blacklight/solr/document_spec.rb +0 -4
- data/spec/models/blacklight/solr/repository_spec.rb +37 -29
- data/spec/models/blacklight/solr/response/facets_spec.rb +86 -40
- data/spec/models/blacklight/solr/response/group_response_spec.rb +8 -5
- data/spec/models/blacklight/solr/response/group_spec.rb +9 -5
- data/spec/models/blacklight/solr/response_spec.rb +96 -64
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +38 -57
- data/spec/models/solr_document_spec.rb +5 -1
- data/spec/presenters/blacklight/constraint_presenter_spec.rb +32 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +0 -7
- data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
- data/spec/presenters/blacklight/json_presenter_spec.rb +17 -0
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
- data/spec/services/blacklight/search_service_spec.rb +6 -27
- data/spec/spec_helper.rb +0 -1
- data/spec/support/presenter_test_helpers.rb +1 -1
- data/spec/support/view_component_test_helpers.rb +0 -18
- data/spec/views/catalog/facet.html.erb_spec.rb +10 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +8 -3
- data/spec/views/catalog/index.html.erb_spec.rb +3 -1
- metadata +69 -38
- data/.github/workflows/ruby.yml +0 -98
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -4
- data/app/components/blacklight/facet_field_list_component.html.erb +0 -19
- data/app/components/blacklight/search/facet_suggest_input.html.erb +0 -9
- data/app/components/blacklight/search/facet_suggest_input.rb +0 -16
- data/app/javascript/blacklight-frontend/modalForm.js +0 -60
- data/app/views/catalog/_facet_index_navigation.html.erb +0 -1
- data/app/views/catalog/_facet_layout.html.erb +0 -8
- data/app/views/catalog/_facet_pagination.html.erb +0 -1
- data/app/views/catalog/_facet_pivot.html.erb +0 -3
- data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
- data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
- data/spec/components/blacklight/search/facet_suggest_input_spec.rb +0 -33
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +0 -43
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +0 -41
|
@@ -5,26 +5,22 @@ require 'spec_helper'
|
|
|
5
5
|
RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
6
6
|
subject(:component) { described_class.new(message: message, type: type) }
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
component.render_in(view_context)
|
|
8
|
+
before do
|
|
9
|
+
render_inline(component)
|
|
11
10
|
end
|
|
12
11
|
|
|
13
|
-
let(:rendered) do
|
|
14
|
-
Capybara::Node::Simple.new(render)
|
|
15
|
-
end
|
|
16
12
|
let(:message) { 'This is an important message' }
|
|
17
13
|
let(:type) { 'whatever' }
|
|
18
14
|
|
|
19
15
|
it 'renders a message inside an alert' do
|
|
20
|
-
expect(
|
|
16
|
+
expect(page).to have_css 'div.alert.alert-whatever', text: message
|
|
21
17
|
end
|
|
22
18
|
|
|
23
19
|
context 'with a success message' do
|
|
24
20
|
let(:type) { 'success' }
|
|
25
21
|
|
|
26
22
|
it 'adds some styling' do
|
|
27
|
-
expect(
|
|
23
|
+
expect(page).to have_css 'div.alert-success'
|
|
28
24
|
end
|
|
29
25
|
end
|
|
30
26
|
|
|
@@ -32,7 +28,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
|
32
28
|
let(:type) { 'notice' }
|
|
33
29
|
|
|
34
30
|
it 'adds some styling' do
|
|
35
|
-
expect(
|
|
31
|
+
expect(page).to have_css 'div.alert-info'
|
|
36
32
|
end
|
|
37
33
|
end
|
|
38
34
|
|
|
@@ -40,7 +36,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
|
40
36
|
let(:type) { 'alert' }
|
|
41
37
|
|
|
42
38
|
it 'adds some styling' do
|
|
43
|
-
expect(
|
|
39
|
+
expect(page).to have_css 'div.alert-warning'
|
|
44
40
|
end
|
|
45
41
|
end
|
|
46
42
|
|
|
@@ -48,7 +44,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
|
48
44
|
let(:type) { 'error' }
|
|
49
45
|
|
|
50
46
|
it 'adds some styling' do
|
|
51
|
-
expect(
|
|
47
|
+
expect(page).to have_css 'div.alert-danger'
|
|
52
48
|
end
|
|
53
49
|
end
|
|
54
50
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
RSpec.describe Blacklight::Catalog do
|
|
4
4
|
subject { controller }
|
|
5
5
|
|
|
6
|
-
let(:controller) {
|
|
6
|
+
let(:controller) { Class.new(ApplicationController) { include Blacklight::Catalog }.new }
|
|
7
7
|
|
|
8
8
|
describe "#search_state" do
|
|
9
9
|
subject { controller.send(:search_state) }
|
|
@@ -499,13 +499,14 @@ RSpec.describe CatalogController, :api do
|
|
|
499
499
|
expect(request.flash[:error]).to be_nil
|
|
500
500
|
end
|
|
501
501
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
502
|
+
context 'when message is provided' do
|
|
503
|
+
it "sends email and redirects back to the record" do
|
|
504
|
+
expect do
|
|
505
|
+
post :email, params: { id: doc_id, to: 'test_email@projectblacklight.org', message: 'xyz' }
|
|
506
|
+
end.to send_email(to: 'test_email@projectblacklight.org')
|
|
507
|
+
expect(request.flash[:error]).to be_nil
|
|
508
|
+
expect(request).to redirect_to(solr_document_path(doc_id))
|
|
509
|
+
end
|
|
509
510
|
end
|
|
510
511
|
|
|
511
512
|
it "renders email_success for XHR requests" do
|
|
@@ -549,11 +550,9 @@ RSpec.describe CatalogController, :api do
|
|
|
549
550
|
end
|
|
550
551
|
|
|
551
552
|
it "sends to the appropriate carrier email address" do
|
|
552
|
-
expect
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
.and_return double(deliver: nil)
|
|
556
|
-
post :sms, params: { id: doc_id, to: '5555555555', carrier: 'txt.att.net' }
|
|
553
|
+
expect do
|
|
554
|
+
post :sms, params: { id: doc_id, to: '5555555555', carrier: 'txt.att.net' }
|
|
555
|
+
end.to send_email(to: '5555555555@txt.att.net')
|
|
557
556
|
end
|
|
558
557
|
|
|
559
558
|
it "redirects back to the record upon success" do
|
|
@@ -786,13 +785,6 @@ RSpec.describe CatalogController, :api do
|
|
|
786
785
|
end
|
|
787
786
|
end
|
|
788
787
|
|
|
789
|
-
describe "search_facet_path" do
|
|
790
|
-
it "is the same as the catalog path" do
|
|
791
|
-
get :index, params: { page: 1 }
|
|
792
|
-
expect(controller.send(:search_facet_path, id: "some_facet", page: 5)).to eq facet_catalog_path(id: "some_facet")
|
|
793
|
-
end
|
|
794
|
-
end
|
|
795
|
-
|
|
796
788
|
describe "page_links" do
|
|
797
789
|
it "has prev/next docs and result set data for non-empty result sets", :integration do
|
|
798
790
|
get :page_links, params: { f: { "format" => 'Book' }, counter: 2 }
|
|
@@ -803,7 +795,7 @@ RSpec.describe CatalogController, :api do
|
|
|
803
795
|
end
|
|
804
796
|
|
|
805
797
|
it "is empty for empty result sets", :integration do
|
|
806
|
-
get :page_links, params: { f: { "format" => 'empty-result-set' }, counter: 1 }
|
|
798
|
+
get :page_links, params: { f: { "format" => ['empty-result-set'] }, counter: 1 }
|
|
807
799
|
expect(assigns(:page_link_data)).to be_empty
|
|
808
800
|
end
|
|
809
801
|
end
|
|
@@ -5,25 +5,7 @@ require 'spec_helper'
|
|
|
5
5
|
RSpec.describe "Blacklight Advanced Search Form" do
|
|
6
6
|
describe "advanced search form" do
|
|
7
7
|
before do
|
|
8
|
-
|
|
9
|
-
edismax: {}
|
|
10
|
-
}
|
|
11
|
-
CatalogController.blacklight_config.search_fields['author']['clause_params'] = {
|
|
12
|
-
edismax: { qf: '${author_qf}' }
|
|
13
|
-
}
|
|
14
|
-
CatalogController.blacklight_config.search_fields['title']['clause_params'] = {
|
|
15
|
-
edismax: { qf: '${title_qf}' }
|
|
16
|
-
}
|
|
17
|
-
CatalogController.blacklight_config.search_fields['subject']['clause_params'] = {
|
|
18
|
-
edismax: { qf: '${subject_qf}' }
|
|
19
|
-
}
|
|
20
|
-
visit '/catalog/advanced?hypothetical_existing_param=true&q=ignore+this+existing+query'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
after do
|
|
24
|
-
%w[all_fields author title subject].each do |field|
|
|
25
|
-
CatalogController.blacklight_config.search_fields[field].delete(:clause_params)
|
|
26
|
-
end
|
|
8
|
+
visit '/catalog/advanced'
|
|
27
9
|
end
|
|
28
10
|
|
|
29
11
|
it "has field and facet blocks" do
|
|
@@ -56,6 +38,16 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
56
38
|
expect(page).to have_content 'Language'
|
|
57
39
|
end
|
|
58
40
|
end
|
|
41
|
+
|
|
42
|
+
it "omits facets configured with include_in_advanced_search: false" do
|
|
43
|
+
expect(page).to have_no_css('.blacklight-example_pivot_field')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "lists all the values for an included facet" do
|
|
47
|
+
within('.blacklight-subject_ssim') do
|
|
48
|
+
expect(page).to have_css('ul.facet-values li', count: 45)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
59
51
|
end
|
|
60
52
|
|
|
61
53
|
it 'scopes searches to fields' do
|
|
@@ -66,10 +58,20 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
66
58
|
expect(page).to have_css('article.document', count: 1)
|
|
67
59
|
end
|
|
68
60
|
|
|
61
|
+
it 'does not render spellcheck/did you mean? section' do
|
|
62
|
+
fill_in 'All Fields', with: 'tibet'
|
|
63
|
+
click_on 'advanced-search-submit'
|
|
64
|
+
expect(page).to have_content 'Remove constraint All Fields: tibet'
|
|
65
|
+
expect(page).to have_css('article.document', count: 2)
|
|
66
|
+
expect(page).to have_no_css('#spell')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
69
|
it 'can limit to facets' do
|
|
70
70
|
fill_in 'Subject', with: 'Women'
|
|
71
71
|
click_on 'Language'
|
|
72
|
-
|
|
72
|
+
within '#facet-language_ssim' do
|
|
73
|
+
check 'Urdu 3'
|
|
74
|
+
end
|
|
73
75
|
click_on 'advanced-search-submit'
|
|
74
76
|
expect(page).to have_content 'Pākistānī ʻaurat dorāhe par'
|
|
75
77
|
expect(page).to have_no_content 'Ajikto kŭrŏk chŏrŏk sasimnikka : and 아직도 그럭 저럭 사십니까'
|
|
@@ -105,7 +107,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
105
107
|
|
|
106
108
|
describe "prepopulated advanced search form" do
|
|
107
109
|
before do
|
|
108
|
-
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&sort=author'
|
|
110
|
+
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&f[format][]=Book&sort=author'
|
|
109
111
|
end
|
|
110
112
|
|
|
111
113
|
it 'prepopulates the expected fields' do
|
|
@@ -115,6 +117,12 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
115
117
|
expect(page).to have_select 'sort', selected: 'author'
|
|
116
118
|
end
|
|
117
119
|
|
|
120
|
+
it 'creates hidden inputs for fields not included in the advanced search form' do
|
|
121
|
+
within('form.advanced') do
|
|
122
|
+
expect(page).to have_field 'f[format][]', type: :hidden, with: 'Book'
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
118
126
|
it "does not create hidden inputs for fields included in adv search form" do
|
|
119
127
|
within('form.advanced') do
|
|
120
128
|
expect(page).to have_no_field('clause[1][query]', type: :hidden, with: 'medicine')
|
|
@@ -138,5 +146,18 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
138
146
|
expect(page).to have_no_field 'Title', with: 'medicine'
|
|
139
147
|
expect(page).to have_no_field 'Tibetan', checked: true
|
|
140
148
|
end
|
|
149
|
+
|
|
150
|
+
it 'creates constraints for fields not included in advanced search form' do
|
|
151
|
+
within('div.constraints') do
|
|
152
|
+
expect(page).to have_content('Format:Book')
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'does not create constraints for fields included in the advanced search form' do
|
|
157
|
+
within('div.constraints') do
|
|
158
|
+
expect(page).to have_no_content('Title:medicine')
|
|
159
|
+
expect(page).to have_no_content('Language:Tibetan')
|
|
160
|
+
end
|
|
161
|
+
end
|
|
141
162
|
end
|
|
142
163
|
end
|
|
@@ -69,14 +69,14 @@ RSpec.describe "Facets" do
|
|
|
69
69
|
click_on 'Pivot Field'
|
|
70
70
|
|
|
71
71
|
within '#facet-example_pivot_field' do
|
|
72
|
-
expect(page).to have_css('.facet-leaf-node', text: "
|
|
73
|
-
expect(page).to have_no_css('.facet-select', text: '
|
|
74
|
-
|
|
75
|
-
click_on '
|
|
72
|
+
expect(page).to have_css('.facet-leaf-node', text: "Tibetan 6", normalize_ws: true)
|
|
73
|
+
expect(page).to have_no_css('.facet-select', text: 'India')
|
|
74
|
+
first('.facet-toggle-handle').click
|
|
75
|
+
click_on 'India'
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
expect(page).to have_css('.constraint-value', text: 'Format Book')
|
|
79
78
|
expect(page).to have_css('.constraint-value', text: 'Language Tibetan')
|
|
79
|
+
expect(page).to have_css('.constraint-value', text: 'Region India')
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
describe 'heading button focus with Firefox' do
|
|
@@ -99,7 +99,7 @@ RSpec.describe "Facets" do
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
describe 'Facet modal' do
|
|
102
|
+
describe 'Facet modal content' do
|
|
103
103
|
it 'allows the user to filter a long list of facet values', :js do
|
|
104
104
|
visit '/catalog/facet/subject_ssim'
|
|
105
105
|
expect(page).to have_no_link 'Old age' # This is on the second page of facet values
|
|
@@ -107,27 +107,99 @@ RSpec.describe "Facets" do
|
|
|
107
107
|
|
|
108
108
|
fill_in 'facet_suggest_subject_ssim', with: "ag"
|
|
109
109
|
|
|
110
|
+
expect(page).to have_css '.facet-suggestions'
|
|
110
111
|
expect(page).to have_link 'Old age'
|
|
111
112
|
expect(page).to have_css 'a.facet-select', count: 2
|
|
112
113
|
end
|
|
113
114
|
|
|
115
|
+
it 'can show suggestions including a period', :js do
|
|
116
|
+
visit '/catalog/facet/subject_ssim'
|
|
117
|
+
fill_in 'facet_suggest_subject_ssim', with: 'iran.'
|
|
118
|
+
|
|
119
|
+
expect(page).to have_css '.facet-suggestions'
|
|
120
|
+
expect(page).to have_link 'Iran. Vizārat-i Kishvar'
|
|
121
|
+
expect(page).to have_css 'a.facet-select', count: 1
|
|
122
|
+
end
|
|
123
|
+
|
|
114
124
|
it 'shows the user facet suggestions that are relevant to their q param', :js do
|
|
115
125
|
visit '/catalog/facet/subject_ssim?q=tibet&search_field=all_fields'
|
|
116
126
|
fill_in 'facet_suggest_subject_ssim', with: 'la'
|
|
117
127
|
|
|
128
|
+
expect(page).to have_css '.facet-suggestions'
|
|
118
129
|
expect(page).to have_link 'Tibetan language'
|
|
130
|
+
expect(page).to have_no_link 'Law'
|
|
119
131
|
expect(page).to have_css 'a.facet-select', count: 1
|
|
120
132
|
end
|
|
121
133
|
|
|
122
|
-
it 'allows the user to
|
|
134
|
+
it 'allows the user to toggle the sort, then filter', :js do
|
|
123
135
|
visit '/catalog/facet/subject_ssim'
|
|
124
|
-
expect(page).to have_no_link 'Old age' # This is on the second page of facet values
|
|
125
|
-
expect(page).to have_css 'a.facet-select', count: 20
|
|
126
136
|
|
|
127
|
-
fill_in 'facet_suggest_subject_ssim', with:
|
|
137
|
+
fill_in 'facet_suggest_subject_ssim', with: 'po'
|
|
128
138
|
|
|
129
|
-
expect(page).to
|
|
130
|
-
expect(page).to
|
|
139
|
+
expect(page).to have_css '.facet-suggestions'
|
|
140
|
+
expect(page).to have_css('.facet-values li:nth-child(1)', text: 'Political plays, Japanese')
|
|
141
|
+
expect(page).to have_css('.facet-values li:nth-child(2)', text: 'Military weapons')
|
|
142
|
+
expect(page).to have_css('.facet-values li:nth-child(3)', text: 'Political science')
|
|
143
|
+
|
|
144
|
+
first(:link, 'A-Z Sort').click
|
|
145
|
+
|
|
146
|
+
expect(page).to have_css('.facet-suggest[data-facet-search-context*="facet.sort=index"]')
|
|
147
|
+
|
|
148
|
+
fill_in 'facet_suggest_subject_ssim', with: 'po'
|
|
149
|
+
|
|
150
|
+
expect(page).to have_css '.facet-suggestions'
|
|
151
|
+
expect(page).to have_css('.facet-values li:nth-child(1)', text: 'Military weapons')
|
|
152
|
+
expect(page).to have_css('.facet-values li:nth-child(2)', text: 'Political plays, Japanese')
|
|
153
|
+
expect(page).to have_css('.facet-values li:nth-child(3)', text: 'Political science')
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'allows the user to choose a starting letter, then filter', :js do
|
|
157
|
+
visit '/catalog/facet/subject_ssim'
|
|
158
|
+
|
|
159
|
+
first(:link, 'A-Z Sort').click
|
|
160
|
+
expect(page).to have_css('.facet-suggest[data-facet-search-context*="facet.sort=index"]')
|
|
161
|
+
|
|
162
|
+
click_on 'M'
|
|
163
|
+
expect(page).to have_css('.facet-suggest[data-facet-search-context*="facet.prefix=M"]')
|
|
164
|
+
|
|
165
|
+
fill_in 'facet_suggest_subject_ssim', with: 'te'
|
|
166
|
+
|
|
167
|
+
expect(page).to have_css '.facet-suggestions'
|
|
168
|
+
expect(page).to have_link 'Maternity insurance'
|
|
169
|
+
expect(page).to have_no_link 'Teaching'
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it 'hides previous/next links when filtering', :js do
|
|
173
|
+
visit '/catalog/facet/subject_ssim'
|
|
174
|
+
expect(page).to have_link 'Next »'
|
|
175
|
+
|
|
176
|
+
fill_in 'facet_suggest_subject_ssim', with: 'te'
|
|
177
|
+
expect(page).to have_css '.facet-suggestions'
|
|
178
|
+
expect(page).to have_no_link 'Next »'
|
|
179
|
+
|
|
180
|
+
fill_in 'facet_suggest_subject_ssim', with: ''
|
|
181
|
+
expect(page).to have_no_css '.facet-suggestions'
|
|
182
|
+
expect(page).to have_link 'Next »'
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
context 'when facet is configured with suggest: false' do
|
|
186
|
+
before do
|
|
187
|
+
enabled = CatalogController.blacklight_config.dup
|
|
188
|
+
enabled.facet_fields[:subject_ssim].merge!({ suggest: false })
|
|
189
|
+
allow(CatalogController).to receive(:blacklight_config).and_return enabled
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it 'does not offer the user a way to filter the list of facet values' do
|
|
193
|
+
visit '/catalog/facet/subject_ssim'
|
|
194
|
+
expect(page).to have_no_field 'facet_suggest_subject_ssim'
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
describe 'facebook-style facet parameters' do
|
|
200
|
+
it 'can perform a search' do
|
|
201
|
+
visit '/?f[subject_ssim][0]=Iran.+Viza%CC%84rat-i+Kishvar'
|
|
202
|
+
expect(page).to have_text 'Naqdī barā-yi tamām-i fuṣūl'
|
|
131
203
|
end
|
|
132
204
|
end
|
|
133
205
|
end
|
data/spec/features/modal_spec.rb
CHANGED
|
@@ -6,7 +6,7 @@ RSpec.describe 'Modal' do
|
|
|
6
6
|
expect(page).to have_no_selector 'dialog#blacklight-modal'
|
|
7
7
|
click_on 'Email'
|
|
8
8
|
expect(page).to have_css 'dialog#blacklight-modal'
|
|
9
|
-
|
|
9
|
+
find('button[aria-label=Close]').click
|
|
10
10
|
expect(page).to have_no_selector 'dialog#blacklight-modal'
|
|
11
11
|
end
|
|
12
12
|
end
|
|
@@ -18,7 +18,9 @@ RSpec.describe "Facets" do
|
|
|
18
18
|
expect(page).to have_css("span.facet-count.selected", text: "6")
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
within "#facet-subject_geo_ssim" do
|
|
22
|
+
click_on "India"
|
|
23
|
+
end
|
|
22
24
|
within ("#sortAndPerPage") do
|
|
23
25
|
expect(page).to have_content "1 - 2 of 2"
|
|
24
26
|
end
|
|
@@ -51,7 +53,7 @@ RSpec.describe "Facets" do
|
|
|
51
53
|
expect(page).to have_css("span.facet-count.selected", text: "2")
|
|
52
54
|
end
|
|
53
55
|
within "#appliedParams" do
|
|
54
|
-
expect(page).to have_content "
|
|
56
|
+
expect(page).to have_content "Your selections:"
|
|
55
57
|
expect(page).to have_content "history"
|
|
56
58
|
end
|
|
57
59
|
|
|
@@ -138,7 +140,7 @@ RSpec.describe "Facets" do
|
|
|
138
140
|
expect(page).to have_css("span.facet-count.selected", text: "2")
|
|
139
141
|
end
|
|
140
142
|
within "#appliedParams" do
|
|
141
|
-
expect(page).to have_content "
|
|
143
|
+
expect(page).to have_content "Your selections:"
|
|
142
144
|
expect(page).to have_content "history"
|
|
143
145
|
end
|
|
144
146
|
end
|
|
@@ -162,7 +164,7 @@ RSpec.describe "Facets" do
|
|
|
162
164
|
expect(page).to have_css("span.facet-count.selected", text: "2")
|
|
163
165
|
end
|
|
164
166
|
within "#appliedParams" do
|
|
165
|
-
expect(page).to have_content "
|
|
167
|
+
expect(page).to have_content "Your selections:"
|
|
166
168
|
expect(page).to have_content "history"
|
|
167
169
|
end
|
|
168
170
|
end
|
|
@@ -44,7 +44,7 @@ RSpec.describe "Search Page" do
|
|
|
44
44
|
Capybara.ignore_hidden_elements = tmp_value
|
|
45
45
|
|
|
46
46
|
within "#appliedParams" do
|
|
47
|
-
expect(page).to have_content "
|
|
47
|
+
expect(page).to have_content "Your selections:"
|
|
48
48
|
expect(page).to have_content "history"
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -74,7 +74,7 @@ RSpec.describe "Search Page" do
|
|
|
74
74
|
click_on 'search'
|
|
75
75
|
|
|
76
76
|
within "#appliedParams" do
|
|
77
|
-
expect(page).to have_content "
|
|
77
|
+
expect(page).to have_content "Your selections:"
|
|
78
78
|
expect(page).to have_content "Title"
|
|
79
79
|
expect(page).to have_content "inmul"
|
|
80
80
|
end
|
|
@@ -104,7 +104,7 @@ RSpec.describe "Search Page" do
|
|
|
104
104
|
fill_in "q", with: 'history'
|
|
105
105
|
click_on 'search'
|
|
106
106
|
within "#appliedParams" do
|
|
107
|
-
expect(page).to have_content "
|
|
107
|
+
expect(page).to have_content "Your selections:"
|
|
108
108
|
expect(page).to have_content "history"
|
|
109
109
|
end
|
|
110
110
|
|
|
@@ -26,4 +26,14 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
|
26
26
|
expect(presenter).to be_a SomePresenter
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
describe "#search_facet_path" do
|
|
31
|
+
before do
|
|
32
|
+
params[:controller] = 'catalog'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "is the same as the catalog path" do
|
|
36
|
+
expect(helper.search_facet_path(id: "some_facet", page: 5)).to eq facet_catalog_path(id: "some_facet")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
29
39
|
end
|
|
@@ -23,7 +23,7 @@ RSpec.describe Blacklight::Configuration::FacetField do
|
|
|
23
23
|
subject.normalize!
|
|
24
24
|
|
|
25
25
|
expect(subject.presenter).to eq Blacklight::FacetFieldPresenter
|
|
26
|
-
expect(subject.component).to eq Blacklight::
|
|
26
|
+
expect(subject.component).to eq Blacklight::Facets::ListComponent
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
context 'when component is set to true' do
|
|
@@ -34,7 +34,7 @@ RSpec.describe Blacklight::Configuration::FacetField do
|
|
|
34
34
|
it 'casts to the default component' do
|
|
35
35
|
subject.normalize!
|
|
36
36
|
|
|
37
|
-
expect(subject.component).to eq Blacklight::
|
|
37
|
+
expect(subject.component).to eq Blacklight::Facets::ListComponent
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -52,7 +52,7 @@ RSpec.describe Blacklight::Parameters do
|
|
|
52
52
|
let(:search_state) { Blacklight::SearchState.new(query_params, blacklight_config) }
|
|
53
53
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
|
54
54
|
|
|
55
|
-
context 'with
|
|
55
|
+
context 'with facebook\'s badly mangled query parameters' do
|
|
56
56
|
let(:query_params) do
|
|
57
57
|
ActionController::Parameters.new(
|
|
58
58
|
f: { field: { '0': 'first', '1': 'second' } },
|
|
@@ -67,6 +67,17 @@ RSpec.describe Blacklight::Parameters do
|
|
|
67
67
|
it 'normalizes the facets to the expected format' do
|
|
68
68
|
expect(params.permit_search_params.to_h.with_indifferent_access).to include f: { field: %w[first second] }, f_inclusive: { field: %w[first second] }
|
|
69
69
|
end
|
|
70
|
+
|
|
71
|
+
context 'when several fields are configured' do
|
|
72
|
+
before do
|
|
73
|
+
blacklight_config.add_facet_field 'other_field'
|
|
74
|
+
blacklight_config.add_facet_field 'some_other_pivot_field', pivot: %w[abc def]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'normalizes the facets to the expected format' do
|
|
78
|
+
expect(params.permit_search_params.to_h.with_indifferent_access).to include f: { field: %w[first second] }, f_inclusive: { field: %w[first second] }
|
|
79
|
+
end
|
|
80
|
+
end
|
|
70
81
|
end
|
|
71
82
|
|
|
72
83
|
context 'with filter_search_state_fields set to false' do
|
|
@@ -198,4 +198,22 @@ RSpec.describe Blacklight::SearchState::FilterField do
|
|
|
198
198
|
expect(search_state.filter('some_field').include?(OpenStruct.new(value: '1'))).to be true
|
|
199
199
|
end
|
|
200
200
|
end
|
|
201
|
+
|
|
202
|
+
describe '#permitted_params' do
|
|
203
|
+
context 'with a pivot facet' do
|
|
204
|
+
let(:blacklight_config) do
|
|
205
|
+
Blacklight::Configuration.new.configure do |config|
|
|
206
|
+
config.add_facet_field 'my_pivot', pivot: %w[format language_ssim]
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it 'marks all the pivot fields as permitted' do
|
|
211
|
+
field = described_class.new blacklight_config.facet_fields['my_pivot'], search_state
|
|
212
|
+
expect(field.permitted_params).to eq({
|
|
213
|
+
f: { "-format" => [], "-language_ssim" => [], "format" => [], "language_ssim" => [] },
|
|
214
|
+
f_inclusive: { "format" => [], "language_ssim" => [] }
|
|
215
|
+
})
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
201
219
|
end
|