blacklight 7.34.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 -3
- data/.github/workflows/ruby.yml +32 -127
- data/.rubocop.yml +241 -2
- data/.rubocop_todo.yml +214 -270
- data/Gemfile +7 -10
- 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 +374 -489
- 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/_facets.scss +72 -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 +2 -2
- data/app/components/blacklight/advanced_search_form_component.rb +8 -10
- data/app/components/blacklight/constraints_component.rb +27 -37
- data/app/components/blacklight/document/action_component.rb +9 -9
- data/app/components/blacklight/document/actions_component.rb +2 -2
- 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 +14 -53
- data/app/components/blacklight/document_metadata_component.html.erb +2 -4
- data/app/components/blacklight/document_metadata_component.rb +5 -10
- 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 +3 -3
- 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 +3 -3
- 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.rb +1 -1
- 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.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +24 -8
- data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
- 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/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/pagination_component.rb +1 -5
- 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 +3 -5
- 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/start_over_button_component.rb +5 -3
- data/app/components/blacklight/system/dropdown_component.rb +2 -2
- data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
- data/app/components/blacklight/system/flash_message_component.rb +11 -2
- 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 +1 -1
- data/app/components/blacklight/top_navbar_component.rb +0 -4
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +10 -5
- data/app/controllers/concerns/blacklight/catalog.rb +21 -75
- data/app/controllers/concerns/blacklight/controller.rb +3 -41
- 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 +12 -310
- 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 -31
- 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/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/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/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 +0 -4
- 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/_facet_layout.html.erb +2 -2
- 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 +2 -2
- 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 +11 -16
- data/app/views/catalog/_show_sidebar.html.erb +2 -2
- data/app/views/catalog/_show_tools.html.erb +8 -14
- 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 +7 -5
- 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 +19 -19
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/catalog/opensearch.xml.builder +1 -1
- 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 +13 -2
- data/app/views/search_history/index.html.erb +6 -2
- data/app/views/shared/_modal.html.erb +3 -3
- data/blacklight.gemspec +8 -9
- 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 -2
- 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/docker-compose.yml +0 -1
- 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 +294 -358
- data/lib/blacklight/engine.rb +8 -13
- 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 +3 -14
- data/lib/blacklight/solr/request.rb +1 -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 +17 -34
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/blacklight.rb +7 -10
- 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 +4 -3
- 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 +34 -8
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -69
- data/lib/generators/blacklight/test_support_generator.rb +4 -2
- data/lib/generators/blacklight/user_generator.rb +7 -9
- data/lib/railties/blacklight.rake +6 -7
- data/package.json +10 -13
- data/rollup.config.js +27 -0
- data/spec/components/blacklight/constraints_component_spec.rb +17 -13
- data/spec/components/blacklight/document_component_spec.rb +23 -82
- 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 +10 -9
- data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- 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 +13 -135
- data/spec/features/advanced_search_spec.rb +0 -56
- data/spec/features/autocomplete_spec.rb +1 -1
- data/spec/features/axe_spec.rb +1 -6
- data/spec/features/bookmarks_spec.rb +1 -1
- 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/features/sitelinks_search_box.rb +13 -0
- 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 +17 -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/repository_spec.rb +0 -27
- 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 +24 -31
- data/spec/models/blacklight/user_spec.rb +22 -0
- 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 +20 -29
- 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 +6 -4
- 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/support/view_component_capybara_test_helpers.rb +8 -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 +5 -66
- 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 +2 -2
- data/spec/views/catalog/show.html.erb_spec.rb +3 -25
- data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
- data/tasks/blacklight.rake +6 -4
- metadata +79 -126
- 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 -12
- 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/components/blacklight/header_component_spec.rb +0 -20
- data/spec/controllers/blacklight/facet_spec.rb +0 -33
- data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
- 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 -101
- 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/support/view_component_test_helpers.rb +0 -35
- 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
@@ -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
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::UrlHelperBehavior do
|
4
|
-
around { |test| Deprecation.silence(described_class) { test.call } }
|
5
|
-
|
6
4
|
let(:blacklight_config) do
|
7
5
|
Blacklight::Configuration.new.configure do |config|
|
8
6
|
config.index.title_field = 'title_tsim'
|
@@ -14,6 +12,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
14
12
|
|
15
13
|
before do
|
16
14
|
allow(controller).to receive(:controller_name).and_return('test')
|
15
|
+
allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
|
17
16
|
allow(helper).to receive(:search_action_path) do |*args|
|
18
17
|
search_catalog_url *args
|
19
18
|
end
|
@@ -23,54 +22,6 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
23
22
|
allow(helper).to receive(:search_session).and_return({})
|
24
23
|
end
|
25
24
|
|
26
|
-
describe "url_for_document" do
|
27
|
-
let(:controller_class) { ::CatalogController.new }
|
28
|
-
let(:doc) { SolrDocument.new }
|
29
|
-
|
30
|
-
before do
|
31
|
-
allow(helper).to receive_messages(controller: controller_class)
|
32
|
-
allow(helper).to receive_messages(controller_name: controller_class.controller_name)
|
33
|
-
allow(helper).to receive_messages(params: parameter_class.new)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "is a polymorphic routing-ready object" do
|
37
|
-
expect(helper.url_for_document(doc)).to eq doc
|
38
|
-
end
|
39
|
-
|
40
|
-
it "allows for custom show routes" do
|
41
|
-
helper.blacklight_config.show.route = { controller: 'catalog' }
|
42
|
-
expect(helper.url_for_document(doc)).to eq(controller: 'catalog', action: :show, id: doc)
|
43
|
-
end
|
44
|
-
|
45
|
-
context "within bookmarks" do
|
46
|
-
let(:controller_class) { ::BookmarksController.new }
|
47
|
-
|
48
|
-
it "uses polymorphic routing" do
|
49
|
-
expect(helper.url_for_document(doc)).to eq doc
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "within an alternative catalog controller" do
|
54
|
-
let(:controller_class) { ::AlternateController.new }
|
55
|
-
|
56
|
-
before do
|
57
|
-
helper.blacklight_config.show.route = { controller: :current }
|
58
|
-
allow(helper).to receive(:params).and_return(parameter_class.new(controller: 'alternate'))
|
59
|
-
end
|
60
|
-
|
61
|
-
it "supports the :current controller configuration" do
|
62
|
-
expect(helper.url_for_document(doc)).to eq(controller: 'alternate', action: :show, id: doc)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
it "is a polymorphic route if the solr document responds to #to_model with a non-SolrDocument" do
|
67
|
-
some_model = double
|
68
|
-
doc = SolrDocument.new
|
69
|
-
allow(doc).to receive_messages(to_model: some_model)
|
70
|
-
expect(helper.url_for_document(doc)).to eq doc
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
25
|
describe "link_back_to_catalog" do
|
75
26
|
let(:query_params) { { q: "query", f: "facets", controller: 'catalog' } }
|
76
27
|
let(:bookmarks_query_params) { { controller: 'bookmarks' } }
|
@@ -148,61 +99,6 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
148
99
|
end
|
149
100
|
end
|
150
101
|
|
151
|
-
describe "link_to_previous_document" do
|
152
|
-
context "when the argument is nil" do
|
153
|
-
subject { helper.link_to_previous_document(nil) }
|
154
|
-
|
155
|
-
it { is_expected.to eq '<span class="previous">« Previous</span>' }
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe "link_to_query" do
|
160
|
-
it "builds a link tag to catalog using query string (no other params)" do
|
161
|
-
query = "brilliant"
|
162
|
-
allow(helper).to receive_messages(params: parameter_class.new)
|
163
|
-
tag = helper.link_to_query(query)
|
164
|
-
expect(tag).to match /q=#{query}/
|
165
|
-
expect(tag).to match %r{>#{query}</a>}
|
166
|
-
end
|
167
|
-
|
168
|
-
it "builds a link tag to catalog using query string and other existing params" do
|
169
|
-
query = "wonderful"
|
170
|
-
allow(helper).to receive_messages(params: parameter_class.new(qt: "title_search", per_page: "50"))
|
171
|
-
tag = helper.link_to_query(query)
|
172
|
-
expect(tag).to match /qt=title_search/
|
173
|
-
expect(tag).to match /per_page=50/
|
174
|
-
end
|
175
|
-
|
176
|
-
it "ignores existing :page param" do
|
177
|
-
query = "yes"
|
178
|
-
allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
|
179
|
-
tag = helper.link_to_query(query)
|
180
|
-
expect(tag).to match /qt=author_search/
|
181
|
-
expect(tag).not_to match /page/
|
182
|
-
end
|
183
|
-
|
184
|
-
it "is html_safe" do
|
185
|
-
query = "brilliant"
|
186
|
-
allow(helper).to receive_messages(params: parameter_class.new(page: "2", qt: "author_search"))
|
187
|
-
tag = helper.link_to_query(query)
|
188
|
-
expect(tag).to be_html_safe
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe "start_over_path" do
|
193
|
-
it 'is the catalog path with the current view type' do
|
194
|
-
allow(blacklight_config).to receive(:view).and_return(list: nil, abc: nil)
|
195
|
-
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
196
|
-
expect(helper.start_over_path(view: 'abc')).to eq search_catalog_url(view: 'abc')
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'does not include the current view type if it is the default' do
|
200
|
-
allow(blacklight_config).to receive(:view).and_return(list: nil, asdf: nil)
|
201
|
-
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
202
|
-
expect(helper.start_over_path(view: 'list')).to eq search_catalog_url
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
102
|
describe "link_to_document" do
|
207
103
|
let(:title_tsim) { '654321' }
|
208
104
|
let(:id) { '123456' }
|
@@ -216,30 +112,22 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
216
112
|
end
|
217
113
|
|
218
114
|
it "consists of the document title wrapped in a <a>" do
|
219
|
-
|
220
|
-
expect(helper.link_to_document(document, :title_tsim)).to have_selector("a", text: '654321', count: 1)
|
115
|
+
expect(helper.link_to_document(document)).to have_selector("a", text: '654321', count: 1)
|
221
116
|
end
|
222
117
|
|
223
118
|
it "accepts and returns a string label" do
|
224
119
|
expect(helper.link_to_document(document, 'This is the title')).to have_selector("a", text: 'This is the title', count: 1)
|
225
120
|
end
|
226
121
|
|
227
|
-
it "accepts and returns a Proc" do
|
228
|
-
allow(Deprecation).to receive(:warn)
|
229
|
-
expect(helper.link_to_document(document, proc { |doc, _opts| doc[:id] + ": " + doc.first(:title_tsim) })).to have_selector("a", text: '123456: 654321', count: 1)
|
230
|
-
end
|
231
|
-
|
232
122
|
context 'when label is missing' do
|
233
123
|
let(:data) { { 'id' => id } }
|
234
124
|
|
235
125
|
it "returns id" do
|
236
|
-
|
237
|
-
expect(helper.link_to_document(document, :title_tsim)).to have_selector("a", text: '123456', count: 1)
|
126
|
+
expect(helper.link_to_document(document)).to have_selector("a", text: '123456', count: 1)
|
238
127
|
end
|
239
128
|
|
240
129
|
it "is html safe" do
|
241
|
-
|
242
|
-
expect(helper.link_to_document(document, :title_tsim)).to be_html_safe
|
130
|
+
expect(helper.link_to_document(document)).to be_html_safe
|
243
131
|
end
|
244
132
|
|
245
133
|
it "passes on the title attribute to the link_to_with_data method" do
|
@@ -253,15 +141,14 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
253
141
|
context "with an integer id" do
|
254
142
|
let(:id) { 123_456 }
|
255
143
|
|
256
|
-
it "
|
144
|
+
it "has a link" do
|
257
145
|
expect(helper.link_to_document(document)).to have_selector("a")
|
258
146
|
end
|
259
147
|
end
|
260
148
|
end
|
261
149
|
|
262
150
|
it "converts the counter parameter into a data- attribute" do
|
263
|
-
|
264
|
-
expect(helper.link_to_document(document, :title_tsim, counter: 5)).to include 'data-context-href="tracking url"'
|
151
|
+
expect(helper.link_to_document(document, 'foo', counter: 5)).to include 'data-context-href="tracking url"'
|
265
152
|
expect(helper.main_app).to have_received(:track_test_path).with(hash_including(id: have_attributes(id: '123456'), counter: 5))
|
266
153
|
end
|
267
154
|
|
@@ -279,19 +166,10 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
279
166
|
end
|
280
167
|
|
281
168
|
describe "link_to_previous_search" do
|
282
|
-
let(:params) { {} }
|
169
|
+
let(:params) { { q: 'search query' } }
|
283
170
|
|
284
171
|
it "links to the given search parameters" do
|
285
|
-
|
286
|
-
expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", helper.search_action_path)
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
describe "#bookmarks_export_url" do
|
291
|
-
it "is the bookmark url with an encrypted user token" do
|
292
|
-
allow(helper).to receive_messages(encrypt_user_id: 'xyz', current_or_guest_user: double(id: 123))
|
293
|
-
url = helper.bookmarks_export_url(:html)
|
294
|
-
expect(url).to eq helper.bookmarks_url(format: :html, encrypted_user_id: 'xyz')
|
172
|
+
expect(helper.link_to_previous_search(params)).to have_link(href: helper.search_action_path(params)).and(have_text('search query'))
|
295
173
|
end
|
296
174
|
end
|
297
175
|
|
@@ -310,7 +188,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
310
188
|
|
311
189
|
it "uses the track_search_session configuration to determine whether to track the search session" do
|
312
190
|
blacklight_config.track_search_session = false
|
313
|
-
expect(helper.session_tracking_path(document, x: 1)).to
|
191
|
+
expect(helper.session_tracking_path(document, x: 1)).to be_nil
|
314
192
|
end
|
315
193
|
end
|
316
194
|
end
|