blacklight 7.32.0 → 8.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +2 -2
- data/.github/workflows/ruby.yml +32 -107
- data/.rubocop.yml +243 -2
- data/.rubocop_todo.yml +214 -270
- data/Gemfile +7 -6
- data/README.md +11 -3
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +384 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
- data/app/assets/javascripts/blacklight/blacklight.js +351 -496
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
- data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
- data/app/assets/stylesheets/blacklight/_controls.scss +5 -12
- data/app/assets/stylesheets/blacklight/_facets.scss +96 -44
- data/app/assets/stylesheets/blacklight/_header.scss +0 -15
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
- data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
- data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
- data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
- data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
- data/app/builders/blacklight/action_builder.rb +18 -9
- data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +4 -6
- data/app/components/blacklight/constraints_component.rb +27 -37
- data/app/components/blacklight/document/action_component.html.erb +2 -9
- data/app/components/blacklight/document/action_component.rb +26 -8
- data/app/components/blacklight/document/actions_component.rb +1 -1
- data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
- data/app/components/blacklight/document/bookmark_component.rb +4 -2
- data/app/components/blacklight/document/citation_component.rb +5 -3
- data/app/components/blacklight/document/group_component.rb +7 -3
- data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
- data/app/components/blacklight/document/sidebar_component.rb +16 -0
- data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
- data/app/components/blacklight/document/thumbnail_component.rb +1 -9
- data/app/components/blacklight/document_component.html.erb +4 -0
- data/app/components/blacklight/document_component.rb +7 -23
- data/app/components/blacklight/document_metadata_component.rb +5 -6
- data/app/components/blacklight/document_title_component.rb +4 -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_component.html.erb +5 -5
- data/app/components/blacklight/facet_field_component.rb +9 -2
- data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
- data/app/components/blacklight/facet_field_list_component.rb +37 -5
- data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
- data/app/components/blacklight/facet_item_component.rb +1 -43
- data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
- data/app/components/blacklight/header_component.html.erb +2 -0
- data/app/components/blacklight/header_component.rb +26 -0
- data/app/components/blacklight/hidden_search_state_component.rb +1 -2
- data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
- data/app/components/blacklight/icons/list_component.rb +16 -0
- data/app/components/blacklight/icons/search_component.rb +16 -0
- data/app/components/blacklight/metadata_field_component.rb +24 -8
- data/app/components/blacklight/metadata_field_layout_component.rb +0 -18
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
- data/app/components/blacklight/response/facet_group_component.rb +29 -8
- data/app/components/blacklight/response/sort_component.rb +1 -1
- data/app/components/blacklight/response/spellcheck_component.rb +17 -6
- data/app/components/blacklight/response/view_type_button_component.rb +2 -6
- data/app/components/blacklight/response/view_type_component.rb +2 -4
- data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
- data/app/components/blacklight/search/sidebar_component.rb +17 -0
- data/app/components/blacklight/search_bar_component.html.erb +20 -15
- data/app/components/blacklight/search_bar_component.rb +2 -16
- data/app/components/blacklight/search_button_component.rb +3 -3
- data/app/components/blacklight/search_context_component.rb +43 -9
- data/app/components/blacklight/search_header_component.html.erb +2 -0
- data/app/components/blacklight/search_header_component.rb +6 -0
- data/app/components/blacklight/search_navbar_component.html.erb +5 -0
- data/app/components/blacklight/search_navbar_component.rb +34 -0
- data/app/components/blacklight/start_over_button_component.rb +5 -3
- data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
- data/app/components/blacklight/system/flash_message_component.rb +10 -1
- data/app/components/blacklight/system/modal_component.html.erb +1 -1
- data/app/components/blacklight/system/modal_component.rb +0 -2
- data/app/components/blacklight/top_navbar_component.html.erb +12 -0
- data/app/components/blacklight/top_navbar_component.rb +13 -0
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +13 -10
- data/app/controllers/concerns/blacklight/catalog.rb +21 -72
- data/app/controllers/concerns/blacklight/controller.rb +6 -43
- data/app/controllers/concerns/blacklight/search_context.rb +25 -7
- data/app/controllers/concerns/blacklight/search_history.rb +2 -0
- data/app/controllers/concerns/blacklight/searchable.rb +12 -1
- data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
- data/app/controllers/search_history_controller.rb +1 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +10 -308
- data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -137
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
- data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
- data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
- data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -30
- data/app/helpers/blacklight/url_helper_behavior.rb +13 -97
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/catalog_helper.rb +1 -0
- data/app/javascript/blacklight/bookmark_toggle.js +13 -19
- data/app/javascript/blacklight/button_focus.js +12 -10
- data/app/javascript/blacklight/checkbox_submit.js +68 -122
- data/app/javascript/blacklight/core.js +6 -5
- data/app/javascript/blacklight/index.js +13 -0
- data/app/javascript/blacklight/modal.js +99 -164
- data/app/javascript/blacklight/modalForm.js +60 -0
- data/app/javascript/blacklight/search_context.js +45 -55
- data/app/models/blacklight/facet_paginator.rb +3 -2
- data/app/models/blacklight/icon.rb +4 -2
- data/app/models/bookmark.rb +0 -2
- data/app/models/concerns/blacklight/configurable.rb +5 -4
- data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
- data/app/models/concerns/blacklight/document/attributes.rb +50 -0
- data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
- data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
- data/app/models/concerns/blacklight/document/email.rb +1 -0
- data/app/models/concerns/blacklight/document/export.rb +2 -1
- data/app/models/concerns/blacklight/document/extensions.rb +1 -0
- data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
- data/app/models/concerns/blacklight/document/sms.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +12 -20
- data/app/models/concerns/blacklight/suggest/response.rb +1 -0
- data/app/models/concerns/blacklight/user.rb +17 -8
- data/app/models/record_mailer.rb +13 -12
- data/app/models/search.rb +0 -1
- data/app/models/solr_document.rb +1 -0
- data/app/presenters/blacklight/clause_presenter.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +13 -21
- data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
- data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
- data/app/presenters/blacklight/field_presenter.rb +1 -0
- data/app/presenters/blacklight/index_presenter.rb +2 -40
- data/app/presenters/blacklight/json_presenter.rb +7 -5
- data/app/presenters/blacklight/rendering/join.rb +1 -1
- data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
- data/app/presenters/blacklight/show_presenter.rb +1 -9
- data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
- data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
- data/app/services/blacklight/field_retriever.rb +1 -8
- data/app/services/blacklight/search_service.rb +8 -7
- data/app/values/blacklight/types.rb +95 -11
- data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
- data/app/views/bookmarks/_tools.html.erb +7 -12
- data/app/views/catalog/_advanced_search_form.html.erb +0 -1
- data/app/views/catalog/_bookmark_control.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +1 -14
- data/app/views/catalog/_document.atom.builder +12 -14
- data/app/views/catalog/_document.html.erb +5 -3
- data/app/views/catalog/_document.rss.builder +2 -4
- data/app/views/catalog/_facets.html.erb +5 -4
- data/app/views/catalog/_home_text.html.erb +2 -14
- data/app/views/catalog/_search_form.html.erb +3 -3
- data/app/views/catalog/_search_header.html.erb +1 -2
- data/app/views/catalog/_search_results.html.erb +2 -2
- data/app/views/catalog/_search_sidebar.html.erb +5 -1
- data/app/views/catalog/_show_main_content.html.erb +10 -15
- data/app/views/catalog/_show_sidebar.html.erb +2 -2
- data/app/views/catalog/_show_tools.html.erb +7 -12
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/app/views/catalog/email_success.html.erb +5 -6
- data/app/views/catalog/facet.html.erb +4 -2
- data/app/views/catalog/index.atom.builder +12 -14
- data/app/views/catalog/index.html.erb +4 -1
- data/app/views/catalog/index.json.jbuilder +21 -19
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/catalog/opensearch.xml.builder +1 -1
- data/app/views/catalog/show.json.jbuilder +2 -0
- data/app/views/catalog/sms_success.html.erb +5 -6
- data/app/views/catalog/suggest.html.erb +3 -0
- data/app/views/layouts/blacklight/base.html.erb +23 -9
- data/app/views/search_history/index.html.erb +6 -2
- data/app/views/shared/_header_navbar.html.erb +1 -22
- data/app/views/shared/_modal.html.erb +3 -3
- data/blacklight.gemspec +6 -8
- data/config/importmap.rb +3 -0
- data/config/locales/blacklight.ar.yml +0 -1
- data/config/locales/blacklight.ca.yml +0 -1
- data/config/locales/blacklight.de.yml +0 -1
- data/config/locales/blacklight.en.yml +0 -1
- data/config/locales/blacklight.es.yml +0 -1
- data/config/locales/blacklight.fr.yml +0 -1
- data/config/locales/blacklight.hu.yml +0 -1
- data/config/locales/blacklight.it.yml +0 -1
- data/config/locales/blacklight.nl.yml +0 -1
- data/config/locales/blacklight.pt-BR.yml +0 -1
- data/config/locales/blacklight.sq.yml +0 -1
- data/config/locales/blacklight.zh.yml +0 -1
- data/config/routes.rb +3 -2
- data/db/migrate/20140202020201_create_searches.rb +1 -0
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
- data/lib/blacklight/abstract_repository.rb +1 -0
- data/lib/blacklight/configuration/context.rb +4 -4
- data/lib/blacklight/configuration/display_field.rb +7 -9
- data/lib/blacklight/configuration/facet_field.rb +17 -11
- data/lib/blacklight/configuration/field.rb +1 -0
- data/lib/blacklight/configuration/fields.rb +12 -15
- data/lib/blacklight/configuration/index_field.rb +1 -0
- data/lib/blacklight/configuration/null_display_field.rb +17 -0
- data/lib/blacklight/configuration/search_field.rb +1 -0
- data/lib/blacklight/configuration/show_field.rb +1 -0
- data/lib/blacklight/configuration/sort_field.rb +1 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +16 -6
- data/lib/blacklight/configuration.rb +318 -341
- data/lib/blacklight/engine.rb +10 -11
- data/lib/blacklight/exceptions.rb +2 -2
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
- data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
- data/lib/blacklight/parameters.rb +7 -21
- data/lib/blacklight/routes/exportable.rb +1 -0
- data/lib/blacklight/routes/searchable.rb +2 -1
- data/lib/blacklight/routes.rb +1 -0
- data/lib/blacklight/search_builder.rb +10 -10
- data/lib/blacklight/search_state/filter_field.rb +8 -25
- data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
- data/lib/blacklight/search_state.rb +23 -79
- data/lib/blacklight/solr/document.rb +1 -0
- data/lib/blacklight/solr/facet_paginator.rb +1 -0
- data/lib/blacklight/solr/repository.rb +1 -0
- data/lib/blacklight/solr/request.rb +3 -0
- data/lib/blacklight/solr/response/facets.rb +21 -5
- data/lib/blacklight/solr/response/group.rb +1 -0
- data/lib/blacklight/solr/response/group_response.rb +1 -0
- data/lib/blacklight/solr/response/more_like_this.rb +1 -0
- data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
- data/lib/blacklight/solr/response/params.rb +5 -4
- data/lib/blacklight/solr/response/response.rb +1 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/blacklight/solr/response.rb +4 -3
- data/lib/blacklight/solr/search_builder_behavior.rb +16 -32
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/blacklight.rb +8 -11
- data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
- data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
- data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
- data/lib/generators/blacklight/assets_generator.rb +13 -89
- data/lib/generators/blacklight/controller_generator.rb +3 -2
- data/lib/generators/blacklight/document_generator.rb +1 -0
- data/lib/generators/blacklight/install_generator.rb +5 -4
- data/lib/generators/blacklight/models_generator.rb +1 -0
- data/lib/generators/blacklight/search_builder_generator.rb +1 -0
- data/lib/generators/blacklight/solr_generator.rb +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +37 -7
- data/lib/generators/blacklight/templates/solr_document.rb +1 -1
- data/lib/generators/blacklight/test_support_generator.rb +4 -2
- data/lib/generators/blacklight/user_generator.rb +7 -9
- data/lib/railties/blacklight.rake +2 -3
- data/package.json +9 -12
- data/rollup.config.js +27 -0
- data/spec/components/blacklight/constraints_component_spec.rb +17 -13
- data/spec/components/blacklight/document_component_spec.rb +12 -22
- data/spec/components/blacklight/facet_component_spec.rb +2 -7
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
- data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +9 -7
- data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
- data/spec/components/blacklight/search_context_component_spec.rb +40 -0
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
- data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
- data/spec/controllers/bookmarks_controller_spec.rb +2 -3
- data/spec/controllers/catalog_controller_spec.rb +15 -129
- data/spec/features/autocomplete_spec.rb +1 -1
- data/spec/features/axe_spec.rb +1 -1
- data/spec/features/bookmarks_spec.rb +9 -0
- data/spec/features/facets_spec.rb +1 -1
- data/spec/features/search_context_spec.rb +4 -10
- data/spec/features/search_results_spec.rb +0 -33
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
- data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
- data/spec/helpers/blacklight_helper_spec.rb +3 -242
- data/spec/helpers/catalog_helper_spec.rb +7 -118
- data/spec/i18n_spec.rb +1 -0
- data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
- data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
- data/spec/lib/blacklight/parameters_spec.rb +1 -4
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
- data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
- data/spec/lib/blacklight/search_state_spec.rb +80 -198
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
- data/spec/models/blacklight/configuration_spec.rb +39 -51
- data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
- data/spec/models/blacklight/icon_spec.rb +31 -15
- data/spec/models/blacklight/search_builder_spec.rb +9 -9
- data/spec/models/blacklight/solr/document_spec.rb +3 -3
- data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
- data/spec/models/blacklight/solr/response_spec.rb +9 -2
- data/spec/models/blacklight/solr/search_builder_spec.rb +32 -23
- data/spec/models/blacklight/user_spec.rb +22 -0
- data/spec/models/solr_document_spec.rb +21 -3
- data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +2 -2
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
- data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
- data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
- data/spec/presenters/blacklight/index_presenter_spec.rb +2 -4
- data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
- data/spec/presenters/blacklight/show_presenter_spec.rb +10 -25
- data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
- data/spec/requests/load_suggestions_spec.rb +16 -0
- data/spec/routing/catalog_routing_spec.rb +2 -1
- data/spec/services/blacklight/search_service_spec.rb +31 -68
- data/spec/spec_helper.rb +3 -2
- data/spec/support/controller_level_helpers.rb +1 -2
- data/spec/support/features/search_helpers.rb +39 -0
- data/spec/support/features/session_helpers.rb +1 -0
- data/spec/support/features.rb +3 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
- data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +7 -54
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
- data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
- data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
- data/spec/views/catalog/index.html.erb_spec.rb +5 -6
- data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -19
- data/spec/views/catalog/show.html.erb_spec.rb +3 -25
- data/spec/views/catalog/show.json.jbuilder_spec.rb +2 -9
- data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
- data/tasks/blacklight.rake +6 -4
- metadata +66 -112
- data/.babelrc +0 -11
- data/app/assets/images/blacklight/list.svg +0 -1
- data/app/assets/images/blacklight/search.svg +0 -1
- data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
- data/app/components/blacklight/content_areas_shim.rb +0 -13
- data/app/controllers/concerns/blacklight/base.rb +0 -7
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
- data/app/controllers/concerns/blacklight/facet.rb +0 -69
- data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
- data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
- data/app/javascript/blacklight/autocomplete.js +0 -36
- data/app/javascript/blacklight/facet_load.js +0 -22
- data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
- data/app/views/catalog/_constraints_element.html.erb +0 -14
- data/app/views/catalog/_document_action.html.erb +0 -5
- data/app/views/catalog/_facet_group.html.erb +0 -5
- data/app/views/catalog/_facet_limit.html.erb +0 -3
- data/app/views/catalog/_index.html.erb +0 -1
- data/app/views/catalog/_index_header.html.erb +0 -22
- data/app/views/catalog/_previous_next_doc.html.erb +0 -2
- data/app/views/catalog/_show.html.erb +0 -6
- data/app/views/catalog/_show_header.html.erb +0 -2
- data/app/views/catalog/_thumbnail.html.erb +0 -1
- data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
- data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
- data/spec/controllers/blacklight/facet_spec.rb +0 -33
- data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -108
- data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
- data/spec/lib/blacklight/engine_spec.rb +0 -41
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
- data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
- data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
- data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
- data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
- data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
- data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
@@ -58,36 +58,3 @@ RSpec.describe "Search Results" do
|
|
58
58
|
expect(page).to have_xpath("//a[contains(@href, 77826928)]")
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
62
|
-
def search_for q
|
63
|
-
visit root_path
|
64
|
-
fill_in "q", with: q
|
65
|
-
click_button 'search'
|
66
|
-
end
|
67
|
-
|
68
|
-
def position_in_result_page(page, id)
|
69
|
-
i = -1
|
70
|
-
page.all(".index_title a").each_with_index do |link, idx|
|
71
|
-
i = (idx + 1) if link['href'] =~ Regexp.new(Regexp.escape(id) + "$")
|
72
|
-
end
|
73
|
-
i.to_i
|
74
|
-
end
|
75
|
-
|
76
|
-
def number_of_results_for_query(query)
|
77
|
-
visit root_path
|
78
|
-
fill_in "q", with: query
|
79
|
-
click_button "search"
|
80
|
-
get_number_of_results_from_page(page)
|
81
|
-
end
|
82
|
-
|
83
|
-
def number_of_results_from_page(page)
|
84
|
-
tmp_value = Capybara.ignore_hidden_elements
|
85
|
-
Capybara.ignore_hidden_elements = false
|
86
|
-
val = begin
|
87
|
-
page.find("meta[name=totalResults]")['content'].to_i
|
88
|
-
rescue StandardError
|
89
|
-
0
|
90
|
-
end
|
91
|
-
Capybara.ignore_hidden_elements = tmp_value
|
92
|
-
val
|
93
|
-
end
|
@@ -8,14 +8,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
8
8
|
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
9
9
|
end
|
10
10
|
|
11
|
-
describe "#index_fields" do
|
12
|
-
it "passes through the configuration" do
|
13
|
-
allow(Deprecation).to receive(:warn)
|
14
|
-
allow(blacklight_config).to receive_messages(index_fields: config_value)
|
15
|
-
expect(helper.index_fields).to eq config_value
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
11
|
describe "#active_sort_fields" do
|
20
12
|
it "restricts the configured sort fields to only those that should be displayed" do
|
21
13
|
allow(blacklight_config).to receive_messages(sort_fields: { a: double(if: false, unless: false), b: double(if: true, unless: true) })
|
@@ -23,17 +15,9 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
23
15
|
end
|
24
16
|
end
|
25
17
|
|
26
|
-
describe "#document_show_fields" do
|
27
|
-
it "passes through the configuration" do
|
28
|
-
allow(Deprecation).to receive(:warn)
|
29
|
-
allow(blacklight_config).to receive_messages(show_fields: config_value)
|
30
|
-
expect(helper.document_show_fields).to eq config_value
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
18
|
describe "#default_document_index_view_type" do
|
35
19
|
it "uses the first view with default set to true" do
|
36
|
-
blacklight_config.view.a
|
20
|
+
blacklight_config.view.a
|
37
21
|
blacklight_config.view.b(default: true)
|
38
22
|
expect(helper.default_document_index_view_type).to eq :b
|
39
23
|
end
|
@@ -71,62 +55,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
71
55
|
end
|
72
56
|
end
|
73
57
|
|
74
|
-
describe "#has_alternative_views?" do
|
75
|
-
subject { helper.has_alternative_views? }
|
76
|
-
|
77
|
-
before do
|
78
|
-
blacklight_config.view.clear
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "with a single view defined" do
|
82
|
-
it { is_expected.to be false }
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "with multiple views defined" do
|
86
|
-
before do
|
87
|
-
blacklight_config.view.abc
|
88
|
-
blacklight_config.view.xyz
|
89
|
-
end
|
90
|
-
|
91
|
-
it { is_expected.to be true }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "#spell_check_max" do
|
96
|
-
it "passes through the configuration" do
|
97
|
-
allow(blacklight_config).to receive_messages(spell_max: config_value)
|
98
|
-
expect(helper.spell_check_max).to eq config_value
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "#document_show_link_field" do
|
103
|
-
let(:document) { SolrDocument.new id: 123, a: 1, b: 2, c: 3 }
|
104
|
-
|
105
|
-
before do
|
106
|
-
allow(Deprecation).to receive(:warn)
|
107
|
-
end
|
108
|
-
|
109
|
-
it "allows single values" do
|
110
|
-
blacklight_config.index.title_field = :a
|
111
|
-
f = helper.document_show_link_field document
|
112
|
-
expect(f).to eq :a
|
113
|
-
end
|
114
|
-
|
115
|
-
it "retrieves the first field with data" do
|
116
|
-
blacklight_config.index.title_field = [:zzz, :b]
|
117
|
-
f = helper.document_show_link_field document
|
118
|
-
expect(f).to eq :b
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "#view_label" do
|
123
|
-
it "looks up the label to display for the view" do
|
124
|
-
allow(blacklight_config).to receive(:view).and_return("my_view" => double(display_label: "some label"))
|
125
|
-
|
126
|
-
helper.view_label "my_view"
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
58
|
describe "#field_label" do
|
131
59
|
it "looks up the label as an i18n string" do
|
132
60
|
expect(helper).to receive(:t).with(:some_key, default: []).and_return "my label"
|
@@ -148,32 +76,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
148
76
|
end
|
149
77
|
end
|
150
78
|
|
151
|
-
describe "#default_per_page" do
|
152
|
-
before do
|
153
|
-
expect(Deprecation).to receive(:warn)
|
154
|
-
end
|
155
|
-
|
156
|
-
context "when default_per_page is configured" do
|
157
|
-
before do
|
158
|
-
blacklight_config.default_per_page = 42
|
159
|
-
end
|
160
|
-
|
161
|
-
it "is the configured value" do
|
162
|
-
expect(helper.default_per_page).to eq 42
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context "when default_per_page is not configured" do
|
167
|
-
before do
|
168
|
-
blacklight_config.per_page = [11, 22]
|
169
|
-
end
|
170
|
-
|
171
|
-
it "is the first per-page value if a default isn't set" do
|
172
|
-
expect(helper.default_per_page).to eq 11
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
79
|
describe "#default_sort_field" do
|
178
80
|
it "is the configured default field" do
|
179
81
|
allow(helper).to receive_messages(blacklight_config: double(sort_fields: { a: double(default: nil), b: double(key: 'b', default: true) }))
|
@@ -203,11 +105,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
203
105
|
describe "#should_render_field?" do
|
204
106
|
let(:field_config) { double('field config', if: true, unless: false) }
|
205
107
|
|
206
|
-
before do
|
207
|
-
allow(Deprecation).to receive(:warn)
|
208
|
-
allow(helper).to receive_messages(document_has_value?: true)
|
209
|
-
end
|
210
|
-
|
211
108
|
it "is true" do
|
212
109
|
expect(helper.should_render_field?(field_config)).to be true
|
213
110
|
end
|
@@ -223,39 +120,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
223
120
|
end
|
224
121
|
end
|
225
122
|
|
226
|
-
describe "#search_field_options_for_select" do
|
227
|
-
before do
|
228
|
-
@config = Blacklight::Configuration.new do |config|
|
229
|
-
config.default_solr_params = { qt: 'search' }
|
230
|
-
|
231
|
-
config.add_search_field 'all_fields', label: 'All Fields'
|
232
|
-
config.add_search_field 'title', qt: 'title_search'
|
233
|
-
config.add_search_field 'author', qt: 'author_search'
|
234
|
-
config.add_search_field 'subject', qt: 'subject_search'
|
235
|
-
config.add_search_field 'no_display', qt: 'something', include_in_simple_select: false
|
236
|
-
end
|
237
|
-
|
238
|
-
allow(helper).to receive_messages(blacklight_config: @config)
|
239
|
-
end
|
240
|
-
|
241
|
-
it "returns proper options_for_select arguments" do
|
242
|
-
select_arguments = helper.search_field_options_for_select
|
243
|
-
|
244
|
-
select_arguments.each do |(label, key)|
|
245
|
-
config_hash = @config.search_fields[key]
|
246
|
-
|
247
|
-
expect(label).to eq config_hash.label
|
248
|
-
expect(key).to eq config_hash.key
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
it "does not include fields in select if :display_in_simple_search=>false" do
|
253
|
-
select_arguments = helper.search_field_options_for_select
|
254
|
-
|
255
|
-
expect(select_arguments).not_to include(["No Display", "no_display"])
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
123
|
context 'labels' do
|
260
124
|
let(:field_config) { { 'my-key' => double('field', display_label: 'My Field') } }
|
261
125
|
|
@@ -275,7 +139,7 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
275
139
|
end
|
276
140
|
|
277
141
|
it 'handles a missing field' do
|
278
|
-
expect(helper.label_for_search_field(nil)).to
|
142
|
+
expect(helper.label_for_search_field(nil)).to be_nil
|
279
143
|
end
|
280
144
|
end
|
281
145
|
|
@@ -3,397 +3,10 @@
|
|
3
3
|
RSpec.describe Blacklight::FacetsHelperBehavior do
|
4
4
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
5
5
|
|
6
|
-
around { |test| Deprecation.silence(described_class) { test.call } }
|
7
|
-
|
8
6
|
before do
|
9
7
|
allow(helper).to receive(:blacklight_config).and_return blacklight_config
|
10
8
|
end
|
11
9
|
|
12
|
-
describe "has_facet_values?" do
|
13
|
-
let(:empty) { double(items: [], name: 'empty') }
|
14
|
-
let(:response) { instance_double(Blacklight::Solr::Response) }
|
15
|
-
|
16
|
-
it "is true if there are any facets to display" do
|
17
|
-
a = double(items: [1, 2], name: 'a')
|
18
|
-
b = double(items: %w[b c], name: 'b')
|
19
|
-
fields = [a, b, empty]
|
20
|
-
expect(helper.has_facet_values?(fields, response)).to be true
|
21
|
-
end
|
22
|
-
|
23
|
-
it "is false if all facets are empty" do
|
24
|
-
expect(helper.has_facet_values?([empty], response)).to be false
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "different config" do
|
28
|
-
let(:blacklight_config) { Blacklight::Configuration.new { |config| config.add_facet_field 'basic_field', if: false } }
|
29
|
-
|
30
|
-
it "is false if no facets are displayable" do
|
31
|
-
a = double(items: [1, 2], name: 'basic_field')
|
32
|
-
expect(helper.has_facet_values?([a], response)).to be false
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "should_render_facet?" do
|
38
|
-
let(:blacklight_config) do
|
39
|
-
Blacklight::Configuration.new do |config|
|
40
|
-
config.add_facet_field 'basic_field'
|
41
|
-
config.add_facet_field 'no_show', show: false
|
42
|
-
config.add_facet_field 'helper_show', show: :my_custom_check
|
43
|
-
config.add_facet_field 'helper_with_an_arg_show', show: :my_custom_check_with_an_arg
|
44
|
-
config.add_facet_field 'lambda_show', show: ->(_context, _config, _field) { true }
|
45
|
-
config.add_facet_field 'lambda_no_show', show: ->(_context, _config, _field) { false }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
it "renders facets with items" do
|
50
|
-
a = double(items: [1, 2], name: 'basic_field')
|
51
|
-
expect(helper.should_render_facet?(a)).to be true
|
52
|
-
end
|
53
|
-
|
54
|
-
it "does not render facets without items" do
|
55
|
-
empty = double(items: [], name: 'basic_field')
|
56
|
-
expect(helper.should_render_facet?(empty)).to be false
|
57
|
-
end
|
58
|
-
|
59
|
-
it "does not render facets where show is set to false" do
|
60
|
-
a = double(items: [1, 2], name: 'no_show')
|
61
|
-
expect(helper.should_render_facet?(a)).to be false
|
62
|
-
end
|
63
|
-
|
64
|
-
it "calls a helper to determine if it should render a field" do
|
65
|
-
allow(controller).to receive_messages(my_custom_check: true)
|
66
|
-
a = double(items: [1, 2], name: 'helper_show')
|
67
|
-
expect(helper.should_render_facet?(a)).to be true
|
68
|
-
end
|
69
|
-
|
70
|
-
it "calls a helper to determine if it should render a field" do
|
71
|
-
a = double(items: [1, 2], name: 'helper_with_an_arg_show')
|
72
|
-
allow(controller).to receive(:my_custom_check_with_an_arg).with(blacklight_config.facet_fields['helper_with_an_arg_show'], a).and_return(true)
|
73
|
-
expect(helper.should_render_facet?(a)).to be true
|
74
|
-
end
|
75
|
-
|
76
|
-
it "evaluates a Proc to determine if it should render a field" do
|
77
|
-
a = double(items: [1, 2], name: 'lambda_show')
|
78
|
-
expect(helper.should_render_facet?(a)).to be true
|
79
|
-
a = double(items: [1, 2], name: 'lambda_no_show')
|
80
|
-
expect(helper.should_render_facet?(a)).to be false
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe "should_collapse_facet?" do
|
85
|
-
let(:blacklight_config) do
|
86
|
-
Blacklight::Configuration.new do |config|
|
87
|
-
config.add_facet_field 'basic_field'
|
88
|
-
config.add_facet_field 'no_collapse', collapse: false
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it "is collapsed by default" do
|
93
|
-
expect(helper.should_collapse_facet?(blacklight_config.facet_fields['basic_field'])).to be true
|
94
|
-
end
|
95
|
-
|
96
|
-
it "does not be collapsed if the configuration says so" do
|
97
|
-
expect(helper.should_collapse_facet?(blacklight_config.facet_fields['no_collapse'])).to be false
|
98
|
-
end
|
99
|
-
|
100
|
-
it "does not be collapsed if it is in the params" do
|
101
|
-
params[:f] = ActiveSupport::HashWithIndifferentAccess.new(basic_field: [1], no_collapse: [2])
|
102
|
-
expect(helper.should_collapse_facet?(blacklight_config.facet_fields['basic_field'])).to be false
|
103
|
-
expect(helper.should_collapse_facet?(blacklight_config.facet_fields['no_collapse'])).to be false
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "facet_by_field_name" do
|
108
|
-
around { |test| Deprecation.silence(Blacklight::Facet) { test.call } }
|
109
|
-
|
110
|
-
it "retrieves the facet from the response given a string" do
|
111
|
-
facet_config = double(query: nil, field: 'b', key: 'a')
|
112
|
-
facet_field = double
|
113
|
-
allow(helper).to receive(:facet_configuration_for_field).with('b').and_return(facet_config)
|
114
|
-
response = instance_double(Blacklight::Solr::Response, aggregations: { 'b' => facet_field })
|
115
|
-
|
116
|
-
expect(helper.facet_by_field_name('b', response)).to eq facet_field
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "render_facet_partials" do
|
121
|
-
let(:a) { double(items: [1, 2]) }
|
122
|
-
let(:b) { double(items: %w[b c]) }
|
123
|
-
let(:response) { instance_double(Blacklight::Solr::Response) }
|
124
|
-
|
125
|
-
it "tries to render all provided facets" do
|
126
|
-
empty = double(items: [])
|
127
|
-
fields = [a, b, empty]
|
128
|
-
expect(helper).to receive(:render_facet_limit).with(a, {})
|
129
|
-
expect(helper).to receive(:render_facet_limit).with(b, {})
|
130
|
-
expect(helper).to receive(:render_facet_limit).with(empty, {})
|
131
|
-
helper.render_facet_partials fields, response: response
|
132
|
-
end
|
133
|
-
|
134
|
-
it "defaults to the configured facets" do
|
135
|
-
allow(Deprecation).to receive(:warn)
|
136
|
-
expect(helper).to receive(:facet_field_names) { [a, b] }
|
137
|
-
expect(helper).to receive(:render_facet_limit).with(a, {})
|
138
|
-
expect(helper).to receive(:render_facet_limit).with(b, {})
|
139
|
-
helper.render_facet_partials
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe "render_facet_limit" do
|
144
|
-
let(:blacklight_config) do
|
145
|
-
Blacklight::Configuration.new do |config|
|
146
|
-
config.add_facet_field 'basic_field'
|
147
|
-
config.add_facet_field 'component_field', component: true
|
148
|
-
config.add_facet_field 'non_rendering_component_field', component: true, if: false
|
149
|
-
config.add_facet_field 'pivot_facet_field', pivot: %w[a b]
|
150
|
-
config.add_facet_field 'my_pivot_facet_field_with_custom_partial', partial: 'custom_facet_partial', pivot: %w[a b]
|
151
|
-
config.add_facet_field 'my_facet_field_with_custom_partial', partial: 'custom_facet_partial'
|
152
|
-
end
|
153
|
-
end
|
154
|
-
let(:mock_custom_facet) { double(name: 'my_facet_field_with_custom_partial', items: [1, 2, 3]) }
|
155
|
-
|
156
|
-
it "sets basic local variables" do
|
157
|
-
mock_facet = double(name: 'basic_field', items: [1, 2, 3])
|
158
|
-
expect(helper).to receive(:render).with(hash_including(partial: 'facet_limit',
|
159
|
-
locals: {
|
160
|
-
field_name: 'basic_field',
|
161
|
-
facet_field: helper.blacklight_config.facet_fields['basic_field'],
|
162
|
-
display_facet: mock_facet
|
163
|
-
}))
|
164
|
-
helper.render_facet_limit(mock_facet)
|
165
|
-
end
|
166
|
-
|
167
|
-
it "renders a facet _not_ declared in the configuration" do
|
168
|
-
mock_facet = double(name: 'asdf', items: [1, 2, 3])
|
169
|
-
expect(helper).to receive(:render).with(hash_including(partial: 'facet_limit'))
|
170
|
-
helper.render_facet_limit(mock_facet)
|
171
|
-
end
|
172
|
-
|
173
|
-
it "gets the partial name from the configuration" do
|
174
|
-
expect(helper).to receive(:render).with(hash_including(partial: 'custom_facet_partial'))
|
175
|
-
helper.render_facet_limit(mock_custom_facet)
|
176
|
-
end
|
177
|
-
|
178
|
-
it "uses a partial layout for rendering the facet frame" do
|
179
|
-
expect(helper).to receive(:render).with(hash_including(layout: 'facet_layout'))
|
180
|
-
helper.render_facet_limit(mock_custom_facet)
|
181
|
-
end
|
182
|
-
|
183
|
-
it "allows the caller to opt-out of facet layouts" do
|
184
|
-
expect(helper).to receive(:render).with(hash_including(layout: nil))
|
185
|
-
helper.render_facet_limit(mock_custom_facet, layout: nil)
|
186
|
-
end
|
187
|
-
|
188
|
-
it "renders the facet_pivot partial for pivot facets" do
|
189
|
-
mock_facet = double(name: 'pivot_facet_field', items: [1, 2, 3])
|
190
|
-
expect(helper).to receive(:render).with(hash_including(partial: 'facet_pivot'))
|
191
|
-
helper.render_facet_limit(mock_facet)
|
192
|
-
end
|
193
|
-
|
194
|
-
it "lets you override the rendered partial for pivot facets" do
|
195
|
-
mock_facet = double(name: 'my_pivot_facet_field_with_custom_partial', items: [1, 2, 3])
|
196
|
-
expect(helper).to receive(:render).with(hash_including(partial: 'custom_facet_partial'))
|
197
|
-
helper.render_facet_limit(mock_facet)
|
198
|
-
end
|
199
|
-
|
200
|
-
it "lets you override the rendered partial for pivot facets" do
|
201
|
-
mock_facet = double(name: 'component_field')
|
202
|
-
expect(helper).to receive(:render).with(an_instance_of(Blacklight::FacetComponent))
|
203
|
-
helper.render_facet_limit(mock_facet)
|
204
|
-
end
|
205
|
-
|
206
|
-
it "lets you override the rendered partial for pivot facets" do
|
207
|
-
mock_facet = double(name: 'non_rendering_component_field')
|
208
|
-
expect(helper.render_facet_limit(mock_facet)).to be_blank
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "render_facet_limit_list" do
|
213
|
-
subject { helper.render_facet_limit_list(paginator, 'type_solr_field') }
|
214
|
-
|
215
|
-
let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
|
216
|
-
let(:f2) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') }
|
217
|
-
let(:paginator) { Blacklight::Solr::FacetPaginator.new([f1, f2], limit: 10) }
|
218
|
-
|
219
|
-
before do
|
220
|
-
allow(helper).to receive(:search_action_path) do |*args|
|
221
|
-
search_catalog_path *args
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
it "draws a list of elements" do
|
226
|
-
expect(subject).to have_selector 'li', count: 2
|
227
|
-
expect(subject).to have_selector 'li:first-child a.facet-select', text: 'Book'
|
228
|
-
expect(subject).to have_selector 'li:nth-child(2) a.facet-select', text: 'Musical Score'
|
229
|
-
end
|
230
|
-
|
231
|
-
context "when one of the facet items is rendered as nil" do
|
232
|
-
# An app may override render_facet_item to filter out some undesired facet items by returning nil.
|
233
|
-
before do
|
234
|
-
allow(helper.method(:render_facet_item)).to receive(:owner).and_return(self.class)
|
235
|
-
# allow_any_instance_of(Blacklight::FacetItemComponent).to receive(:overridden_helper_methods?).and_return(true)
|
236
|
-
allow(helper).to receive(:render_facet_item).and_return('<a class="facet-select">Book</a>'.html_safe, nil)
|
237
|
-
end
|
238
|
-
|
239
|
-
around { |test| Deprecation.silence(Blacklight::FacetItemComponent) { test.call } }
|
240
|
-
|
241
|
-
it "draws a list of elements" do
|
242
|
-
expect(subject).to have_selector 'li', count: 1
|
243
|
-
expect(subject).to have_selector 'li:first-child a.facet-select', text: 'Book'
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
describe "facet_field_in_params?" do
|
249
|
-
before do
|
250
|
-
blacklight_config.add_facet_field "some-field"
|
251
|
-
end
|
252
|
-
|
253
|
-
it "checks if the facet field is selected in the user params" do
|
254
|
-
allow(helper).to receive_messages(params: { f: { "some-field" => ["x"] } })
|
255
|
-
expect(helper).to be_facet_field_in_params("some-field")
|
256
|
-
expect(helper.facet_field_in_params?("other-field")).not_to be true
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
describe "facet_params" do
|
261
|
-
let(:facet_config) { ["some-field"] }
|
262
|
-
let(:params) { { f: { "some-field" => ["x"] } } }
|
263
|
-
|
264
|
-
before do
|
265
|
-
blacklight_config.add_facet_field *facet_config
|
266
|
-
allow(helper).to receive_messages(params: params)
|
267
|
-
end
|
268
|
-
|
269
|
-
it "extracts the facet parameters for a field" do
|
270
|
-
expect(helper.facet_params("some-field")).to match_array ["x"]
|
271
|
-
end
|
272
|
-
|
273
|
-
context "a facet is not keyed by the field name" do
|
274
|
-
let(:facet_config) { ["some-key", { field: "some-field" }] }
|
275
|
-
let(:params) { { f: { "some-key" => ["x"] } } }
|
276
|
-
|
277
|
-
it "uses the blacklight key to extract the right fields" do
|
278
|
-
expect(helper.facet_params("some-key")).to match_array ["x"]
|
279
|
-
end
|
280
|
-
|
281
|
-
it "looks up facet params by configured field or key values" do
|
282
|
-
expect(helper.facet_params("some-field")).to match_array ["x"]
|
283
|
-
end
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
describe "facet_field_in_params?" do
|
288
|
-
let(:search_state) { double }
|
289
|
-
|
290
|
-
before do
|
291
|
-
allow(helper).to receive_messages(search_state: search_state)
|
292
|
-
end
|
293
|
-
|
294
|
-
it "checks if any value is selected for a given facet" do
|
295
|
-
allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet')).and_return(true)
|
296
|
-
expect(helper.facet_field_in_params?("some-facet")).to eq true
|
297
|
-
end
|
298
|
-
|
299
|
-
it "is false if no value for facet is selected" do
|
300
|
-
allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet')).and_return(false)
|
301
|
-
expect(helper.facet_field_in_params?("some-facet")).to eq false
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
describe "facet_in_params?" do
|
306
|
-
let(:search_state) { double }
|
307
|
-
|
308
|
-
before do
|
309
|
-
allow(helper).to receive_messages(search_state: search_state)
|
310
|
-
allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet'), value: 'x').and_return(true)
|
311
|
-
allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet'), value: 'y').and_return(false)
|
312
|
-
end
|
313
|
-
|
314
|
-
it "checks if a particular value is set in the facet params" do
|
315
|
-
expect(helper.facet_in_params?("some-facet", "x")).to eq true
|
316
|
-
expect(helper.facet_in_params?("some-facet", "y")).to eq false
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
describe "render_facet_value" do
|
321
|
-
let(:item) { double(value: 'A', hits: 10) }
|
322
|
-
let(:search_state) { double(has_facet?: false, add_facet_params_and_redirect: { controller: 'catalog' }) }
|
323
|
-
|
324
|
-
before do
|
325
|
-
allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: nil, item_presenter: nil))
|
326
|
-
allow(helper).to receive(:facet_display_value).and_return('Z')
|
327
|
-
allow(helper).to receive(:search_state).and_return(search_state)
|
328
|
-
allow(helper).to receive(:search_action_path) do |*args|
|
329
|
-
search_catalog_path *args
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
describe "simple case" do
|
334
|
-
let(:expected_html) { '<span class="facet-label"><a class="facet-select" rel="nofollow" href="/catalog">Z</a></span><span class="facet-count">10</span>' }
|
335
|
-
|
336
|
-
it "uses facet_display_value" do
|
337
|
-
result = helper.render_facet_value('simple_field', item)
|
338
|
-
expect(result).to be_equivalent_to(expected_html).respecting_element_order
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
describe "when :url_method is set" do
|
343
|
-
let(:expected_html) { '<span class="facet-label"><a class="facet-select" rel="nofollow" href="/blabla">Z</a></span><span class="facet-count">10</span>' }
|
344
|
-
|
345
|
-
it "uses that method" do
|
346
|
-
allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: :test_method, item_presenter: nil))
|
347
|
-
allow(helper).to receive(:test_method).with('simple_field', item).and_return('/blabla')
|
348
|
-
result = helper.render_facet_value('simple_field', item)
|
349
|
-
expect(result).to be_equivalent_to(expected_html).respecting_element_order
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
describe "when :suppress_link is set" do
|
354
|
-
let(:expected_html) { '<span class="facet-label">Z</span><span class="facet-count">10</span>' }
|
355
|
-
|
356
|
-
it "suppresses the link" do
|
357
|
-
result = helper.render_facet_value('simple_field', item, suppress_link: true)
|
358
|
-
expect(result).to be_equivalent_to(expected_html).respecting_element_order
|
359
|
-
end
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
describe "#facet_display_value" do
|
364
|
-
it "justs be the facet value for an ordinary facet" do
|
365
|
-
allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(query: nil, date: nil, helper_method: nil, url_method: nil, item_presenter: nil))
|
366
|
-
expect(helper.facet_display_value('simple_field', 'asdf')).to eq 'asdf'
|
367
|
-
end
|
368
|
-
|
369
|
-
it "allows you to pass in a :helper_method argument to the configuration" do
|
370
|
-
allow(helper).to receive(:facet_configuration_for_field).with('helper_field').and_return(double(query: nil, date: nil, url_method: nil, helper_method: :my_facet_value_renderer, item_presenter: nil))
|
371
|
-
allow(helper).to receive(:my_facet_value_renderer).with('qwerty').and_return('abc')
|
372
|
-
expect(helper.facet_display_value('helper_field', 'qwerty')).to eq 'abc'
|
373
|
-
end
|
374
|
-
|
375
|
-
it "extracts the configuration label for a query facet" do
|
376
|
-
allow(helper).to receive(:facet_configuration_for_field).with('query_facet').and_return(double(query: { 'query_key' => { label: 'XYZ' } }, date: nil, helper_method: nil, url_method: nil, item_presenter: nil))
|
377
|
-
expect(helper.facet_display_value('query_facet', 'query_key')).to eq 'XYZ'
|
378
|
-
end
|
379
|
-
|
380
|
-
it "localizes the label for date-type facets" do
|
381
|
-
allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => true, :query => nil, :helper_method => nil, :url_method => nil, :item_presenter => nil))
|
382
|
-
expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq 'Sun, 01 Jan 2012 00:00:00 +0000'
|
383
|
-
end
|
384
|
-
|
385
|
-
it "localizes the label for date-type facets with the supplied localization options" do
|
386
|
-
allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => { format: :short }, :query => nil, :helper_method => nil, :url_method => nil, :item_presenter => nil))
|
387
|
-
expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq '01 Jan 00:00'
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
describe "#facet_field_id" do
|
392
|
-
it "is the parameterized version of the facet field" do
|
393
|
-
expect(helper.facet_field_id(double(key: 'some field'))).to eq "facet-some-field"
|
394
|
-
end
|
395
|
-
end
|
396
|
-
|
397
10
|
describe '#facet_field_presenter' do
|
398
11
|
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'x').normalize! }
|
399
12
|
let(:display_facet) { double }
|
@@ -11,5 +11,13 @@ RSpec.describe Blacklight::IconHelperBehavior do
|
|
11
11
|
it 'adds classes to the wrappering element' do
|
12
12
|
expect(icon).to have_css '.custom-class svg'
|
13
13
|
end
|
14
|
+
|
15
|
+
context 'with backwards compatible arguments' do
|
16
|
+
subject(:icon) { helper.blacklight_icon(:search, aria_hidden: true, label: 'blah') }
|
17
|
+
|
18
|
+
it 'adds aria attributes' do
|
19
|
+
expect(icon).to have_css '[aria-hidden="true"][aria-label="blah"]'
|
20
|
+
end
|
21
|
+
end
|
14
22
|
end
|
15
23
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
4
|
-
around { |test| Deprecation.silence(described_class) { test.call } }
|
5
|
-
|
6
4
|
describe "#type_field_to_partial_name" do
|
7
5
|
subject { helper.send(:type_field_to_partial_name, document, value) }
|
8
6
|
|
@@ -58,7 +56,7 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
|
58
56
|
let(:document) { SolrDocument.new }
|
59
57
|
|
60
58
|
it "is the default value" do
|
61
|
-
expect(helper.document_partial_name
|
59
|
+
expect(helper.send(:document_partial_name, document)).to eq 'default'
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
@@ -70,11 +68,11 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
|
70
68
|
end
|
71
69
|
|
72
70
|
it "uses the value in the configured display type field" do
|
73
|
-
expect(helper.document_partial_name
|
71
|
+
expect(helper.send(:document_partial_name, document)).to eq 'xyz'
|
74
72
|
end
|
75
73
|
|
76
74
|
it "uses the value in the configured display type field if the action-specific field is empty" do
|
77
|
-
expect(helper.document_partial_name
|
75
|
+
expect(helper.send(:document_partial_name, document, :some_action)).to eq 'xyz'
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
@@ -87,8 +85,8 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
|
87
85
|
end
|
88
86
|
|
89
87
|
it "uses the value in the action-specific fields" do
|
90
|
-
expect(helper.document_partial_name
|
91
|
-
expect(helper.document_partial_name
|
88
|
+
expect(helper.send(:document_partial_name, document, :media)).to eq 'xyz'
|
89
|
+
expect(helper.send(:document_partial_name, document, :metadata)).to eq 'abc'
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|