blacklight 6.14.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.npmignore +23 -0
- data/.rubocop.yml +40 -16
- data/.rubocop_todo.yml +479 -375
- data/.solr_wrapper.yml +9 -2
- data/.travis.yml +27 -20
- data/Gemfile +3 -1
- data/README.md +22 -5
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/Vagrantfile +2 -0
- data/app/assets/images/blacklight/list.svg +1 -0
- data/app/assets/images/blacklight/search.svg +1 -0
- data/app/assets/javascripts/blacklight/blacklight.js +497 -57
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +7 -12
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +18 -15
- data/app/assets/stylesheets/blacklight/_bookmark.scss +1 -13
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +27 -0
- data/app/assets/stylesheets/blacklight/_constraints.scss +17 -25
- data/app/assets/stylesheets/blacklight/_controls.scss +8 -16
- data/app/assets/stylesheets/blacklight/_facets.scss +64 -93
- data/app/assets/stylesheets/blacklight/_header.scss +35 -48
- data/app/assets/stylesheets/blacklight/_icons.scss +35 -0
- data/app/assets/stylesheets/blacklight/_layout.scss +0 -10
- data/app/assets/stylesheets/blacklight/_mixins.scss +15 -0
- data/app/assets/stylesheets/blacklight/_modal.scss +9 -17
- data/app/assets/stylesheets/blacklight/_pagination.scss +2 -17
- data/app/assets/stylesheets/blacklight/_search_form.scss +7 -0
- data/app/assets/stylesheets/blacklight/_search_history.scss +5 -13
- data/app/assets/stylesheets/blacklight/_search_results.scss +9 -8
- data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +1 -2
- data/app/assets/stylesheets/blacklight/blacklight.scss +1 -1
- data/app/builders/blacklight/action_builder.rb +57 -0
- data/app/controllers/bookmarks_controller.rb +2 -2
- data/app/controllers/catalog_controller.rb +2 -2
- data/app/controllers/concerns/blacklight/base.rb +0 -33
- data/app/controllers/concerns/blacklight/bookmarks.rb +36 -33
- data/app/controllers/concerns/blacklight/catalog.rb +266 -210
- data/app/controllers/concerns/blacklight/controller.rb +111 -126
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +12 -43
- data/app/controllers/concerns/blacklight/facet.rb +3 -0
- data/app/controllers/concerns/blacklight/search_context.rb +16 -14
- data/app/controllers/concerns/blacklight/search_fields.rb +4 -14
- data/app/controllers/concerns/blacklight/search_history.rb +1 -6
- data/app/controllers/concerns/blacklight/token_based_user.rb +24 -9
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +39 -119
- data/app/helpers/blacklight/catalog_helper_behavior.rb +94 -88
- data/app/helpers/blacklight/component_helper_behavior.rb +21 -19
- data/app/helpers/blacklight/configuration_helper_behavior.rb +30 -57
- data/app/helpers/blacklight/facets_helper_behavior.rb +55 -51
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +9 -11
- data/app/helpers/blacklight/icon_helper_behavior.rb +18 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +8 -6
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +195 -0
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +19 -11
- data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +50 -41
- data/app/{assets/javascripts → javascript}/blacklight/autocomplete.js +3 -2
- data/app/javascript/blacklight/bookmark_toggle.js +25 -0
- data/app/javascript/blacklight/checkbox_submit.js +134 -0
- data/app/{assets/javascripts → javascript}/blacklight/collapsable.js +1 -1
- data/app/{assets/javascripts → javascript}/blacklight/core.js +10 -8
- data/app/{assets/javascripts → javascript}/blacklight/facet_load.js +6 -6
- data/app/{assets/javascripts/blacklight/ajax_modal.js → javascript/blacklight/modal.js} +62 -64
- data/app/{assets/javascripts → javascript}/blacklight/search_context.js +10 -3
- data/app/models/blacklight/facet_paginator.rb +3 -3
- data/app/models/blacklight/icon.rb +56 -0
- data/app/models/blacklight/solr/facet_paginator.rb +3 -3
- data/app/models/blacklight/suggest_search.rb +4 -15
- data/app/models/bookmark.rb +5 -10
- data/app/models/concerns/blacklight/configurable.rb +13 -13
- data/app/models/concerns/blacklight/document/active_model_shim.rb +13 -11
- data/app/models/concerns/blacklight/document/cache_key.rb +1 -1
- data/app/models/concerns/blacklight/document/dublin_core.rb +2 -2
- data/app/models/concerns/blacklight/document/email.rb +1 -1
- data/app/models/concerns/blacklight/document/extensions.rb +5 -5
- data/app/models/concerns/blacklight/document/semantic_fields.rb +9 -9
- data/app/models/concerns/blacklight/document/sms.rb +1 -1
- data/app/models/concerns/blacklight/document.rb +26 -40
- data/app/models/concerns/blacklight/solr/document.rb +8 -8
- data/app/models/concerns/blacklight/suggest/response.rb +5 -3
- data/app/models/concerns/blacklight/user.rb +7 -6
- data/app/models/record_mailer.rb +5 -6
- data/app/models/search.rb +5 -7
- data/app/presenters/blacklight/document_presenter.rb +25 -140
- data/app/presenters/blacklight/field_presenter.rb +7 -5
- data/app/presenters/blacklight/index_presenter.rb +41 -58
- data/app/presenters/blacklight/json_presenter.rb +10 -14
- data/app/presenters/blacklight/link_alternate_presenter.rb +3 -1
- data/app/presenters/blacklight/rendering/abstract_step.rb +7 -5
- data/app/presenters/blacklight/rendering/helper_method.rb +10 -8
- data/app/presenters/blacklight/rendering/join.rb +5 -3
- data/app/presenters/blacklight/rendering/link_to_facet.rb +23 -19
- data/app/presenters/blacklight/rendering/microdata.rb +6 -3
- data/app/presenters/blacklight/rendering/pipeline.rb +7 -5
- data/app/presenters/blacklight/rendering/terminator.rb +2 -0
- data/app/presenters/blacklight/search_bar_presenter.rb +39 -0
- data/app/presenters/blacklight/show_presenter.rb +26 -63
- data/app/presenters/blacklight/thumbnail_presenter.rb +74 -0
- data/app/services/blacklight/document_factory.rb +13 -0
- data/app/services/blacklight/field_retriever.rb +26 -24
- data/app/services/blacklight/search_service.rb +152 -0
- data/app/values/blacklight/types.rb +31 -0
- data/app/views/blacklight/nav/_bookmark.html.erb +2 -2
- data/app/views/blacklight/nav/_search_history.html.erb +1 -1
- data/app/views/bookmarks/_tools.html.erb +2 -2
- data/app/views/bookmarks/index.html.erb +12 -13
- data/app/views/catalog/_bookmark_control.html.erb +26 -10
- data/app/views/catalog/_citation.html.erb +4 -4
- data/app/views/catalog/_constraints.html.erb +6 -7
- data/app/views/catalog/_constraints_element.html.erb +6 -6
- data/app/views/catalog/_did_you_mean.html.erb +1 -1
- data/app/views/catalog/{_document_default.atom.builder → _document.atom.builder} +19 -18
- data/app/views/catalog/_document.html.erb +5 -3
- data/app/views/catalog/{_document_default.rss.builder → _document.rss.builder} +2 -0
- data/app/views/catalog/_document_action.html.erb +2 -1
- data/app/views/catalog/_email_form.html.erb +8 -4
- data/app/views/catalog/_facet_index_navigation.html.erb +5 -4
- data/app/views/catalog/_facet_layout.html.erb +6 -10
- data/app/views/catalog/_facet_limit.html.erb +3 -2
- data/app/views/catalog/_facet_pagination.html.erb +8 -8
- data/app/views/catalog/_facet_pivot.html.erb +2 -2
- data/app/views/catalog/_facets.html.erb +9 -12
- data/app/views/catalog/_field.json.jbuilder +10 -0
- data/app/views/catalog/{_group_default.html.erb → _group.html.erb} +1 -1
- data/app/views/catalog/_home_text.html.erb +32 -36
- data/app/views/catalog/_index.html.erb +10 -0
- data/app/views/catalog/{_index_header_default.html.erb → _index_header.html.erb} +3 -3
- data/app/views/catalog/_per_page_widget.html.erb +6 -7
- data/app/views/catalog/_previous_next_doc.html.erb +6 -14
- data/app/views/catalog/_results_pagination.html.erb +2 -2
- data/app/views/catalog/_search_form.html.erb +12 -8
- data/app/views/catalog/_search_header.html.erb +0 -3
- data/app/views/catalog/_search_results.html.erb +6 -2
- data/app/views/catalog/_show.html.erb +8 -0
- data/app/views/catalog/_show_main_content.html.erb +4 -4
- data/app/views/catalog/_show_more_like_this.html.erb +1 -1
- data/app/views/catalog/_show_sidebar.html.erb +3 -3
- data/app/views/catalog/_show_tools.html.erb +10 -12
- data/app/views/catalog/_sms_form.html.erb +8 -4
- data/app/views/catalog/_sort_and_per_page.html.erb +3 -3
- data/app/views/catalog/_sort_widget.html.erb +7 -7
- data/app/views/catalog/_thumbnail.html.erb +5 -0
- data/app/views/catalog/_view_type_group.html.erb +2 -2
- data/app/views/catalog/_zero_results.html.erb +1 -1
- data/app/views/catalog/citation.js.erb +4 -2
- data/app/views/catalog/email.html.erb +5 -3
- data/app/views/catalog/email_success.html.erb +12 -8
- data/app/views/catalog/facet.html.erb +10 -8
- data/app/views/catalog/facet.json.jbuilder +2 -0
- data/app/views/catalog/index.atom.builder +13 -16
- data/app/views/catalog/index.html.erb +9 -11
- data/app/views/catalog/index.json.jbuilder +84 -3
- data/app/views/catalog/index.rss.builder +7 -5
- data/app/views/catalog/opensearch.xml.builder +12 -10
- data/app/views/catalog/show.html.erb +11 -6
- data/app/views/catalog/show.json.jbuilder +21 -0
- data/app/views/catalog/sms.html.erb +3 -1
- data/app/views/catalog/sms_success.html.erb +12 -8
- data/app/views/kaminari/blacklight/_first_page.html.erb +2 -2
- data/app/views/kaminari/blacklight/_gap.html.erb +2 -2
- data/app/views/kaminari/blacklight/_last_page.html.erb +2 -2
- data/app/views/kaminari/blacklight/_next_page.html.erb +5 -5
- data/app/views/kaminari/blacklight/_page.html.erb +5 -3
- data/app/views/kaminari/blacklight/_prev_page.html.erb +4 -4
- data/app/views/kaminari/blacklight_compact/_paginator.html.erb +4 -4
- data/app/views/layouts/blacklight/base.html.erb +35 -0
- data/app/views/layouts/blacklight.html.erb +14 -41
- data/app/views/layouts/catalog_result.html.erb +11 -0
- data/app/views/search_history/index.html.erb +16 -21
- data/app/views/shared/_header_navbar.html.erb +8 -13
- data/app/views/shared/_modal.html.erb +6 -0
- data/app/views/shared/_user_util_links.html.erb +22 -0
- data/blacklight.gemspec +10 -11
- data/config/i18n-tasks.yml +17 -0
- data/config/locales/blacklight.de.yml +71 -82
- data/config/locales/blacklight.en.yml +15 -27
- data/config/locales/blacklight.es.yml +14 -26
- data/config/locales/blacklight.fr.yml +16 -33
- data/config/locales/blacklight.hu.yml +212 -0
- data/config/locales/blacklight.it.yml +15 -26
- data/config/locales/blacklight.nl.yml +212 -0
- data/config/locales/blacklight.pt-BR.yml +24 -29
- data/config/locales/blacklight.sq.yml +4 -28
- data/config/locales/blacklight.zh.yml +3 -25
- data/config/routes.rb +2 -10
- data/db/migrate/20140202020202_create_bookmarks.rb +0 -1
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -1
- data/lib/blacklight/abstract_repository.rb +22 -10
- data/lib/blacklight/configuration/context.rb +12 -1
- data/lib/blacklight/configuration/facet_field.rb +16 -9
- data/lib/blacklight/configuration/field.rb +32 -3
- data/lib/blacklight/configuration/fields.rb +61 -58
- data/lib/blacklight/configuration/null_field.rb +2 -0
- data/lib/blacklight/configuration/search_field.rb +2 -2
- data/lib/blacklight/configuration/sort_field.rb +2 -2
- data/lib/blacklight/configuration/view_config.rb +4 -0
- data/lib/blacklight/configuration.rb +101 -88
- data/lib/blacklight/engine.rb +11 -7
- data/lib/blacklight/exceptions.rb +4 -7
- data/lib/blacklight/{utils.rb → nested_open_struct_with_hash_access.rb} +9 -81
- data/lib/blacklight/open_struct_with_hash_access.rb +49 -0
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/routes/exportable.rb +1 -3
- data/lib/blacklight/routes/searchable.rb +3 -3
- data/lib/blacklight/runtime_registry.rb +2 -0
- data/lib/blacklight/search_builder.rb +28 -35
- data/lib/blacklight/search_state.rb +10 -8
- data/lib/blacklight/solr/repository.rb +40 -6
- data/lib/blacklight/solr/request.rb +1 -1
- data/lib/blacklight/solr/response/facets.rb +29 -31
- data/lib/blacklight/solr/response/group.rb +3 -3
- data/lib/blacklight/solr/response/group_response.rb +1 -1
- data/lib/blacklight/solr/response/more_like_this.rb +2 -2
- data/lib/blacklight/solr/response/response.rb +2 -2
- data/lib/blacklight/solr/response/spelling.rb +4 -3
- data/lib/blacklight/solr/response.rb +29 -30
- data/lib/blacklight/solr/search_builder_behavior.rb +25 -29
- data/lib/blacklight/version.rb +1 -1
- data/lib/blacklight.rb +10 -8
- data/lib/generators/blacklight/assets_generator.rb +18 -12
- data/lib/generators/blacklight/controller_generator.rb +4 -5
- data/lib/generators/blacklight/document_generator.rb +1 -1
- data/lib/generators/blacklight/install_generator.rb +18 -28
- data/lib/generators/blacklight/search_builder_generator.rb +1 -1
- data/lib/generators/blacklight/{solr5_generator.rb → solr_generator.rb} +12 -6
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +5 -0
- data/lib/generators/blacklight/templates/alternate_controller.rb +4 -4
- data/lib/generators/blacklight/templates/blacklight.scss +0 -2
- data/lib/generators/blacklight/templates/catalog_controller.rb +59 -49
- data/lib/generators/blacklight/templates/config/blacklight.yml +1 -13
- data/lib/generators/blacklight/templates/solr/conf/schema.xml +388 -0
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +195 -0
- data/lib/generators/blacklight/test_support_generator.rb +10 -10
- data/lib/generators/blacklight/user_generator.rb +5 -6
- data/lib/railties/blacklight.rake +17 -21
- data/package-lock.json +2195 -0
- data/package.json +29 -0
- data/spec/controllers/alternate_controller_spec.rb +5 -4
- data/spec/controllers/application_controller_spec.rb +1 -5
- data/spec/controllers/blacklight/base_spec.rb +6 -3
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +11 -7
- data/spec/controllers/blacklight/facet_spec.rb +1 -2
- data/spec/controllers/blacklight/search_fields_spec.rb +25 -34
- data/spec/controllers/bookmarks_controller_spec.rb +46 -11
- data/spec/controllers/catalog_controller_spec.rb +334 -161
- data/spec/controllers/search_history_controller_spec.rb +6 -6
- data/spec/features/alternate_controller_spec.rb +4 -4
- data/spec/features/autocomplete_spec.rb +4 -2
- data/spec/features/bookmarks_spec.rb +10 -10
- data/spec/features/did_you_mean_spec.rb +7 -12
- data/spec/features/facets_spec.rb +29 -17
- data/spec/features/record_view_spec.rb +12 -18
- data/spec/features/search_context_spec.rb +6 -7
- data/spec/features/search_crawler_spec.rb +3 -5
- data/spec/features/search_filters_spec.rb +80 -80
- data/spec/features/search_formats_spec.rb +1 -1
- data/spec/features/search_history_spec.rb +6 -29
- data/spec/features/search_pagination_spec.rb +4 -2
- data/spec/features/search_results_spec.rb +14 -12
- data/spec/features/search_sort_spec.rb +2 -2
- data/spec/features/search_spec.rb +8 -9
- data/spec/features/sitelinks_search_box.rb +4 -4
- data/{solr → spec/fixtures}/sample_solr_documents.yml +688 -688
- data/spec/helpers/{configuration_helper_spec.rb → blacklight/configuration_helper_behavior_spec.rb} +97 -92
- data/spec/helpers/{facets_helper_spec.rb → blacklight/facets_helper_behavior_spec.rb} +72 -67
- data/spec/helpers/{hash_as_hidden_fields_spec.rb → blacklight/hash_as_hidden_fields_behavior_spec.rb} +2 -2
- data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +10 -0
- data/spec/helpers/{layout_helper_spec.rb → blacklight/layout_helper_behavior_spec.rb} +5 -5
- data/spec/helpers/{render_constraints_helper_spec.rb → blacklight/render_constraints_helper_behavior_spec.rb} +10 -6
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +92 -0
- data/spec/helpers/{search_history_constraints_helper_spec.rb → blacklight/search_history_constraints_helper_behavior_spec.rb} +29 -30
- data/spec/helpers/{suggest_helper_spec.rb → blacklight/suggest_helper_behavior_spec.rb} +9 -2
- data/spec/helpers/{url_helper_spec.rb → blacklight/url_helper_behavior_spec.rb} +56 -54
- data/spec/helpers/blacklight_helper_spec.rb +65 -150
- data/spec/helpers/catalog_helper_spec.rb +80 -96
- data/spec/i18n_spec.rb +18 -0
- data/spec/integration/generators/blacklight/{solr5_generator_spec.rb → solr_generator_spec.rb} +21 -13
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +13 -0
- data/spec/lib/blacklight/configuration/field_spec.rb +15 -0
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +17 -0
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +148 -0
- data/spec/lib/blacklight/parameters_spec.rb +4 -2
- data/spec/lib/blacklight/search_state_spec.rb +53 -36
- data/spec/lib/blacklight_spec.rb +14 -15
- data/spec/lib/tasks/blacklight_task_spec.rb +4 -6
- data/spec/models/blacklight/configurable_spec.rb +24 -27
- data/spec/models/blacklight/configuration/context_spec.rb +9 -10
- data/spec/models/blacklight/configuration_spec.rb +248 -223
- data/spec/models/blacklight/document/active_model_shim_spec.rb +15 -6
- data/spec/models/blacklight/document/cache_key_spec.rb +9 -2
- data/spec/models/blacklight/document/dublin_core_spec.rb +17 -20
- data/spec/models/blacklight/document/email_spec.rb +10 -10
- data/spec/models/blacklight/document/sms_spec.rb +10 -10
- data/spec/models/blacklight/document_spec.rb +10 -22
- data/spec/models/blacklight/facet_paginator_spec.rb +40 -30
- data/spec/models/blacklight/icon_spec.rb +44 -0
- data/spec/models/blacklight/search_builder_spec.rb +41 -26
- data/spec/models/blacklight/solr/document_spec.rb +224 -216
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +6 -4
- data/spec/models/blacklight/solr/repository_spec.rb +61 -46
- data/spec/models/blacklight/solr/request_spec.rb +17 -18
- data/spec/models/blacklight/solr/response/facets_spec.rb +58 -58
- data/spec/models/blacklight/solr/response/group_response_spec.rb +16 -22
- data/spec/models/blacklight/solr/response/group_spec.rb +18 -25
- data/spec/models/blacklight/solr/response_spec.rb +56 -55
- data/spec/models/blacklight/solr/search_builder_spec.rb +150 -164
- data/spec/models/blacklight/suggest/response_spec.rb +6 -4
- data/spec/models/blacklight/suggest_search_spec.rb +9 -16
- data/spec/models/blacklight/user_spec.rb +9 -11
- data/spec/models/bookmark_spec.rb +7 -6
- data/spec/models/record_mailer_spec.rb +23 -21
- data/spec/models/search_spec.rb +19 -18
- data/spec/models/solr_document_spec.rb +33 -5
- data/spec/presenters/blacklight/document_presenter_spec.rb +86 -0
- data/spec/presenters/blacklight/index_presenter_spec.rb +186 -0
- data/spec/presenters/blacklight/json_presenter_spec.rb +59 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -0
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +79 -0
- data/spec/presenters/blacklight/show_presenter_spec.rb +333 -0
- data/spec/presenters/pipeline_spec.rb +18 -11
- data/spec/presenters/thumbnail_presenter_spec.rb +174 -0
- data/spec/routing/catalog_routing_spec.rb +13 -15
- data/spec/services/blacklight/search_service_spec.rb +488 -0
- data/spec/spec_helper.rb +20 -19
- data/spec/support/features/session_helpers.rb +4 -4
- data/spec/support/features.rb +1 -1
- data/spec/test_app_templates/Gemfile.extra +2 -4
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -13
- data/spec/views/catalog/_constraints.html.erb_spec.rb +3 -6
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +17 -13
- data/spec/views/catalog/_document.html.erb_spec.rb +11 -11
- data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -1
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +6 -6
- data/spec/views/catalog/_facets.html.erb_spec.rb +10 -12
- data/spec/views/catalog/{_index_default.erb_spec.rb → _index.html.erb_spec.rb} +14 -15
- data/spec/views/catalog/{_index_header_default.html.erb_spec.rb → _index_header.html.erb_spec.rb} +6 -9
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +7 -30
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -3
- data/spec/views/catalog/{_show_default.erb_spec.rb → _show.html.erb_spec.rb} +13 -14
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +6 -9
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -2
- data/spec/views/catalog/_sort_widget.html.erb_spec.rb +3 -1
- data/spec/views/catalog/{_thumbnail_default.erb_spec.rb → _thumbnail.html.erb_spec.rb} +7 -9
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +12 -10
- data/spec/views/catalog/email_success.html.erb_spec.rb +8 -0
- data/spec/views/catalog/facet.html.erb_spec.rb +4 -3
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +3 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +11 -6
- data/spec/views/catalog/index.html.erb_spec.rb +6 -8
- data/spec/views/catalog/index.json.jbuilder_spec.rb +119 -26
- data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -1
- data/spec/views/catalog/show.html.erb_spec.rb +8 -8
- data/spec/views/catalog/show.json.jbuilder_spec.rb +40 -0
- data/spec/views/catalog/sms_success.html.erb_spec.rb +8 -0
- data/spec/views/{_user_util_links.html.erb_spec.rb → shared/_user_util_links.html.erb_spec.rb} +4 -7
- data/tasks/blacklight.rake +10 -8
- data/template.demo.rb +3 -11
- metadata +188 -189
- data/app/assets/javascripts/blacklight/autofocus.js +0 -16
- data/app/assets/javascripts/blacklight/bookmark_toggle.js +0 -23
- data/app/assets/javascripts/blacklight/checkbox_submit.js +0 -135
- data/app/controllers/concerns/blacklight/request_builders.rb +0 -77
- data/app/controllers/concerns/blacklight/saved_searches.rb +0 -70
- data/app/controllers/concerns/blacklight/search_helper.rb +0 -155
- data/app/controllers/concerns/blacklight/suggest.rb +0 -25
- data/app/controllers/saved_searches_controller.rb +0 -4
- data/app/controllers/suggest_controller.rb +0 -4
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +0 -57
- data/app/helpers/blacklight/render_partials_helper.rb +0 -205
- data/app/helpers/blacklight_configuration_helper.rb +0 -4
- data/app/helpers/blacklight_url_helper.rb +0 -4
- data/app/helpers/component_helper.rb +0 -4
- data/app/helpers/facets_helper.rb +0 -4
- data/app/helpers/hash_as_hidden_fields_helper.rb +0 -4
- data/app/helpers/layout_helper.rb +0 -4
- data/app/helpers/render_constraints_helper.rb +0 -4
- data/app/helpers/search_history_constraints_helper.rb +0 -4
- data/app/helpers/suggest_helper.rb +0 -4
- data/app/models/concerns/blacklight/solr/document/more_like_this.rb +0 -6
- data/app/views/_user_util_links.html.erb +0 -26
- data/app/views/blacklight/nav/_saved_searches.html.erb +0 -1
- data/app/views/catalog/_index_default.html.erb +0 -12
- data/app/views/catalog/_show_default.html.erb +0 -10
- data/app/views/catalog/_thumbnail_default.html.erb +0 -5
- data/app/views/saved_searches/index.html.erb +0 -32
- data/app/views/shared/_ajax_modal.html.erb +0 -6
- data/lib/generators/blacklight/solr4_generator.rb +0 -31
- data/lib/generators/blacklight/templates/config/jetty.yml +0 -13
- data/solr/conf/schema.xml +0 -629
- data/solr/conf/solrconfig.xml +0 -411
- data/spec/controllers/blacklight/search_helper_spec.rb +0 -470
- data/spec/controllers/saved_searches_controller_spec.rb +0 -32
- data/spec/controllers/suggest_controller_spec.rb +0 -17
- data/spec/features/saved_searches_spec.rb +0 -47
- data/spec/helpers/deprecated_url_helper_behavior_spec.rb +0 -101
- data/spec/lib/blacklight/utils_spec.rb +0 -167
- data/spec/models/blacklight/solr/document/more_like_this_spec.rb +0 -18
- data/spec/presenters/document_presenter_spec.rb +0 -438
- data/spec/presenters/index_presenter_spec.rb +0 -173
- data/spec/presenters/show_presenter_spec.rb +0 -313
- data/spec/support/backport_test.rb +0 -14
- /data/app/views/catalog/{_show_header_default.html.erb → _show_header.html.erb} +0 -0
- /data/app/views/{_flash_msg.html.erb → shared/_flash_msg.html.erb} +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/_rest_managed.json +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/admin-extra.html +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/elevate.xml +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/mapping-ISOLatin1Accent.txt +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/protwords.txt +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/scripts.conf +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/spellings.txt +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/stopwords.txt +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/stopwords_en.txt +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/synonyms.txt +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/xslt/example.xsl +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/xslt/example_atom.xsl +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/xslt/example_rss.xsl +0 -0
- /data/{solr → lib/generators/blacklight/templates/solr}/conf/xslt/luke.xsl +0 -0
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
describe "Blacklight::Configuration" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@config = Blacklight::Configuration.new
|
|
3
|
+
RSpec.describe "Blacklight::Configuration", api: true do
|
|
4
|
+
let(:config) do
|
|
5
|
+
Blacklight::Configuration.new
|
|
7
6
|
end
|
|
8
7
|
|
|
9
8
|
it "supports arbitrary configuration values" do
|
|
10
|
-
|
|
9
|
+
config.a = 1
|
|
11
10
|
|
|
12
|
-
expect(
|
|
13
|
-
expect(
|
|
11
|
+
expect(config.a).to eq 1
|
|
12
|
+
expect(config[:a]).to eq 1
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
describe "initialization" do
|
|
17
16
|
it "is an OpenStructWithHashAccess" do
|
|
18
|
-
expect(
|
|
17
|
+
expect(config).to be_a_kind_of Blacklight::OpenStructWithHashAccess
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
it "accepts a block for configuration" do
|
|
22
|
-
config = Blacklight::Configuration.new(:
|
|
21
|
+
config = Blacklight::Configuration.new(a: 1) { |c| c.a = 2 }
|
|
23
22
|
|
|
24
23
|
expect(config.a).to eq 2
|
|
25
24
|
|
|
@@ -31,46 +30,46 @@ describe "Blacklight::Configuration" do
|
|
|
31
30
|
|
|
32
31
|
describe "defaults" do
|
|
33
32
|
it "has a hash of default rsolr query parameters" do
|
|
34
|
-
expect(
|
|
33
|
+
expect(config.default_solr_params).to be_a_kind_of Hash
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
it "has openstruct values for show and index parameters" do
|
|
38
|
-
expect(
|
|
39
|
-
expect(
|
|
37
|
+
expect(config.show).to be_a_kind_of OpenStruct
|
|
38
|
+
expect(config.index).to be_a_kind_of OpenStruct
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
it "has ordered hashes for field configuration" do
|
|
43
|
-
expect(
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
47
|
-
expect(
|
|
48
|
-
expect(
|
|
49
|
-
expect(
|
|
42
|
+
expect(config.facet_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
43
|
+
expect(config.index_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
44
|
+
expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
45
|
+
expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
46
|
+
expect(config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
47
|
+
expect(config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
48
|
+
expect(config.sort_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
50
49
|
end
|
|
51
|
-
|
|
52
50
|
end
|
|
53
51
|
|
|
54
52
|
describe "#connection_config" do
|
|
55
53
|
let(:custom_config) { double }
|
|
54
|
+
|
|
56
55
|
it "has the global blacklight configuration" do
|
|
57
|
-
expect(
|
|
56
|
+
expect(config.connection_config).to eq Blacklight.connection_config
|
|
58
57
|
end
|
|
59
58
|
it "is overridable with custom configuration" do
|
|
60
|
-
|
|
61
|
-
expect(
|
|
59
|
+
config.connection_config = custom_config
|
|
60
|
+
expect(config.connection_config).to eq custom_config
|
|
62
61
|
end
|
|
63
62
|
end
|
|
64
63
|
|
|
65
64
|
describe "config.index.respond_to" do
|
|
66
65
|
it "has a list of additional formats for index requests to respond to" do
|
|
67
|
-
|
|
66
|
+
config.index.respond_to.xml = true
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
config.index.respond_to.csv = { layout: false }
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
config.index.respond_to.yaml = -> { render plain: "" }
|
|
72
71
|
|
|
73
|
-
expect(
|
|
72
|
+
expect(config.index.respond_to.keys).to eq [:xml, :csv, :yaml]
|
|
74
73
|
end
|
|
75
74
|
end
|
|
76
75
|
|
|
@@ -78,31 +77,76 @@ describe "Blacklight::Configuration" do
|
|
|
78
77
|
it "defaults to 5" do
|
|
79
78
|
expect(Blacklight::Configuration.new.spell_max).to eq 5
|
|
80
79
|
end
|
|
81
|
-
|
|
80
|
+
|
|
82
81
|
it "accepts config'd value" do
|
|
83
|
-
expect(Blacklight::Configuration.new(:
|
|
82
|
+
expect(Blacklight::Configuration.new(spell_max: 10).spell_max).to eq 10
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "for_display_type" do
|
|
87
|
+
let(:image) { SolrDocument.new(format: 'Image') }
|
|
88
|
+
let(:sound) { SolrDocument.new(format: 'Sound') }
|
|
89
|
+
|
|
90
|
+
it "adds index fields just for a certain type" do
|
|
91
|
+
config.for_display_type "Image" do |c|
|
|
92
|
+
c.add_index_field :dimensions
|
|
93
|
+
end
|
|
94
|
+
config.add_index_field :title
|
|
95
|
+
|
|
96
|
+
expect(config.index_fields_for(image)).to have_key 'dimensions'
|
|
97
|
+
expect(config.index_fields_for(image)).to have_key 'title'
|
|
98
|
+
expect(config.index_fields_for(sound)).not_to have_key 'dimensions'
|
|
99
|
+
expect(config.index_fields_for(image)).to have_key 'title'
|
|
100
|
+
expect(config.index_fields).not_to have_key 'dimensions'
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "adds show fields just for a certain type" do
|
|
104
|
+
config.for_display_type "Image" do |c|
|
|
105
|
+
c.add_show_field :dimensions
|
|
106
|
+
end
|
|
107
|
+
config.add_show_field :title
|
|
108
|
+
|
|
109
|
+
expect(config.show_fields_for(image)).to have_key 'dimensions'
|
|
110
|
+
expect(config.show_fields_for(image)).to have_key 'title'
|
|
111
|
+
expect(config.show_fields_for(sound)).not_to have_key 'dimensions'
|
|
112
|
+
expect(config.show_fields_for(image)).to have_key 'title'
|
|
113
|
+
expect(config.show_fields).not_to have_key 'dimensions'
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'calls the block on subsequent invocations' do
|
|
117
|
+
config.for_display_type "Image" do |c|
|
|
118
|
+
c.add_show_field :dimensions
|
|
119
|
+
end
|
|
120
|
+
config.for_display_type "Image" do |c|
|
|
121
|
+
c.add_show_field :photographer
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
expect(config.show_fields_for(image)).to have_key 'dimensions'
|
|
125
|
+
expect(config.show_fields_for(image)).to have_key 'photographer'
|
|
84
126
|
end
|
|
85
127
|
end
|
|
86
128
|
|
|
87
129
|
describe "inheritable_copy" do
|
|
130
|
+
let(:klass) { Class.new }
|
|
131
|
+
let(:config_copy) { config.inheritable_copy(klass) }
|
|
132
|
+
|
|
88
133
|
it "provides a deep copy of the configuration" do
|
|
89
|
-
config_copy = @config.inheritable_copy
|
|
90
134
|
config_copy.a = 1
|
|
91
135
|
|
|
92
136
|
@mock_facet = Blacklight::Configuration::FacetField.new
|
|
93
137
|
config_copy.add_facet_field "dummy_field", @mock_facet
|
|
94
138
|
|
|
95
|
-
expect(
|
|
96
|
-
expect(
|
|
139
|
+
expect(config.a).to be_nil
|
|
140
|
+
expect(config.facet_fields).not_to include(@mock_facet)
|
|
97
141
|
end
|
|
98
142
|
|
|
99
143
|
context "when model classes are customised" do
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
config_copy = @config.inheritable_copy
|
|
144
|
+
before do
|
|
145
|
+
config.response_model = Hash
|
|
146
|
+
config.document_model = Array
|
|
147
|
+
end
|
|
105
148
|
|
|
149
|
+
it "does not dup response_model or document_model" do
|
|
106
150
|
expect(config_copy.response_model).to eq Hash
|
|
107
151
|
expect(config_copy.document_model).to eq Array
|
|
108
152
|
end
|
|
@@ -110,33 +154,27 @@ describe "Blacklight::Configuration" do
|
|
|
110
154
|
|
|
111
155
|
context "when model classes are not set" do
|
|
112
156
|
it "leaves response_model and document_model empty" do
|
|
113
|
-
config_copy = @config.inheritable_copy
|
|
114
|
-
|
|
115
157
|
expect(config_copy.fetch(:response_model, nil)).to be_nil
|
|
116
158
|
expect(config_copy.fetch(:document_model, nil)).to be_nil
|
|
117
159
|
end
|
|
118
160
|
|
|
119
161
|
it "returns default classes" do
|
|
120
|
-
config_copy = @config.inheritable_copy
|
|
121
|
-
|
|
122
162
|
expect(config_copy.response_model).to eq Blacklight::Solr::Response
|
|
123
163
|
expect(config_copy.document_model).to eq SolrDocument
|
|
124
164
|
end
|
|
125
165
|
end
|
|
126
166
|
|
|
127
167
|
it "provides cloned copies of mutable data structures" do
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
config_copy = @config.inheritable_copy
|
|
168
|
+
config.a = { value: 1 }
|
|
169
|
+
config.b = [1, 2, 3]
|
|
132
170
|
|
|
133
171
|
config_copy.a[:value] = 2
|
|
134
172
|
config_copy.b << 5
|
|
135
173
|
|
|
136
|
-
expect(
|
|
174
|
+
expect(config.a[:value]).to eq 1
|
|
137
175
|
expect(config_copy.a[:value]).to eq 2
|
|
138
|
-
expect(
|
|
139
|
-
expect(config_copy.b).to match_array [1,2,3,5]
|
|
176
|
+
expect(config.b).to match_array [1, 2, 3]
|
|
177
|
+
expect(config_copy.b).to match_array [1, 2, 3, 5]
|
|
140
178
|
end
|
|
141
179
|
end
|
|
142
180
|
|
|
@@ -145,352 +183,339 @@ describe "Blacklight::Configuration" do
|
|
|
145
183
|
Blacklight::Configuration.define_field_access :my_custom_field
|
|
146
184
|
|
|
147
185
|
config = Blacklight::Configuration.new do |config|
|
|
148
|
-
config.add_my_custom_field 'qwerty', :
|
|
186
|
+
config.add_my_custom_field 'qwerty', label: "asdf"
|
|
149
187
|
end
|
|
150
188
|
|
|
151
|
-
|
|
152
|
-
|
|
153
189
|
expect(config.my_custom_fields.keys).to include('qwerty')
|
|
154
190
|
end
|
|
155
191
|
|
|
156
192
|
it "lets you define a field accessor that uses an existing field-type" do
|
|
157
|
-
|
|
158
|
-
Blacklight::Configuration.define_field_access :my_custom_facet_field, :class => Blacklight::Configuration::FacetField
|
|
193
|
+
Blacklight::Configuration.define_field_access :my_custom_facet_field, class: Blacklight::Configuration::FacetField
|
|
159
194
|
|
|
160
195
|
config = Blacklight::Configuration.new do |config|
|
|
161
|
-
config.add_my_custom_facet_field 'qwerty', :
|
|
196
|
+
config.add_my_custom_facet_field 'qwerty', label: "asdf"
|
|
162
197
|
end
|
|
163
198
|
|
|
164
|
-
|
|
165
|
-
|
|
166
199
|
expect(config.my_custom_facet_fields['qwerty']).to be_a_kind_of(Blacklight::Configuration::FacetField)
|
|
167
200
|
end
|
|
168
|
-
|
|
169
201
|
end
|
|
170
|
-
|
|
202
|
+
|
|
171
203
|
describe "add_facet_field" do
|
|
172
204
|
it "accepts field name and hash form arg" do
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
expect(
|
|
176
|
-
expect(
|
|
177
|
-
expect(
|
|
205
|
+
config.add_facet_field('format', label: "Format", limit: true)
|
|
206
|
+
|
|
207
|
+
expect(config.facet_fields["format"]).not_to be_nil
|
|
208
|
+
expect(config.facet_fields["format"]["label"]).to eq "Format"
|
|
209
|
+
expect(config.facet_fields["format"]["limit"]).to be true
|
|
178
210
|
end
|
|
179
211
|
|
|
180
212
|
it "accepts FacetField obj arg" do
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
expect(
|
|
184
|
-
expect(
|
|
213
|
+
config.add_facet_field("format", Blacklight::Configuration::FacetField.new(label: "Format"))
|
|
214
|
+
|
|
215
|
+
expect(config.facet_fields["format"]).not_to be_nil
|
|
216
|
+
expect(config.facet_fields["format"]["label"]).to eq "Format"
|
|
185
217
|
end
|
|
186
|
-
|
|
218
|
+
|
|
187
219
|
it "accepts field name and block form" do
|
|
188
|
-
|
|
220
|
+
config.add_facet_field("format") do |facet|
|
|
189
221
|
facet.label = "Format"
|
|
190
222
|
facet.limit = true
|
|
191
223
|
end
|
|
192
|
-
|
|
193
|
-
expect(
|
|
194
|
-
expect(
|
|
224
|
+
|
|
225
|
+
expect(config.facet_fields["format"]).not_to be_nil
|
|
226
|
+
expect(config.facet_fields["format"].limit).to be true
|
|
195
227
|
end
|
|
196
228
|
|
|
197
229
|
it "accepts block form" do
|
|
198
|
-
|
|
230
|
+
config.add_facet_field do |facet|
|
|
199
231
|
facet.field = "format"
|
|
200
232
|
facet.label = "Format"
|
|
201
233
|
end
|
|
202
234
|
|
|
203
|
-
expect(
|
|
235
|
+
expect(config.facet_fields['format']).not_to be_nil
|
|
204
236
|
end
|
|
205
237
|
|
|
206
238
|
it "accepts a configuration hash" do
|
|
207
|
-
|
|
208
|
-
expect(
|
|
239
|
+
config.add_facet_field field: 'format', label: 'Format'
|
|
240
|
+
expect(config.facet_fields['format']).not_to be_nil
|
|
209
241
|
end
|
|
210
242
|
|
|
211
243
|
it "accepts array form" do
|
|
212
|
-
|
|
244
|
+
config.add_facet_field([{ field: 'format', label: 'Format' }, { field: 'publication_date', label: 'Publication Date' }])
|
|
213
245
|
|
|
214
|
-
expect(
|
|
246
|
+
expect(config.facet_fields).to have(2).fields
|
|
215
247
|
end
|
|
216
248
|
|
|
217
249
|
it "accepts array form with a block" do
|
|
218
250
|
expect do |b|
|
|
219
|
-
|
|
251
|
+
config.add_facet_field([{ field: 'format', label: 'Format' }, { field: 'publication_date', label: 'Publication Date' }], &b)
|
|
220
252
|
end.to yield_control.twice
|
|
221
253
|
end
|
|
222
254
|
|
|
223
|
-
|
|
224
255
|
it "creates default label from titleized solr field" do
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
expect(
|
|
256
|
+
config.add_facet_field("publication_date")
|
|
257
|
+
|
|
258
|
+
expect(config.facet_fields["publication_date"].label).to eq "Publication Date"
|
|
228
259
|
end
|
|
229
260
|
|
|
230
261
|
it "allows you to not show the facet in the facet bar" do
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
expect(
|
|
262
|
+
config.add_facet_field("publication_date", show: false)
|
|
263
|
+
|
|
264
|
+
expect(config.facet_fields["publication_date"]['show']).to be false
|
|
234
265
|
end
|
|
235
|
-
|
|
266
|
+
|
|
236
267
|
it "raises on nil solr field name" do
|
|
237
|
-
expect {
|
|
268
|
+
expect { config.add_facet_field(nil) }.to raise_error ArgumentError
|
|
238
269
|
end
|
|
239
270
|
|
|
240
271
|
it "looks up and match field names" do
|
|
241
|
-
allow(
|
|
242
|
-
"some_field_facet" => {},
|
|
272
|
+
allow(config).to receive(:reflected_fields).and_return(
|
|
273
|
+
"some_field_facet" => {},
|
|
243
274
|
"another_field_facet" => {},
|
|
244
|
-
"a_facet_field" => {}
|
|
245
|
-
|
|
246
|
-
expect { |b|
|
|
275
|
+
"a_facet_field" => {}
|
|
276
|
+
)
|
|
277
|
+
expect { |b| config.add_facet_field match: /_facet$/, &b }.to yield_control.twice
|
|
247
278
|
|
|
248
|
-
expect(
|
|
279
|
+
expect(config.facet_fields.keys).to eq %w[some_field_facet another_field_facet]
|
|
249
280
|
end
|
|
250
281
|
|
|
251
282
|
it "takes wild-carded field names and dereference them to solr fields" do
|
|
252
|
-
allow(
|
|
283
|
+
allow(config).to receive(:reflected_fields).and_return(
|
|
253
284
|
"some_field_facet" => {},
|
|
254
285
|
"another_field_facet" => {},
|
|
255
|
-
"a_facet_field" => {}
|
|
256
|
-
|
|
257
|
-
expect { |b|
|
|
286
|
+
"a_facet_field" => {}
|
|
287
|
+
)
|
|
288
|
+
expect { |b| config.add_facet_field "*_facet", &b }.to yield_control.twice
|
|
258
289
|
|
|
259
|
-
expect(
|
|
290
|
+
expect(config.facet_fields.keys).to eq %w[some_field_facet another_field_facet]
|
|
260
291
|
end
|
|
261
292
|
|
|
262
293
|
describe "if/unless conditions with legacy show parameter" do
|
|
263
294
|
it "is hidden if the if condition is false" do
|
|
264
|
-
expect(
|
|
265
|
-
expect(
|
|
295
|
+
expect(config.add_facet_field("hidden", if: false).if).to eq false
|
|
296
|
+
expect(config.add_facet_field("hidden_with_legacy", if: false, show: true).if).to eq false
|
|
266
297
|
end
|
|
267
298
|
|
|
268
299
|
it "is true if the if condition is true" do
|
|
269
|
-
expect(
|
|
270
|
-
expect(
|
|
300
|
+
expect(config.add_facet_field("hidden", if: true).if).to eq true
|
|
301
|
+
expect(config.add_facet_field("hidden_with_legacy", if: true, show: false).if).to eq true
|
|
271
302
|
end
|
|
272
303
|
|
|
273
304
|
it "is true if the if condition is missing" do
|
|
274
|
-
expect(
|
|
305
|
+
expect(config.add_facet_field("hidden", show: true).if).to eq true
|
|
275
306
|
end
|
|
276
307
|
end
|
|
277
308
|
end
|
|
278
|
-
|
|
309
|
+
|
|
279
310
|
describe "add_index_field" do
|
|
280
311
|
it "takes hash form" do
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
expect(
|
|
284
|
-
expect(
|
|
312
|
+
config.add_index_field("title_tsim", label: "Title")
|
|
313
|
+
|
|
314
|
+
expect(config.index_fields["title_tsim"]).not_to be_nil
|
|
315
|
+
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
|
285
316
|
end
|
|
286
317
|
it "takes IndexField param" do
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
expect(
|
|
290
|
-
expect(
|
|
318
|
+
config.add_index_field("title_tsim", Blacklight::Configuration::IndexField.new(field: "title_display", label: "Title"))
|
|
319
|
+
|
|
320
|
+
expect(config.index_fields["title_tsim"]).not_to be_nil
|
|
321
|
+
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
|
291
322
|
end
|
|
292
323
|
it "takes block form" do
|
|
293
|
-
|
|
324
|
+
config.add_index_field("title_tsim") do |field|
|
|
294
325
|
field.label = "Title"
|
|
295
326
|
end
|
|
296
|
-
expect(
|
|
297
|
-
expect(
|
|
327
|
+
expect(config.index_fields["title_tsim"]).not_to be_nil
|
|
328
|
+
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
|
298
329
|
end
|
|
299
|
-
|
|
330
|
+
|
|
300
331
|
it "creates default label from titleized field" do
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
expect(
|
|
332
|
+
config.add_index_field("title_tsim")
|
|
333
|
+
|
|
334
|
+
expect(config.index_fields["title_tsim"].label).to eq "Title Tsim"
|
|
304
335
|
end
|
|
305
|
-
|
|
336
|
+
|
|
306
337
|
it "raises on nil solr field name" do
|
|
307
|
-
expect {
|
|
338
|
+
expect { config.add_index_field(nil) }.to raise_error ArgumentError
|
|
308
339
|
end
|
|
309
340
|
|
|
310
341
|
it "takes wild-carded field names and dereference them to solr fields" do
|
|
311
|
-
allow(
|
|
312
|
-
"some_field_display" => {},
|
|
342
|
+
allow(config).to receive(:reflected_fields).and_return(
|
|
343
|
+
"some_field_display" => {},
|
|
313
344
|
"another_field_display" => {},
|
|
314
|
-
"a_facet_field" => {}
|
|
315
|
-
|
|
316
|
-
|
|
345
|
+
"a_facet_field" => {}
|
|
346
|
+
)
|
|
347
|
+
config.add_index_field "*_display"
|
|
317
348
|
|
|
318
|
-
expect(
|
|
349
|
+
expect(config.index_fields.keys).to eq %w[some_field_display another_field_display]
|
|
319
350
|
end
|
|
320
351
|
|
|
321
352
|
it "queries solr and get live values for match fields", integration: true do
|
|
322
|
-
|
|
323
|
-
expect(
|
|
353
|
+
config.add_index_field match: /title.+sim/
|
|
354
|
+
expect(config.index_fields.keys).to include "subtitle_tsim", "subtitle_vern_ssim", "title_tsim", "title_vern_ssim"
|
|
324
355
|
end
|
|
325
356
|
end
|
|
326
|
-
|
|
357
|
+
|
|
327
358
|
describe "add_show_field" do
|
|
328
359
|
it "takes hash form" do
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
expect(
|
|
332
|
-
expect(
|
|
360
|
+
config.add_show_field("title_tsim", label: "Title")
|
|
361
|
+
|
|
362
|
+
expect(config.show_fields["title_tsim"]).not_to be_nil
|
|
363
|
+
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
|
333
364
|
end
|
|
334
365
|
it "takes ShowField argument" do
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
expect(
|
|
338
|
-
expect(
|
|
366
|
+
config.add_show_field("title_tsim", Blacklight::Configuration::ShowField.new(field: "title_display", label: "Title"))
|
|
367
|
+
|
|
368
|
+
expect(config.show_fields["title_tsim"]).not_to be_nil
|
|
369
|
+
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
|
339
370
|
end
|
|
340
371
|
it "takes block form" do
|
|
341
|
-
|
|
372
|
+
config.add_show_field("title_tsim") do |f|
|
|
342
373
|
f.label = "Title"
|
|
343
374
|
end
|
|
344
|
-
|
|
345
|
-
expect(
|
|
346
|
-
expect(
|
|
375
|
+
|
|
376
|
+
expect(config.show_fields["title_tsim"]).not_to be_nil
|
|
377
|
+
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
|
347
378
|
end
|
|
348
|
-
|
|
379
|
+
|
|
349
380
|
it "creates default label humanized from field" do
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
expect(
|
|
381
|
+
config.add_show_field("my_custom_field")
|
|
382
|
+
|
|
383
|
+
expect(config.show_fields["my_custom_field"].label).to eq "My Custom Field"
|
|
353
384
|
end
|
|
354
|
-
|
|
385
|
+
|
|
355
386
|
it "raises on nil solr field name" do
|
|
356
|
-
expect {
|
|
387
|
+
expect { config.add_show_field(nil) }.to raise_error ArgumentError
|
|
357
388
|
end
|
|
358
|
-
|
|
389
|
+
|
|
359
390
|
it "takes wild-carded field names and dereference them to solr fields" do
|
|
360
|
-
allow(
|
|
361
|
-
"some_field_display" => {},
|
|
391
|
+
allow(config).to receive(:reflected_fields).and_return(
|
|
392
|
+
"some_field_display" => {},
|
|
362
393
|
"another_field_display" => {},
|
|
363
|
-
"a_facet_field" => {}
|
|
364
|
-
|
|
365
|
-
|
|
394
|
+
"a_facet_field" => {}
|
|
395
|
+
)
|
|
396
|
+
config.add_show_field "*_display"
|
|
366
397
|
|
|
367
|
-
expect(
|
|
398
|
+
expect(config.show_fields.keys).to eq %w[some_field_display another_field_display]
|
|
368
399
|
end
|
|
369
|
-
|
|
370
400
|
end
|
|
371
|
-
|
|
372
|
-
|
|
401
|
+
|
|
373
402
|
describe "add_search_field" do
|
|
374
403
|
it "accepts hash form" do
|
|
375
404
|
c = Blacklight::Configuration.new
|
|
376
|
-
c.add_search_field(:
|
|
377
|
-
expect(c.search_fields["my_search_key"]).
|
|
405
|
+
c.add_search_field(key: "my_search_key")
|
|
406
|
+
expect(c.search_fields["my_search_key"]).not_to be_nil
|
|
378
407
|
end
|
|
379
408
|
|
|
380
409
|
it "accepts two-arg hash form" do
|
|
381
410
|
c = Blacklight::Configuration.new
|
|
382
|
-
|
|
411
|
+
|
|
383
412
|
c.add_search_field("my_search_type",
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
413
|
+
key: "my_search_type",
|
|
414
|
+
solr_parameters: { qf: "my_field_qf^10" },
|
|
415
|
+
solr_local_parameters: { pf: "$my_field_pf" })
|
|
416
|
+
|
|
388
417
|
field = c.search_fields["my_search_type"]
|
|
389
|
-
|
|
390
|
-
expect(field).
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
expect(field.
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
end
|
|
398
|
-
|
|
418
|
+
|
|
419
|
+
expect(field).not_to be_nil
|
|
420
|
+
|
|
421
|
+
expect(field.solr_parameters).not_to be_nil
|
|
422
|
+
expect(field.solr_local_parameters).not_to be_nil
|
|
423
|
+
end
|
|
424
|
+
|
|
399
425
|
it "accepts block form" do
|
|
400
426
|
c = Blacklight::Configuration.new
|
|
401
|
-
|
|
402
|
-
c.add_search_field("some_field") do |field|
|
|
403
|
-
field.solr_parameters = {:
|
|
404
|
-
field.solr_local_parameters = {:
|
|
427
|
+
|
|
428
|
+
c.add_search_field("some_field") do |field|
|
|
429
|
+
field.solr_parameters = { qf: "solr_field^10" }
|
|
430
|
+
field.solr_local_parameters = { pf: "$some_field_pf" }
|
|
405
431
|
end
|
|
406
|
-
|
|
432
|
+
|
|
407
433
|
f = c.search_fields["some_field"]
|
|
408
|
-
|
|
409
|
-
expect(f).
|
|
410
|
-
expect(f.solr_parameters).
|
|
411
|
-
expect(f.solr_local_parameters).
|
|
434
|
+
|
|
435
|
+
expect(f).not_to be_nil
|
|
436
|
+
expect(f.solr_parameters).not_to be_nil
|
|
437
|
+
expect(f.solr_local_parameters).not_to be_nil
|
|
412
438
|
end
|
|
413
|
-
|
|
439
|
+
|
|
414
440
|
it "accepts SearchField object" do
|
|
415
441
|
c = Blacklight::Configuration.new
|
|
416
|
-
|
|
417
|
-
f = Blacklight::Configuration::SearchField.new(
|
|
418
|
-
|
|
442
|
+
|
|
443
|
+
f = Blacklight::Configuration::SearchField.new(foo: "bar")
|
|
444
|
+
|
|
419
445
|
c.add_search_field("foo", f)
|
|
420
|
-
|
|
421
|
-
expect(c.search_fields["foo"]).
|
|
446
|
+
|
|
447
|
+
expect(c.search_fields["foo"]).not_to be_nil
|
|
422
448
|
end
|
|
423
|
-
|
|
449
|
+
|
|
424
450
|
it "raises on nil key" do
|
|
425
|
-
expect {
|
|
451
|
+
expect { config.add_search_field(nil, foo: "bar") }.to raise_error ArgumentError
|
|
426
452
|
end
|
|
427
|
-
|
|
453
|
+
|
|
428
454
|
it "creates default label from titleized field key" do
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
expect(
|
|
455
|
+
config.add_search_field("author_name")
|
|
456
|
+
|
|
457
|
+
expect(config.search_fields["author_name"].label).to eq "Author Name"
|
|
432
458
|
end
|
|
433
459
|
|
|
434
460
|
describe "if/unless conditions with legacy include_in_simple_search" do
|
|
435
461
|
it "is hidden if the if condition is false" do
|
|
436
|
-
expect(
|
|
437
|
-
expect(
|
|
462
|
+
expect(config.add_search_field("hidden", if: false).if).to eq false
|
|
463
|
+
expect(config.add_search_field("hidden_with_legacy", if: false, include_in_simple_search: true).if).to eq false
|
|
438
464
|
end
|
|
439
465
|
|
|
440
466
|
it "is true if the if condition is true" do
|
|
441
|
-
expect(
|
|
442
|
-
expect(
|
|
467
|
+
expect(config.add_search_field("hidden", if: true).if).to eq true
|
|
468
|
+
expect(config.add_search_field("hidden_with_legacy", if: true, include_in_simple_search: false).if).to eq true
|
|
443
469
|
end
|
|
444
470
|
|
|
445
471
|
it "is true if the if condition is missing" do
|
|
446
|
-
expect(
|
|
472
|
+
expect(config.add_search_field("hidden", include_in_simple_search: true).if).to eq true
|
|
447
473
|
end
|
|
448
474
|
end
|
|
449
475
|
end
|
|
450
|
-
|
|
476
|
+
|
|
451
477
|
describe "add_sort_field" do
|
|
452
478
|
it "takes a hash" do
|
|
453
479
|
c = Blacklight::Configuration.new
|
|
454
|
-
c.add_sort_field(:
|
|
455
|
-
expect(c.sort_fields["my_sort_key"]).
|
|
480
|
+
c.add_sort_field(key: "my_sort_key", sort: "score desc")
|
|
481
|
+
expect(c.sort_fields["my_sort_key"]).not_to be_nil
|
|
456
482
|
end
|
|
457
483
|
|
|
458
484
|
it "takes a two-arg form with a hash" do
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
expect(@config.sort_fields.values.find{|f| f.label == "relevance"}).to_not be_nil
|
|
485
|
+
config.add_sort_field("score desc, pub_date_si desc, title_si asc", label: "relevance")
|
|
486
|
+
expect(config.sort_fields.values.find { |f| f.label == "relevance" }).not_to be_nil
|
|
463
487
|
end
|
|
464
|
-
|
|
488
|
+
|
|
465
489
|
it "takes a SortField object" do
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
490
|
+
config.add_sort_field(
|
|
491
|
+
Blacklight::Configuration::SortField.new(label: "relevance",
|
|
492
|
+
sort: "score desc, pub_date_sort desc, title_sort asc")
|
|
493
|
+
)
|
|
494
|
+
expect(config.sort_fields.values.find { |f| f.label == "relevance" }).not_to be_nil
|
|
469
495
|
end
|
|
470
|
-
|
|
496
|
+
|
|
471
497
|
it "takes block form" do
|
|
472
|
-
|
|
498
|
+
config.add_sort_field do |field|
|
|
473
499
|
field.label = "relevance"
|
|
474
|
-
field.sort = "score desc,
|
|
500
|
+
field.sort = "score desc, pub_date_si desc, title_si asc"
|
|
475
501
|
end
|
|
476
|
-
|
|
477
|
-
expect(@config.sort_fields.values.find{|f| f.label == "relevance"}).to_not be_nil
|
|
478
502
|
|
|
503
|
+
expect(config.sort_fields.values.find { |f| f.label == "relevance" }).not_to be_nil
|
|
479
504
|
end
|
|
480
505
|
end
|
|
481
|
-
|
|
506
|
+
|
|
482
507
|
describe "#default_search_field" do
|
|
483
508
|
it "uses the field with a :default key" do
|
|
484
|
-
|
|
485
|
-
|
|
509
|
+
config.add_search_field('search_field_1')
|
|
510
|
+
config.add_search_field('search_field_2', default: true)
|
|
486
511
|
|
|
487
|
-
expect(
|
|
512
|
+
expect(config.default_search_field.key).to eq 'search_field_2'
|
|
488
513
|
end
|
|
489
514
|
end
|
|
490
515
|
|
|
491
516
|
describe "#facet_paginator_class" do
|
|
492
517
|
it "defaults to Blacklight::Solr::FacetPaginator" do
|
|
493
|
-
expect(
|
|
518
|
+
expect(config.facet_paginator_class).to eq Blacklight::Solr::FacetPaginator
|
|
494
519
|
end
|
|
495
520
|
end
|
|
496
521
|
end
|