blacklight-spotlight 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -8
- data/Rakefile +40 -39
- data/app/assets/javascripts/spotlight/blacklight_configuration.js +16 -0
- data/app/assets/javascripts/spotlight/blocks/resources_block.js +3 -1
- data/app/assets/stylesheets/spotlight/_blacklight_configuration.scss +2 -2
- data/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +24 -0
- data/app/assets/stylesheets/spotlight/_header.scss +150 -47
- data/app/assets/stylesheets/spotlight/_pages.scss +62 -11
- data/app/assets/stylesheets/spotlight/_report_a_problem.scss +1 -0
- data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -0
- data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +28 -21
- data/app/controllers/spotlight/about_pages_controller.rb +25 -14
- data/app/controllers/spotlight/appearances_controller.rb +34 -30
- data/app/controllers/spotlight/application_controller.rb +2 -1
- data/app/controllers/spotlight/attachments_controller.rb +9 -7
- data/app/controllers/spotlight/browse_controller.rb +13 -9
- data/app/controllers/spotlight/catalog_controller.rb +179 -161
- data/app/controllers/spotlight/concerns/application_controller.rb +22 -20
- data/app/controllers/spotlight/concerns/catalog_search_context.rb +44 -0
- data/app/controllers/spotlight/confirmations_controller.rb +5 -2
- data/app/controllers/spotlight/contact_forms_controller.rb +13 -7
- data/app/controllers/spotlight/contacts_controller.rb +13 -4
- data/app/controllers/spotlight/custom_fields_controller.rb +48 -40
- data/app/controllers/spotlight/dashboards_controller.rb +17 -8
- data/app/controllers/spotlight/default_controller.rb +3 -1
- data/app/controllers/spotlight/exhibits_controller.rb +69 -62
- data/app/controllers/spotlight/feature_pages_controller.rb +21 -11
- data/app/controllers/spotlight/home_pages_controller.rb +6 -5
- data/app/controllers/spotlight/lock_controller.rb +3 -1
- data/app/controllers/spotlight/metadata_configurations_controller.rb +49 -0
- data/app/controllers/spotlight/pages_controller.rb +28 -18
- data/app/controllers/spotlight/resources/upload_controller.rb +53 -46
- data/app/controllers/spotlight/resources_controller.rb +9 -5
- data/app/controllers/spotlight/roles_controller.rb +26 -22
- data/app/controllers/spotlight/search_configurations_controller.rb +66 -0
- data/app/controllers/spotlight/searches_controller.rb +91 -82
- data/app/controllers/spotlight/solr_controller.rb +20 -13
- data/app/controllers/spotlight/tags_controller.rb +5 -3
- data/app/controllers/spotlight/versions_controller.rb +15 -12
- data/app/controllers/spotlight/view_configurations_controller.rb +17 -0
- data/app/helpers/spotlight/application_helper.rb +44 -32
- data/app/helpers/spotlight/browse_helper.rb +13 -1
- data/app/helpers/spotlight/crud_link_helpers.rb +22 -14
- data/app/helpers/spotlight/jcrop_helper.rb +4 -2
- data/app/helpers/spotlight/main_app_helpers.rb +45 -41
- data/app/helpers/spotlight/navbar_helper.rb +6 -0
- data/app/helpers/spotlight/pages_helper.rb +23 -15
- data/app/helpers/spotlight/roles_helper.rb +10 -4
- data/app/helpers/spotlight/search_configurations_helper.rb +22 -0
- data/app/helpers/spotlight/title_helper.rb +16 -13
- data/app/jobs/spotlight/add_uploads_from_csv.rb +13 -9
- data/app/jobs/spotlight/reindex_job.rb +9 -9
- data/app/jobs/spotlight/rename_sidecar_field_job.rb +3 -0
- data/app/mailers/spotlight/confirmation_mailer.rb +2 -0
- data/app/mailers/spotlight/indexing_complete_mailer.rb +4 -2
- data/app/models/ability.rb +3 -0
- data/app/models/concerns/spotlight/ar_light.rb +49 -25
- data/app/models/concerns/spotlight/blacklight_configuration_defaults.rb +25 -10
- data/app/models/concerns/spotlight/exhibit_analytics.rb +28 -0
- data/app/models/concerns/spotlight/image_derivatives.rb +25 -26
- data/app/models/concerns/spotlight/resources/open_graph.rb +23 -19
- data/app/models/concerns/spotlight/resources/web.rb +25 -24
- data/app/models/concerns/spotlight/solr_document.rb +40 -34
- data/app/models/concerns/spotlight/solr_document/active_model_concern.rb +29 -40
- data/app/models/concerns/spotlight/solr_document/atomic_updates.rb +22 -18
- data/app/models/concerns/spotlight/solr_document/finder.rb +23 -18
- data/app/models/concerns/spotlight/solr_document/spotlight_images.rb +43 -39
- data/app/models/concerns/spotlight/solr_document/uploaded_resource.rb +41 -29
- data/app/models/concerns/spotlight/user.rb +25 -19
- data/app/models/sir_trevor_rails/blocks/browse_block.rb +36 -30
- data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +24 -18
- data/app/models/sir_trevor_rails/blocks/oembed_block.rb +8 -4
- data/app/models/sir_trevor_rails/blocks/search_results_block.rb +29 -23
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +43 -42
- data/app/models/sir_trevor_rails/blocks/solr_documents_carousel_block.rb +16 -12
- data/app/models/sir_trevor_rails/blocks/solr_documents_embed_block.rb +7 -3
- data/app/models/sir_trevor_rails/blocks/solr_documents_features_block.rb +7 -3
- data/app/models/sir_trevor_rails/blocks/solr_documents_grid_block.rb +7 -3
- data/app/models/sir_trevor_rails/blocks/textable.rb +18 -18
- data/app/models/spotlight/ability.rb +32 -33
- data/app/models/spotlight/about_page.rb +3 -1
- data/app/models/spotlight/analytics/ga.rb +46 -27
- data/app/models/spotlight/attachment.rb +3 -1
- data/app/models/spotlight/blacklight_configuration.rb +146 -68
- data/app/models/spotlight/contact.rb +35 -30
- data/app/models/spotlight/contact_email.rb +6 -3
- data/app/models/spotlight/contact_form.rb +4 -3
- data/app/models/spotlight/custom_field.rb +41 -33
- data/app/models/spotlight/exhibit.rb +104 -130
- data/app/models/spotlight/feature_page.rb +9 -7
- data/app/models/spotlight/featured_image.rb +10 -10
- data/app/models/spotlight/field_metadata.rb +46 -0
- data/app/models/spotlight/home_page.rb +8 -5
- data/app/models/spotlight/lock.rb +4 -3
- data/app/models/spotlight/main_navigation.rb +9 -3
- data/app/models/spotlight/masthead.rb +17 -16
- data/app/models/spotlight/page.rb +16 -16
- data/app/models/spotlight/resource.rb +69 -22
- data/app/models/spotlight/resources/csv_upload.rb +8 -4
- data/app/models/spotlight/resources/upload.rb +68 -57
- data/app/models/spotlight/role.rb +30 -34
- data/app/models/spotlight/search.rb +74 -63
- data/app/models/spotlight/solr_document_sidecar.rb +17 -15
- data/app/serializers/spotlight/exhibit_export_serializer.rb +65 -29
- data/app/serializers/spotlight/page_representer.rb +10 -6
- data/app/uploaders/spotlight/attachment_uploader.rb +4 -6
- data/app/uploaders/spotlight/avatar_uploader.rb +4 -3
- data/app/uploaders/spotlight/featured_image_uploader.rb +15 -14
- data/app/uploaders/spotlight/item_uploader.rb +3 -1
- data/app/uploaders/spotlight/masthead_uploader.rb +4 -2
- data/app/views/catalog/_search_form.html.erb +24 -0
- data/app/views/shared/_browse_navbar.html.erb +1 -1
- data/app/views/shared/_exhibit_navbar.html.erb +1 -1
- data/app/views/spotlight/appearances/edit.html.erb +13 -45
- data/app/views/spotlight/catalog/_edit_default.html.erb +1 -1
- data/app/views/spotlight/custom_fields/_form.html.erb +1 -1
- data/app/views/spotlight/exhibits/edit.html.erb +4 -4
- data/app/views/spotlight/home_pages/_empty.html.erb +1 -3
- data/app/views/spotlight/home_pages/_page_options.html.erb +1 -1
- data/app/views/spotlight/{blacklight_configurations → metadata_configurations}/_metadata_field.html.erb +0 -0
- data/app/views/spotlight/{blacklight_configurations/edit_metadata_fields.html.erb → metadata_configurations/edit.html.erb} +1 -1
- data/app/views/spotlight/pages/show.html.erb +2 -2
- data/app/views/spotlight/search_configurations/_default_per_page.html.erb +5 -0
- data/app/views/spotlight/search_configurations/_document_index_view_types.html.erb +7 -0
- data/app/views/spotlight/search_configurations/_facets.html.erb +38 -0
- data/app/views/spotlight/search_configurations/_search_fields.html.erb +58 -0
- data/app/views/spotlight/search_configurations/_sort.html.erb +53 -0
- data/app/views/spotlight/search_configurations/edit.html.erb +46 -0
- data/app/views/spotlight/searches/_search.html.erb +1 -1
- data/app/views/spotlight/shared/_admin_sidebar.html.erb +0 -2
- data/app/views/spotlight/shared/_curation_sidebar.html.erb +2 -3
- data/app/views/spotlight/shared/_report_a_problem.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_oembed_block.html.erb +5 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +7 -5
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb +7 -5
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +14 -9
- data/config/locales/spotlight.en.yml +94 -49
- data/config/routes.rb +11 -20
- data/db/migrate/20150410180014_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
- data/db/migrate/20150410180015_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
- data/db/migrate/20150410180016_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
- data/db/migrate/20150713160101_change_spotlight_searches_to_published.rb +5 -0
- data/db/migrate/20151016092343_remove_searchable_from_exhibit.rb +20 -0
- data/lib/blacklight/spotlight.rb +1 -1
- data/lib/generators/spotlight/install_generator.rb +27 -25
- data/lib/generators/spotlight/templates/catalog_controller.rb +7 -5
- data/lib/generators/spotlight/templates/jetty.rake +8 -2
- data/lib/generators/spotlight/templates/spotlight_helper.rb +3 -1
- data/lib/spotlight.rb +4 -2
- data/lib/spotlight/base.rb +21 -14
- data/lib/spotlight/catalog.rb +10 -9
- data/lib/spotlight/catalog/access_controls_enforcement.rb +30 -15
- data/lib/spotlight/config.rb +4 -2
- data/lib/spotlight/controller.rb +12 -11
- data/lib/spotlight/engine.rb +30 -22
- data/lib/spotlight/rails/routes.rb +7 -4
- data/lib/spotlight/version.rb +2 -1
- data/lib/tasks/spotlight_tasks.rake +56 -50
- data/spec/controllers/application_controller_spec.rb +13 -13
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +63 -59
- data/spec/controllers/spotlight/appearances_controller_spec.rb +29 -24
- data/spec/controllers/spotlight/application_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/attachments_controller_spec.rb +10 -10
- data/spec/controllers/spotlight/browse_controller_spec.rb +23 -25
- data/spec/controllers/spotlight/catalog_controller_spec.rb +82 -87
- data/spec/controllers/spotlight/confirmations_controller_spec.rb +13 -11
- data/spec/controllers/spotlight/contact_forms_controller_spec.rb +17 -12
- data/spec/controllers/spotlight/contacts_controller_spec.rb +36 -36
- data/spec/controllers/spotlight/custom_fields_controller_spec.rb +26 -26
- data/spec/controllers/spotlight/dashboards_controller_spec.rb +14 -14
- data/spec/controllers/spotlight/exhibits_controller_spec.rb +59 -54
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +59 -59
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +28 -29
- data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +84 -0
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +42 -33
- data/spec/controllers/spotlight/resources_controller_spec.rb +25 -29
- data/spec/controllers/spotlight/roles_controller_spec.rb +37 -19
- data/spec/controllers/spotlight/search_configurations_controller_spec.rb +125 -0
- data/spec/controllers/spotlight/searches_controller_spec.rb +84 -63
- data/spec/controllers/spotlight/solr_controller_spec.rb +13 -14
- data/spec/controllers/spotlight/tags_controller_spec.rb +16 -16
- data/spec/controllers/spotlight/versions_controller_spec.rb +15 -18
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +31 -0
- data/spec/factories/contacts.rb +1 -3
- data/spec/factories/custom_fields.rb +2 -4
- data/spec/factories/exhibits.rb +4 -2
- data/spec/factories/pages.rb +8 -11
- data/spec/factories/resources.rb +4 -4
- data/spec/factories/searches.rb +10 -13
- data/spec/factories/tags.rb +0 -3
- data/spec/factories/users.rb +2 -4
- data/spec/features/about_page_spec.rb +19 -19
- data/spec/features/add_contacts_spec.rb +34 -34
- data/spec/features/add_custom_field_metadata_spec.rb +24 -26
- data/spec/features/add_item_bookmarklet_spec.rb +12 -12
- data/spec/features/browse_category_admin_spec.rb +39 -39
- data/spec/features/catalog_spec.rb +9 -10
- data/spec/features/confirm_email_spec.rb +10 -10
- data/spec/features/create_exhibit_spec.rb +18 -15
- data/spec/features/create_page_spec.rb +8 -8
- data/spec/features/curator_items.rb +3 -3
- data/spec/features/dashboard_spec.rb +15 -16
- data/spec/features/edit_contact_spec.rb +8 -10
- data/spec/features/edit_search_fields_spec.rb +79 -0
- data/spec/features/exhibits/add_tags_spec.rb +15 -16
- data/spec/features/exhibits/administration_spec.rb +25 -25
- data/spec/features/exhibits/custom_metadata_fields_spec.rb +41 -43
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +19 -19
- data/spec/features/feature_page_spec.rb +49 -48
- data/spec/features/home_page_spec.rb +38 -38
- data/spec/features/import_exhibit_spec.rb +23 -20
- data/spec/features/item_admin_spec.rb +28 -29
- data/spec/features/javascript/about_page_admin_spec.rb +9 -9
- data/spec/features/javascript/block_controls_spec.rb +16 -18
- data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +11 -12
- data/spec/features/javascript/blocks/featured_pages_block_spec.rb +12 -13
- data/spec/features/javascript/blocks/search_result_block_spec.rb +17 -17
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +67 -65
- data/spec/features/javascript/edit_in_place_spec.rb +30 -56
- data/spec/features/javascript/feature_page_admin_spec.rb +73 -59
- data/spec/features/javascript/home_page_edit_spec.rb +6 -6
- data/spec/features/javascript/metadata_admin_spec.rb +15 -15
- data/spec/features/javascript/multi_image_select_spec.rb +17 -18
- data/spec/features/javascript/preview_block_spec.rb +11 -12
- data/spec/features/javascript/rule_block_spec.rb +7 -7
- data/spec/features/javascript/search_config_admin_spec.rb +144 -0
- data/spec/features/javascript/search_context_spec.rb +41 -42
- data/spec/features/main_navigation_spec.rb +22 -22
- data/spec/features/metadata_admin_spec.rb +8 -8
- data/spec/features/multiple_exhibits_spec.rb +15 -17
- data/spec/features/report_a_problem_spec.rb +23 -17
- data/spec/features/site_masthead_spec.rb +46 -46
- data/spec/features/slideshow_spec.rb +8 -9
- data/spec/features/tags_admin_spec.rb +11 -11
- data/spec/features/upload_non_repository_item_spec.rb +32 -32
- data/spec/features/user_admin_spec.rb +7 -7
- data/spec/helpers/spotlight/application_helper_spec.rb +63 -56
- data/spec/helpers/spotlight/browse_helper_spec.rb +6 -6
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +58 -52
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +44 -24
- data/spec/helpers/spotlight/navbar_helper_spec.rb +4 -4
- data/spec/helpers/spotlight/pages_helper_spec.rb +56 -37
- data/spec/helpers/spotlight/roles_helper_spec.rb +3 -3
- data/spec/helpers/spotlight/search_configurations_helper_spec.rb +24 -0
- data/spec/helpers/spotlight/title_helper_spec.rb +33 -35
- data/spec/jobs/spotlight/reindex_job_spec.rb +6 -6
- data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +7 -7
- data/spec/lib/spotlight/catalog/access_controls_enforcement_spec.rb +41 -26
- data/spec/lib/spotlight/controller_spec.rb +10 -10
- data/spec/lib/spotlight/routes_spec.rb +4 -4
- data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +13 -13
- data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +8 -8
- data/spec/models/{spotlight/sir_trevor_blocks → sir_trevor_rails/blocks}/textable_spec.rb +7 -8
- data/spec/models/solr_document_spec.rb +49 -50
- data/spec/models/spotlight/ability_spec.rb +17 -20
- data/spec/models/spotlight/about_page_spec.rb +6 -6
- data/spec/models/spotlight/analytics/ga_spec.rb +2 -2
- data/spec/models/spotlight/blacklight_configuration_spec.rb +196 -133
- data/spec/models/spotlight/contact_email_spec.rb +28 -24
- data/spec/models/spotlight/contact_spec.rb +6 -7
- data/spec/models/spotlight/custom_field_spec.rb +51 -52
- data/spec/models/spotlight/exhibit_spec.rb +102 -60
- data/spec/models/spotlight/feature_page_spec.rb +32 -32
- data/spec/models/spotlight/featured_image_spec.rb +5 -5
- data/spec/models/spotlight/field_metadata_spec.rb +78 -0
- data/spec/models/spotlight/home_page_spec.rb +11 -20
- data/spec/models/spotlight/{spotlight_image_derivatives_spec.rb → image_derivatives_spec.rb} +2 -2
- data/spec/models/spotlight/main_navigation_spec.rb +7 -9
- data/spec/models/spotlight/masthead_spec.rb +6 -6
- data/spec/models/spotlight/page_spec.rb +26 -29
- data/spec/models/spotlight/resource_spec.rb +56 -26
- data/spec/models/spotlight/resources/open_graph_spec.rb +16 -18
- data/spec/models/spotlight/resources/upload_spec.rb +32 -35
- data/spec/models/spotlight/resources/web_spec.rb +9 -11
- data/spec/models/spotlight/role_spec.rb +20 -20
- data/spec/models/spotlight/search_spec.rb +32 -15
- data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +34 -0
- data/spec/models/spotlight/{solr_document_images_spec.rb → solr_document/spotlight_images_spec.rb} +18 -10
- data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +52 -0
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +3 -4
- data/spec/routing/spotlight/exhibit_catalog_spec.rb +5 -5
- data/spec/routing/spotlight/pages_routing_spec.rb +24 -25
- data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +88 -68
- data/spec/spec_helper.rb +13 -22
- data/spec/support/features/test_features_helpers.rb +50 -46
- data/spec/support/views/test_view_helpers.rb +1 -1
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/test_app_templates/carrierwave.rb +2 -2
- data/spec/test_app_templates/catalog_controller.rb +42 -42
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +20 -11
- data/spec/test_app_templates/spotlight_test.rake +3 -3
- data/spec/uploaders/spotlight/item_uploader_spec.rb +68 -0
- data/spec/views/_user_util_links.html.erb_spec.rb +14 -14
- data/spec/views/shared/_analytics.html.erb_spec.rb +4 -6
- data/spec/views/shared/_exhibit_masthead.html.erb_spec.rb +19 -20
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +129 -131
- data/spec/views/shared/_footer.html.erb_spec.rb +6 -7
- data/spec/views/shared/_header_navbar.html.erb_spec.rb +5 -5
- data/spec/views/spotlight/about_pages/_empty.html.erb_spec.rb +4 -4
- data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +9 -11
- data/spec/views/spotlight/about_pages/index.html.erb_spec.rb +31 -28
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/browse/_sort_and_per_page.html.erb_spec.rb +10 -12
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/browse/show.html.erb_spec.rb +19 -20
- data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +7 -7
- data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +7 -7
- data/spec/views/spotlight/catalog/edit.html.erb_spec.rb +3 -6
- data/spec/views/spotlight/catalog/new.html.erb_spec.rb +8 -10
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +8 -8
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +22 -22
- data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +7 -8
- data/spec/views/spotlight/feature_pages/_empty.html.erb_spec.rb +5 -5
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +24 -26
- data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +13 -9
- data/spec/views/spotlight/home_pages/_sidebar.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +26 -0
- data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +22 -0
- data/spec/views/spotlight/pages/edit.html.erb_spec.rb +16 -16
- data/spec/views/spotlight/pages/index.html.erb_spec.rb +19 -17
- data/spec/views/spotlight/pages/new.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/pages/show.html.erb_spec.rb +27 -28
- data/spec/views/spotlight/roles/index.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +54 -0
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +28 -0
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +20 -10
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +12 -11
- data/spec/views/spotlight/searches/index.html.erb_spec.rb +12 -7
- data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +7 -8
- data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +4 -4
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +38 -0
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +7 -8
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +18 -13
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +14 -12
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +11 -12
- data/spec/views/spotlight/tags/index.html.erb_spec.rb +9 -9
- metadata +167 -83
- data/app/controllers/spotlight/blacklight_configurations_controller.rb +0 -101
- data/app/controllers/spotlight/resources/csv_controller.rb +0 -23
- data/app/forms/spotlight/appearance.rb +0 -86
- data/app/helpers/spotlight/attachments_helper.rb +0 -4
- data/app/helpers/spotlight/blacklight_configurations_helper.rb +0 -15
- data/app/jobs/spotlight/set_default_thumbnail_job.rb +0 -16
- data/app/models/spotlight/resources/csv.rb +0 -80
- data/app/uploaders/spotlight/csv_uploader.rb +0 -15
- data/app/views/spotlight/blacklight_configurations/edit_facet_fields.html.erb +0 -47
- data/app/views/spotlight/blacklight_configurations/edit_sort_fields.html.erb +0 -65
- data/app/views/spotlight/resources/csv/_form.html.erb +0 -17
- data/app/views/spotlight/resources/csv/new.html.erb +0 -3
- data/spec/controllers/spotlight/blacklight_configurations_controller_spec.rb +0 -167
- data/spec/features/edit_sort_fields_spec.rb +0 -42
- data/spec/features/exhibits/edit_facet_fields_spec.rb +0 -37
- data/spec/features/javascript/facet_admin_spec.rb +0 -36
- data/spec/features/search_facets_admin_spec.rb +0 -19
- data/spec/features/update_appearance_spec.rb +0 -58
- data/spec/helpers/spotlight/blacklight_configurations_helper_spec.rb +0 -12
- data/spec/models/spotlight/appearance_spec.rb +0 -33
- data/spec/models/spotlight/resources/csv_spec.rb +0 -101
- data/spec/models/spotlight/solr_document_atomic_updates_spec.rb +0 -29
- data/spec/models/spotlight/solr_document_uploaded_resource_spec.rb +0 -45
- data/spec/uploaders/item_uploader_spec.rb +0 -62
- data/spec/views/spotlight/blacklight_configuration/_metadata_field.html.erb_spec.rb +0 -27
- data/spec/views/spotlight/blacklight_configuration/edit_metadata_fields.html.erb_spec.rb +0 -23
- data/spec/views/spotlight/blacklight_configuration/edit_sort_fields.html.erb_spec.rb +0 -19
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe SolrDocument, :
|
3
|
+
describe SolrDocument, type: :model do
|
4
4
|
subject { ::SolrDocument.new(id: 'abcd123') }
|
5
|
-
its(:to_key) {should == ['abcd123']}
|
6
|
-
its(:persisted?) {should be_truthy}
|
5
|
+
its(:to_key) { should == ['abcd123'] }
|
6
|
+
its(:persisted?) { should be_truthy }
|
7
7
|
before do
|
8
8
|
allow(subject).to receive_messages(reindex: nil)
|
9
9
|
end
|
@@ -11,119 +11,119 @@ describe SolrDocument, :type => :model do
|
|
11
11
|
let(:exhibit) { FactoryGirl.create(:exhibit) }
|
12
12
|
let(:exhibit_alt) { FactoryGirl.create(:exhibit) }
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'has tags on the exhibit' do
|
15
15
|
expect(subject.tags_from(exhibit)).to be_empty
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
19
|
-
expect
|
20
|
-
exhibit.tag(subject, with:
|
21
|
-
|
22
|
-
expect(subject.tags_from(exhibit)).to eq
|
18
|
+
it 'is able to add tags' do
|
19
|
+
expect do
|
20
|
+
exhibit.tag(subject, with: 'paris, normandy', on: :tags)
|
21
|
+
end.to change { ActsAsTaggableOn::Tag.count }.by(2)
|
22
|
+
expect(subject.tags_from(exhibit)).to eq %w(paris normandy)
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
expect(::SolrDocument.find('dq287tq6352')).to be_kind_of
|
25
|
+
it 'has find' do
|
26
|
+
expect(::SolrDocument.find('dq287tq6352')).to be_kind_of described_class
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'has ==' do
|
30
30
|
expect(::SolrDocument.find('dq287tq6352')).to eq ::SolrDocument.find('dq287tq6352')
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'GlobalID' do
|
34
34
|
let(:doc_id) { 'dq287tq6352' }
|
35
|
-
it '
|
35
|
+
it 'responds to #to_global_id' do
|
36
36
|
expect(::SolrDocument.find(doc_id).to_global_id.to_s).to eq "gid://internal/SolrDocument/#{doc_id}"
|
37
37
|
end
|
38
|
-
it '
|
38
|
+
it 'is able to locate SolrDocuments by their GlobalID' do
|
39
39
|
expect(GlobalID::Locator.locate(
|
40
40
|
::SolrDocument.find(doc_id).to_global_id
|
41
41
|
)['id']).to eq doc_id
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
46
|
-
it
|
45
|
+
describe '#sidecar' do
|
46
|
+
it 'returns a sidecar for adding exhibit-specific fields' do
|
47
47
|
expect(subject.sidecar(exhibit)).to be_kind_of Spotlight::SolrDocumentSidecar
|
48
48
|
expect(subject.sidecar(exhibit).exhibit).to eq exhibit
|
49
49
|
end
|
50
|
-
|
51
|
-
it
|
50
|
+
|
51
|
+
it 'keeps distinct sidecars for each exhibit' do
|
52
52
|
expect(subject.sidecar(exhibit).exhibit).to eq exhibit
|
53
53
|
expect(subject.sidecar(exhibit_alt).exhibit).to eq exhibit_alt
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe
|
58
|
-
it
|
57
|
+
describe '#update' do
|
58
|
+
it 'stores sidecar data on the sidecar object' do
|
59
59
|
mock_sidecar = double
|
60
60
|
allow(subject).to receive_messages(sidecar: mock_sidecar)
|
61
61
|
expect(mock_sidecar).to receive(:update).with(data: { 'a' => 1 })
|
62
|
-
subject.update exhibit, sidecar: { data: { 'a' => 1 }}
|
62
|
+
subject.update exhibit, sidecar: { data: { 'a' => 1 } }
|
63
63
|
end
|
64
|
-
it
|
65
|
-
subject.update exhibit, exhibit_tag_list:
|
66
|
-
expect(subject.tags_from(exhibit)).to eq
|
64
|
+
it 'stores tags' do
|
65
|
+
subject.update exhibit, exhibit_tag_list: 'paris, normandy'
|
66
|
+
expect(subject.tags_from(exhibit)).to eq %w(paris normandy)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
70
|
+
describe '#to_solr' do
|
71
71
|
before do
|
72
72
|
Spotlight::SolrDocumentSidecar.create! document: subject, exhibit: exhibit,
|
73
|
-
|
73
|
+
data: { 'a_tesim' => 1, 'b_tesim' => 2, 'c_tesim' => 3 }
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
77
|
-
expect(subject.to_solr[:id]).to eq 'abcd123'
|
76
|
+
it 'includes the doc id' do
|
77
|
+
expect(subject.to_solr[:id]).to eq 'abcd123'
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
80
|
+
it 'includes exhibit-specific tags' do
|
81
81
|
exhibit.tag(subject, with: 'paris', on: :tags)
|
82
82
|
|
83
83
|
expect(subject.to_solr).to include :exhibit_1_tags_ssim
|
84
84
|
expect(subject.to_solr[:exhibit_1_tags_ssim]).to include 'paris'
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
87
|
+
it "includes placeholders for all exhibits' tags" do
|
88
88
|
expect(subject.to_solr).to include :exhibit_1_tags_ssim
|
89
89
|
expect(subject.to_solr[:exhibit_1_tags_ssim]).to eq nil
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
92
|
+
it 'includes sidecar fields' do
|
93
93
|
expect(subject.to_solr).to include('a_tesim' => 1, 'b_tesim' => 2, 'c_tesim' => 3)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
describe
|
98
|
-
it
|
97
|
+
describe '#public?' do
|
98
|
+
it 'defaults to public' do
|
99
99
|
expect(subject).to be_public exhibit
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
104
|
-
it
|
103
|
+
describe '#private?' do
|
104
|
+
it 'defaults to public' do
|
105
105
|
expect(subject).not_to be_private exhibit
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
describe
|
110
|
-
it
|
109
|
+
describe '#make_public!' do
|
110
|
+
it 'sets the object to public' do
|
111
111
|
allow(subject).to receive(:reindex)
|
112
112
|
subject.make_public! exhibit
|
113
113
|
expect(subject).not_to be_private exhibit
|
114
114
|
end
|
115
115
|
|
116
|
-
it
|
116
|
+
it 'augments existing sidecar data' do
|
117
117
|
allow(subject).to receive(:reindex)
|
118
118
|
|
119
|
-
subject.update exhibit, sidecar: { data: { a: 1}}
|
119
|
+
subject.update exhibit, sidecar: { data: { a: 1 } }
|
120
120
|
subject.make_public! exhibit
|
121
121
|
expect(subject.sidecar(exhibit).data[:a]).to eq 1
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
describe
|
126
|
-
it
|
125
|
+
describe '#make_private!' do
|
126
|
+
it 'sets the object to private' do
|
127
127
|
allow(subject).to receive(:reindex)
|
128
128
|
subject.make_private! exhibit
|
129
129
|
expect(subject).to be_private exhibit
|
@@ -131,25 +131,24 @@ describe SolrDocument, :type => :model do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
describe 'uploaded resources' do
|
134
|
-
let(:uploaded_resource)
|
135
|
-
|
136
|
-
spotlight_resource_type_ssim:
|
134
|
+
let(:uploaded_resource) do
|
135
|
+
described_class.new(
|
136
|
+
spotlight_resource_type_ssim: 'spotlight/resources/uploads'
|
137
137
|
)
|
138
|
-
|
139
|
-
it '
|
138
|
+
end
|
139
|
+
it 'does not include Spotlight::SolrDocument::UploadedResource when the correct fields are present' do
|
140
140
|
expect(subject).to_not be_kind_of Spotlight::SolrDocument::UploadedResource
|
141
141
|
end
|
142
|
-
it '
|
142
|
+
it 'includes Spotlight::SolrDocument::UploadedResource when the correct fields are present' do
|
143
143
|
expect(uploaded_resource).to be_kind_of Spotlight::SolrDocument::UploadedResource
|
144
144
|
end
|
145
145
|
describe '#uploaded_resource?' do
|
146
|
-
it '
|
146
|
+
it 'returns false if the correct fields are not present' do
|
147
147
|
expect(subject).to_not be_uploaded_resource
|
148
148
|
end
|
149
|
-
it '
|
149
|
+
it 'returns true when the correct fields are present' do
|
150
150
|
expect(uploaded_resource).to be_uploaded_resource
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
154
|
-
|
155
154
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'cancan/matchers'
|
3
3
|
|
4
|
-
describe Spotlight::Ability, :
|
4
|
+
describe Spotlight::Ability, type: :model do
|
5
5
|
before do
|
6
|
-
allow_any_instance_of(Spotlight::Search).to receive(:
|
6
|
+
allow_any_instance_of(Spotlight::Search).to receive(:set_default_featured_image)
|
7
7
|
end
|
8
8
|
let(:exhibit) { FactoryGirl.create(:exhibit) }
|
9
|
-
let(:search) {FactoryGirl.create(:published_search, exhibit: exhibit)}
|
10
|
-
let(:unpublished_search) {FactoryGirl.create(:search, exhibit: exhibit)}
|
11
|
-
let(:page) {FactoryGirl.create(:feature_page, exhibit: exhibit)}
|
9
|
+
let(:search) { FactoryGirl.create(:published_search, exhibit: exhibit) }
|
10
|
+
let(:unpublished_search) { FactoryGirl.create(:search, exhibit: exhibit) }
|
11
|
+
let(:page) { FactoryGirl.create(:feature_page, exhibit: exhibit) }
|
12
12
|
subject { Ability.new(user) }
|
13
13
|
|
14
|
-
describe
|
14
|
+
describe 'a user with no roles' do
|
15
15
|
let(:user) { nil }
|
16
16
|
it { is_expected.not_to be_able_to(:create, exhibit) }
|
17
17
|
it { is_expected.to be_able_to(:read, exhibit) }
|
@@ -22,33 +22,31 @@ describe Spotlight::Ability, :type => :model do
|
|
22
22
|
it { is_expected.not_to be_able_to(:tag, exhibit) }
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe 'a superadmin' do
|
26
26
|
let(:user) { FactoryGirl.create(:site_admin) }
|
27
27
|
|
28
|
-
it { is_expected.to be_able_to(:create,
|
29
|
-
|
28
|
+
it { is_expected.to be_able_to(:create, Spotlight::Exhibit) }
|
30
29
|
end
|
31
30
|
|
32
|
-
describe
|
31
|
+
describe 'a user with admin role' do
|
33
32
|
let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
|
34
33
|
let(:role) { FactoryGirl.create(:role, exhibit: exhibit) }
|
35
34
|
|
36
35
|
it { is_expected.to be_able_to(:update, exhibit) }
|
37
36
|
|
38
|
-
it { is_expected.to be_able_to(:index,
|
37
|
+
it { is_expected.to be_able_to(:index, role) }
|
39
38
|
it { is_expected.to be_able_to(:destroy, role) }
|
40
|
-
it { is_expected.to be_able_to(:update,
|
41
|
-
it { is_expected.to be_able_to(:create,
|
42
|
-
it { is_expected.not_to be_able_to(:create,
|
43
|
-
it { is_expected.to be_able_to(:import,
|
44
|
-
it { is_expected.to be_able_to(:process_import,
|
45
|
-
it { is_expected.to be_able_to(:destroy,
|
39
|
+
it { is_expected.to be_able_to(:update, role) }
|
40
|
+
it { is_expected.to be_able_to(:create, Spotlight::Role) }
|
41
|
+
it { is_expected.not_to be_able_to(:create, Spotlight::Exhibit) }
|
42
|
+
it { is_expected.to be_able_to(:import, exhibit) }
|
43
|
+
it { is_expected.to be_able_to(:process_import, exhibit) }
|
44
|
+
it { is_expected.to be_able_to(:destroy, exhibit) }
|
46
45
|
|
47
46
|
let(:blacklight_config) { role.exhibit.blacklight_configuration }
|
48
|
-
it { is_expected.to be_able_to(:edit, Spotlight::Appearance.new(blacklight_config)) }
|
49
47
|
end
|
50
48
|
|
51
|
-
describe
|
49
|
+
describe 'a user with curate role' do
|
52
50
|
let(:user) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
|
53
51
|
|
54
52
|
it { is_expected.not_to be_able_to(:update, exhibit) }
|
@@ -76,6 +74,5 @@ describe Spotlight::Ability, :type => :model do
|
|
76
74
|
|
77
75
|
let(:role) { FactoryGirl.create(:role, exhibit: user.roles.first.exhibit) }
|
78
76
|
let(:blacklight_config) { role.exhibit.blacklight_configuration }
|
79
|
-
it { is_expected.not_to be_able_to(:edit, Spotlight::Appearance.new(blacklight_config)) }
|
80
77
|
end
|
81
78
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Spotlight::AboutPage, :
|
4
|
-
let(:page) {
|
5
|
-
it {is_expected.not_to be_feature_page}
|
6
|
-
it {is_expected.to be_about_page}
|
7
|
-
it
|
3
|
+
describe Spotlight::AboutPage, type: :model do
|
4
|
+
let(:page) { described_class.create! exhibit: FactoryGirl.create(:exhibit) }
|
5
|
+
it { is_expected.not_to be_feature_page }
|
6
|
+
it { is_expected.to be_about_page }
|
7
|
+
it 'displays the sidebar' do
|
8
8
|
expect(page.display_sidebar?).to be_truthy
|
9
9
|
end
|
10
|
-
it
|
10
|
+
it 'forces the sidebar to display (we do not provide an interface for setting this to false)' do
|
11
11
|
expect(page.display_sidebar?).to be_truthy
|
12
12
|
page.display_sidebar = false
|
13
13
|
page.save
|
@@ -1,46 +1,46 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Spotlight::BlacklightConfiguration, :
|
4
|
-
subject {
|
3
|
+
describe Spotlight::BlacklightConfiguration, type: :model do
|
4
|
+
subject { described_class.new }
|
5
5
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
6
6
|
|
7
7
|
before :each do
|
8
8
|
blacklight_config.configure do |config|
|
9
|
-
config.add_sort_field 'relevance', sort: 'score desc, sort_title_ssi asc', :
|
10
|
-
config.add_sort_field 'title', sort: 'sort_title_ssi asc', :
|
11
|
-
config.add_sort_field 'type', sort: 'sort_type_ssi asc', :
|
12
|
-
config.add_sort_field 'date', sort: 'sort_date_dtsi asc', :
|
13
|
-
config.add_sort_field 'source', sort: 'sort_source_ssi asc', :
|
14
|
-
config.add_sort_field 'identifier', sort: 'id asc', :
|
9
|
+
config.add_sort_field 'relevance', sort: 'score desc, sort_title_ssi asc', label: 'Relevance'
|
10
|
+
config.add_sort_field 'title', sort: 'sort_title_ssi asc', label: 'Title'
|
11
|
+
config.add_sort_field 'type', sort: 'sort_type_ssi asc', label: 'Type'
|
12
|
+
config.add_sort_field 'date', sort: 'sort_date_dtsi asc', label: 'Date'
|
13
|
+
config.add_sort_field 'source', sort: 'sort_source_ssi asc', label: 'Source'
|
14
|
+
config.add_sort_field 'identifier', sort: 'id asc', label: 'Identifier'
|
15
15
|
end
|
16
16
|
allow(subject).to receive_messages default_blacklight_config: blacklight_config
|
17
17
|
subject.exhibit = FactoryGirl.create(:exhibit)
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'touches the exhibit' do
|
21
21
|
expect(subject.exhibit).to receive :touch
|
22
22
|
subject.save!
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it 'adds a default thumbnail field' do
|
26
26
|
expect(subject.blacklight_config.index.thumbnail_field).to eq Spotlight::Engine.config.thumbnail_field
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
30
|
-
it
|
29
|
+
describe 'facet fields' do
|
30
|
+
it 'has facet fields' do
|
31
31
|
expect(subject.facet_fields).to be_empty
|
32
|
-
subject.facet_fields[
|
33
|
-
subject.facet_fields[
|
34
|
-
expect(subject.facet_fields.keys).to eq
|
32
|
+
subject.facet_fields['title_facet'] = {}
|
33
|
+
subject.facet_fields['author_facet'] = {}
|
34
|
+
expect(subject.facet_fields.keys).to eq %w(title_facet author_facet)
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
38
|
-
subject.facet_fields[
|
37
|
+
it 'filters blank values' do
|
38
|
+
subject.facet_fields['title_facet'] = { something: '' }
|
39
39
|
subject.valid?
|
40
|
-
expect(subject.facet_fields[
|
40
|
+
expect(subject.facet_fields['title_facet'].keys).to_not include :something
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
43
|
+
it 'filters the upstream blacklight config' do
|
44
44
|
subject.facet_fields['a'] = { show: true }
|
45
45
|
subject.facet_fields['b'] = { show: false }
|
46
46
|
subject.facet_fields['d'] = { show: true }
|
@@ -56,8 +56,7 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
56
56
|
expect(subject.blacklight_config.facet_fields['d']).to be_nil
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
|
59
|
+
it 'orders the fields by weight' do
|
61
60
|
subject.facet_fields['a'] = { show: true, weight: 3 }
|
62
61
|
subject.facet_fields['b'] = { show: true, weight: 5 }
|
63
62
|
subject.facet_fields['c'] = { show: true, weight: 1 }
|
@@ -66,45 +65,43 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
66
65
|
blacklight_config.add_facet_field 'b'
|
67
66
|
blacklight_config.add_facet_field 'c'
|
68
67
|
|
69
|
-
expect(subject.blacklight_config.facet_fields.keys).to eq
|
68
|
+
expect(subject.blacklight_config.facet_fields.keys).to eq %w(c a b)
|
70
69
|
end
|
71
70
|
|
72
|
-
context
|
73
|
-
it
|
71
|
+
context 'custom fields' do
|
72
|
+
it 'includes any custom fields' do
|
74
73
|
allow(subject).to receive_messages(custom_facet_fields: { 'a' => double(if: nil, :if= => true, merge!: true, validate!: true, normalize!: true) })
|
75
74
|
expect(subject.blacklight_config.facet_fields).to include('a')
|
76
75
|
end
|
77
76
|
|
78
|
-
it
|
77
|
+
it 'defaults to not showing a custom field in the facets' do
|
79
78
|
allow(subject).to receive_messages(custom_facet_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a') })
|
80
79
|
expect(subject.blacklight_config.facet_fields).to include('a')
|
81
80
|
expect(subject.blacklight_config.facet_fields['a'].show).to be_falsey
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
85
|
-
context
|
84
|
+
context 'exhibit fields' do
|
86
85
|
before do
|
87
86
|
# undo the stubbing we've used elsewhere..
|
88
87
|
allow(subject).to receive(:default_blacklight_config).and_call_original
|
89
88
|
allow(Spotlight::Engine).to receive_messages blacklight_config: blacklight_config
|
90
89
|
end
|
91
|
-
it
|
92
|
-
expect(subject.blacklight_config.facet_fields).to include
|
90
|
+
it 'injects a tags facet' do
|
91
|
+
expect(subject.blacklight_config.facet_fields).to include 'exhibit_tags'
|
93
92
|
end
|
94
93
|
end
|
95
94
|
end
|
96
95
|
|
97
|
-
describe
|
98
|
-
|
99
|
-
it "should have index fields" do
|
96
|
+
describe 'index fields' do
|
97
|
+
it 'has index fields' do
|
100
98
|
expect(subject.index_fields).to be_empty
|
101
99
|
subject.index_fields['title'] = {}
|
102
100
|
subject.index_fields['author'] = {}
|
103
|
-
expect(subject.index_fields.keys).to eq
|
101
|
+
expect(subject.index_fields.keys).to eq %w(title author)
|
104
102
|
end
|
105
103
|
|
106
|
-
it
|
107
|
-
|
104
|
+
it 'defaults to displaying all index fields if no exhibit-specific configuration is set' do
|
108
105
|
blacklight_config.add_index_field 'a'
|
109
106
|
blacklight_config.add_index_field 'b'
|
110
107
|
blacklight_config.add_index_field 'c'
|
@@ -117,18 +114,18 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
117
114
|
expect(subject.blacklight_config.index_fields['c'].list).to be_truthy
|
118
115
|
end
|
119
116
|
|
120
|
-
it
|
117
|
+
it 'filters upstream fields that are always disabled' do
|
121
118
|
blacklight_config.add_index_field 'a', if: false
|
122
119
|
expect(subject.blacklight_config.index_fields).not_to have_key 'a'
|
123
120
|
end
|
124
121
|
|
125
|
-
it
|
126
|
-
subject.index_fields['title'] = { something:
|
122
|
+
it 'filters blank values' do
|
123
|
+
subject.index_fields['title'] = { something: '' }
|
127
124
|
subject.valid?
|
128
|
-
expect(subject.index_fields[
|
125
|
+
expect(subject.index_fields['title'].keys).to_not include :something
|
129
126
|
end
|
130
127
|
|
131
|
-
it
|
128
|
+
it 'filters the upstream blacklight config' do
|
132
129
|
subject.index_fields['a'] = { enabled: true, list: true }
|
133
130
|
subject.index_fields['c'] = { enabled: false, list: false }
|
134
131
|
subject.index_fields['d'] = { enabled: true, list: true }
|
@@ -144,20 +141,20 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
144
141
|
expect(subject.blacklight_config.index_fields['d']).to be_nil
|
145
142
|
end
|
146
143
|
|
147
|
-
it
|
144
|
+
it 'includes configured show fields, but disable them for index views' do
|
148
145
|
blacklight_config.add_show_field 'a'
|
149
146
|
expect(subject.blacklight_config.index_fields).to have_key 'a'
|
150
147
|
expect(subject.blacklight_config.index_fields['a'].enabled).to be_truthy
|
151
148
|
expect(subject.blacklight_config.index_fields['a'].show).to be_truthy
|
152
149
|
expect(subject.blacklight_config.index_fields['a'].list).to be_falsey
|
153
150
|
end
|
154
|
-
|
155
|
-
it
|
151
|
+
|
152
|
+
it 'filters show fields that are always disabled' do
|
156
153
|
blacklight_config.add_show_field 'a', if: false
|
157
154
|
expect(subject.blacklight_config.index_fields).not_to have_key 'a'
|
158
155
|
end
|
159
156
|
|
160
|
-
it
|
157
|
+
it 'includes persisted configurations for show fields' do
|
161
158
|
subject.index_fields['a'] = { enabled: true, list: true }
|
162
159
|
blacklight_config.add_show_field 'a'
|
163
160
|
expect(subject.blacklight_config.index_fields).to have_key 'a'
|
@@ -165,21 +162,21 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
165
162
|
expect(subject.blacklight_config.index_fields['a'].list).to be_truthy
|
166
163
|
end
|
167
164
|
|
168
|
-
context
|
169
|
-
it
|
165
|
+
context 'custom fields' do
|
166
|
+
it 'includes any custom fields' do
|
170
167
|
subject.index_fields['a'] = { enabled: true, list: true }
|
171
168
|
allow(subject).to receive_messages(custom_index_fields: { 'a' => double(if: nil, :if= => true, merge!: true, validate!: true, normalize!: true) })
|
172
169
|
expect(subject.blacklight_config.index_fields).to include('a')
|
173
170
|
end
|
174
171
|
|
175
|
-
it
|
172
|
+
it 'defaults to showing a custom field on the show view' do
|
176
173
|
allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a') })
|
177
174
|
expect(subject.blacklight_config.index_fields).to include('a')
|
178
175
|
expect(subject.blacklight_config.index_fields['a'].show).to be_truthy
|
179
176
|
expect(subject.blacklight_config.index_fields['a'].enabled).to be_truthy
|
180
177
|
end
|
181
178
|
|
182
|
-
it
|
179
|
+
it 'uses explicit configuration to override custom field defaults' do
|
183
180
|
subject.index_fields['a'] = { show: false }
|
184
181
|
allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a') })
|
185
182
|
expect(subject.blacklight_config.index_fields).to include('a')
|
@@ -187,13 +184,13 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
187
184
|
end
|
188
185
|
end
|
189
186
|
|
190
|
-
it
|
187
|
+
it 'prefers the label stored in index fields' do
|
191
188
|
subject.index_fields['a'] = { enabled: true, list: true, label: 'updated val' }
|
192
|
-
allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(:
|
189
|
+
allow(subject).to receive_messages(custom_index_fields: { 'a' => Blacklight::Configuration::IndexField.new(field: 'a', label: 'Initial value') })
|
193
190
|
expect(subject.blacklight_config.index_fields['a'].label).to eq 'updated val'
|
194
191
|
end
|
195
192
|
|
196
|
-
it
|
193
|
+
it 'filters the upstream blacklight config with respect for view types' do
|
197
194
|
subject.index_fields['a'] = { enabled: true, list: true, gallery: false }
|
198
195
|
subject.index_fields['b'] = { enabled: true, list: false, gallery: true }
|
199
196
|
subject.index_fields['c'] = { enabled: false, list: true, gallery: false }
|
@@ -205,16 +202,16 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
205
202
|
blacklight_config.add_index_field 'c'
|
206
203
|
blacklight_config.add_index_field 'd'
|
207
204
|
|
208
|
-
expect(subject.blacklight_config.index_fields.select { |
|
209
|
-
expect(subject.blacklight_config.index_fields.select { |
|
210
|
-
expect(subject.blacklight_config.index_fields.select { |
|
211
|
-
expect(subject.blacklight_config.index_fields.select { |
|
212
|
-
expect(subject.blacklight_config.index_fields.select { |
|
213
|
-
expect(subject.blacklight_config.index_fields.select { |
|
214
|
-
expect(subject.blacklight_config.index_fields.select { |
|
205
|
+
expect(subject.blacklight_config.index_fields.select { |_k, x| x.list }).to include('a')
|
206
|
+
expect(subject.blacklight_config.index_fields.select { |_k, x| x.gallery }).to include('b', 'd')
|
207
|
+
expect(subject.blacklight_config.index_fields.select { |_k, x| x.list }).to_not include('b', 'd')
|
208
|
+
expect(subject.blacklight_config.index_fields.select { |_k, x| x.gallery }).to_not include('a', 'c')
|
209
|
+
expect(subject.blacklight_config.index_fields.select { |_k, x| x.list }).to have(2).fields
|
210
|
+
expect(subject.blacklight_config.index_fields.select { |_k, x| x.list && x.enabled }).to have(1).fields
|
211
|
+
expect(subject.blacklight_config.index_fields.select { |_k, x| x.gallery }).to have(2).fields
|
215
212
|
end
|
216
213
|
|
217
|
-
it
|
214
|
+
it 'filters the upstream blacklight config for show fields' do
|
218
215
|
subject.index_fields['a'] = { enabled: true, show: true }
|
219
216
|
subject.index_fields['c'] = { enabled: false, show: false }
|
220
217
|
subject.index_fields['d'] = { enabled: true, show: false }
|
@@ -223,12 +220,12 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
223
220
|
blacklight_config.add_index_field 'b'
|
224
221
|
blacklight_config.add_index_field 'c'
|
225
222
|
|
226
|
-
expect(subject.blacklight_config.show_fields.select { |
|
227
|
-
expect(subject.blacklight_config.show_fields.select { |
|
228
|
-
expect(subject.blacklight_config.show_fields.select { |
|
223
|
+
expect(subject.blacklight_config.show_fields.select { |_k, x| x.show && x.enabled }).to include('a')
|
224
|
+
expect(subject.blacklight_config.show_fields.select { |_k, x| x.show && x.enabled }).to_not include('b', 'd')
|
225
|
+
expect(subject.blacklight_config.show_fields.select { |_k, x| x.show && x.enabled }).to have(1).fields
|
229
226
|
end
|
230
227
|
|
231
|
-
it
|
228
|
+
it 'includes any custom fields' do
|
232
229
|
subject.index_fields['a'] = { enabled: true, show: true }
|
233
230
|
|
234
231
|
allow(subject).to receive_messages(custom_index_fields: { 'a' => double(if: nil, :if= => true, merge!: true, validate!: true, normalize!: true) })
|
@@ -236,8 +233,7 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
236
233
|
expect(subject.blacklight_config.show_fields).to include('a')
|
237
234
|
end
|
238
235
|
|
239
|
-
it
|
240
|
-
|
236
|
+
it 'orders the fields by weight' do
|
241
237
|
subject.index_fields['a'] = { enabled: true, weight: 3, list: true }
|
242
238
|
subject.index_fields['b'] = { enabled: true, weight: 5, list: true }
|
243
239
|
subject.index_fields['c'] = { enabled: true, weight: 1, list: true }
|
@@ -246,11 +242,10 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
246
242
|
blacklight_config.add_index_field 'b'
|
247
243
|
blacklight_config.add_index_field 'c'
|
248
244
|
|
249
|
-
expect(subject.blacklight_config.index_fields.keys).to eq
|
245
|
+
expect(subject.blacklight_config.index_fields.keys).to eq %w(c a b)
|
250
246
|
end
|
251
247
|
|
252
|
-
it
|
253
|
-
|
248
|
+
it 'orders the fields by weight' do
|
254
249
|
subject.index_fields['a'] = { enabled: true, weight: 3, show: true }
|
255
250
|
subject.index_fields['b'] = { enabled: true, weight: 5, show: true }
|
256
251
|
subject.index_fields['c'] = { enabled: true, weight: 1, show: true }
|
@@ -259,43 +254,48 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
259
254
|
blacklight_config.add_index_field 'b'
|
260
255
|
blacklight_config.add_index_field 'c'
|
261
256
|
|
262
|
-
expect(subject.blacklight_config.show_fields.keys).to eq
|
257
|
+
expect(subject.blacklight_config.show_fields.keys).to eq %w(c a b)
|
263
258
|
end
|
264
259
|
end
|
265
260
|
|
266
|
-
describe
|
261
|
+
describe 'a newly created instance' do
|
267
262
|
before do
|
268
263
|
subject.save!
|
269
264
|
end
|
270
|
-
describe
|
271
|
-
its(:sort_fields)
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
265
|
+
describe 'should have default values' do
|
266
|
+
its(:sort_fields) do
|
267
|
+
should eq('identifier' => { enabled: true },
|
268
|
+
'relevance' => { enabled: true },
|
269
|
+
'date' => { enabled: true },
|
270
|
+
'source' => { enabled: true },
|
271
|
+
'title' => { enabled: true },
|
272
|
+
'type' => { enabled: true })
|
273
|
+
end
|
274
|
+
its(:search_fields) do
|
275
|
+
should eq('all_fields' => { enabled: true },
|
276
|
+
'title' => { enabled: true },
|
277
|
+
'author' => { enabled: true })
|
278
|
+
end
|
279
279
|
its(:default_per_page) { should eq 10 }
|
280
|
-
its(:document_index_view_types) { should match_array ::CatalogController.blacklight_config.view.keys.map
|
280
|
+
its(:document_index_view_types) { should match_array ::CatalogController.blacklight_config.view.keys.map(&:to_s) }
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
284
|
-
describe
|
285
|
-
it
|
284
|
+
describe 'sort fields' do
|
285
|
+
it 'has sort fields' do
|
286
286
|
expect(subject.sort_fields).to be_empty
|
287
287
|
subject.sort_fields['title'] = {}
|
288
288
|
subject.sort_fields['author'] = {}
|
289
|
-
expect(subject.sort_fields.keys).to eq
|
289
|
+
expect(subject.sort_fields.keys).to eq %w(title author)
|
290
290
|
end
|
291
291
|
|
292
|
-
it
|
293
|
-
subject.sort_fields['title'] = { something:
|
292
|
+
it 'filters blank values' do
|
293
|
+
subject.sort_fields['title'] = { something: '' }
|
294
294
|
subject.valid?
|
295
295
|
expect(subject.sort_fields['title'].keys).to_not include :something
|
296
296
|
end
|
297
297
|
|
298
|
-
it
|
298
|
+
it 'filters the upstream blacklight config' do
|
299
299
|
subject.sort_fields['a'] = { enabled: true }
|
300
300
|
subject.sort_fields['c'] = { enabled: true }
|
301
301
|
subject.sort_fields['d'] = { enabled: true }
|
@@ -304,118 +304,145 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
304
304
|
blacklight_config.add_sort_field 'b'
|
305
305
|
blacklight_config.add_sort_field 'c'
|
306
306
|
|
307
|
-
expect(subject.blacklight_config.sort_fields.select { |
|
308
|
-
expect(subject.blacklight_config.sort_fields.select { |
|
307
|
+
expect(subject.blacklight_config.sort_fields.select { |_k, v| v.enabled == true }).to include('a', 'c')
|
308
|
+
expect(subject.blacklight_config.sort_fields.select { |_k, v| v.enabled == true }).not_to include('b', 'd')
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
describe 'search fields' do
|
313
|
+
it 'has search fields' do
|
314
|
+
expect(subject.search_fields).to be_empty
|
315
|
+
subject.search_fields['title'] = {}
|
316
|
+
subject.search_fields['author'] = {}
|
317
|
+
expect(subject.search_fields.keys).to eq %w(title author)
|
318
|
+
end
|
319
|
+
|
320
|
+
it 'filters blank values' do
|
321
|
+
subject.search_fields['title'] = { something: '' }
|
322
|
+
subject.valid?
|
323
|
+
expect(subject.search_fields['title'].keys).to_not include :something
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'filters the upstream blacklight config' do
|
327
|
+
subject.search_fields['a'] = { enabled: true }
|
328
|
+
subject.search_fields['c'] = { enabled: true }
|
329
|
+
subject.search_fields['d'] = { enabled: true }
|
330
|
+
|
331
|
+
blacklight_config.add_search_field 'a'
|
332
|
+
blacklight_config.add_search_field 'b'
|
333
|
+
blacklight_config.add_search_field 'c'
|
334
|
+
|
335
|
+
expect(subject.blacklight_config.search_fields.select { |_k, v| v.enabled == true }).to include('a', 'c')
|
336
|
+
expect(subject.blacklight_config.search_fields.select { |_k, v| v.enabled == true }).not_to include('b', 'd')
|
309
337
|
end
|
310
338
|
end
|
311
339
|
|
312
|
-
describe
|
313
|
-
it
|
340
|
+
describe 'per page' do
|
341
|
+
it 'has per page configuration' do
|
314
342
|
expect(subject.per_page).to be_empty
|
315
343
|
subject.per_page << 10 << 50
|
316
344
|
expect(subject.per_page).to eq [10, 50]
|
317
345
|
end
|
318
346
|
|
319
|
-
it
|
320
|
-
subject.per_page <<
|
347
|
+
it 'filters blank values' do
|
348
|
+
subject.per_page << ''
|
321
349
|
subject.valid?
|
322
|
-
expect(subject.per_page).to_not include
|
350
|
+
expect(subject.per_page).to_not include ''
|
323
351
|
end
|
324
352
|
|
325
|
-
it
|
353
|
+
it 'filters the upstream blacklight config' do
|
326
354
|
subject.per_page = [10, 50, 1000]
|
327
355
|
blacklight_config.per_page = [1, 10, 50, 100]
|
328
356
|
|
329
357
|
expect(subject.blacklight_config.per_page).to eq [10, 50]
|
330
358
|
end
|
331
|
-
|
332
|
-
it
|
359
|
+
|
360
|
+
it 'prepends the default per page' do
|
333
361
|
blacklight_config.per_page = [1, 10, 50, 100]
|
334
362
|
subject.default_per_page = 50
|
335
363
|
expect(subject.blacklight_config.per_page.first).to eq 50
|
336
364
|
end
|
337
365
|
end
|
338
366
|
|
339
|
-
describe
|
340
|
-
|
341
|
-
it "should have index view configuration" do
|
367
|
+
describe 'document_index_view_types' do
|
368
|
+
it 'has index view configuration' do
|
342
369
|
expect(subject.document_index_view_types).to be_empty
|
343
370
|
subject.document_index_view_types << 'list' << 'gallery'
|
344
|
-
expect(subject.document_index_view_types).to eq
|
371
|
+
expect(subject.document_index_view_types).to eq %w(list gallery)
|
345
372
|
end
|
346
373
|
|
347
|
-
it
|
348
|
-
subject.document_index_view_types <<
|
374
|
+
it 'filters blank values' do
|
375
|
+
subject.document_index_view_types << ''
|
349
376
|
subject.valid?
|
350
|
-
expect(subject.document_index_view_types).to_not include
|
377
|
+
expect(subject.document_index_view_types).to_not include ''
|
351
378
|
end
|
352
379
|
|
353
|
-
it
|
354
|
-
subject.document_index_view_types =
|
380
|
+
it 'filters the upstream blacklight config' do
|
381
|
+
subject.document_index_view_types = %w(list gallery unknown)
|
355
382
|
blacklight_config.view.list
|
356
383
|
blacklight_config.view.gallery
|
357
384
|
blacklight_config.view.something
|
358
385
|
|
359
386
|
expect(subject.blacklight_config.view.keys).to include :list, :gallery, :something
|
360
|
-
expect(subject.blacklight_config.view.all? { |k,v| v.key == k
|
387
|
+
expect(subject.blacklight_config.view.all? { |k, v| v.key == k && v.if == :enabled_in_spotlight_view_type_configuration? }).to be_truthy
|
361
388
|
end
|
362
389
|
|
363
|
-
it
|
390
|
+
it 'passes through the blacklight configuration when not set' do
|
364
391
|
blacklight_config.view.list
|
365
392
|
blacklight_config.view.gallery
|
366
393
|
blacklight_config.view.something
|
367
|
-
expect(subject.blacklight_config.view.keys).to include
|
394
|
+
expect(subject.blacklight_config.view.keys).to include(*blacklight_config.view.keys)
|
368
395
|
end
|
369
396
|
end
|
370
397
|
|
371
|
-
describe
|
372
|
-
it
|
398
|
+
describe 'default_solr_params' do
|
399
|
+
it 'has default solr params configuration' do
|
373
400
|
expect(subject.default_solr_params).to be_empty
|
374
401
|
subject.default_solr_params[:qt] = 'custom_request_handler'
|
375
402
|
expect(subject.default_solr_params[:qt]).to eq 'custom_request_handler'
|
376
403
|
end
|
377
404
|
|
378
|
-
it
|
379
|
-
blacklight_config.default_solr_params = { :
|
405
|
+
it 'merges with the blacklight config' do
|
406
|
+
blacklight_config.default_solr_params = { qt: 'xyz', rows: 10 }
|
380
407
|
subject.default_solr_params[:qt] = 'abc'
|
381
408
|
expect(subject.blacklight_config.default_solr_params).to include(:qt, :rows)
|
382
409
|
expect(subject.blacklight_config.default_solr_params[:qt]).to eq 'abc'
|
383
410
|
end
|
384
411
|
end
|
385
412
|
|
386
|
-
describe
|
387
|
-
it
|
413
|
+
describe 'show' do
|
414
|
+
it 'has show view configuration' do
|
388
415
|
expect(subject.show).to be_empty
|
389
416
|
subject.show[:key] = 'some value'
|
390
417
|
expect(subject.show[:key]).to eq 'some value'
|
391
418
|
end
|
392
419
|
|
393
|
-
it
|
420
|
+
it 'merges with the blacklight config' do
|
394
421
|
blacklight_config.show.title_field = 'xyz'
|
395
422
|
subject.show[:title_field] = 'abc'
|
396
423
|
expect(subject.blacklight_config.show.title_field).to eq 'abc'
|
397
424
|
end
|
398
425
|
end
|
399
426
|
|
400
|
-
describe
|
401
|
-
it
|
427
|
+
describe 'index' do
|
428
|
+
it 'has index view configuration' do
|
402
429
|
expect(subject.index).to be_empty
|
403
430
|
subject.index[:key] = 'some value'
|
404
431
|
expect(subject.index[:key]).to eq 'some value'
|
405
432
|
end
|
406
433
|
|
407
|
-
it
|
434
|
+
it 'merges with the blacklight config' do
|
408
435
|
blacklight_config.index.title_field = 'xyz'
|
409
436
|
subject.index[:title_field] = 'abc'
|
410
437
|
expect(subject.blacklight_config.index.title_field).to eq 'abc'
|
411
438
|
end
|
412
439
|
end
|
413
440
|
|
414
|
-
describe
|
415
|
-
it
|
441
|
+
describe '#custom_index_fields' do
|
442
|
+
it 'converts exhibit-specific fields to Blacklight configurations' do
|
416
443
|
allow(subject).to receive_messages(exhibit: double(custom_fields: [
|
417
|
-
stub_model(Spotlight::CustomField, field:
|
418
|
-
stub_model(Spotlight::CustomField, field:
|
444
|
+
stub_model(Spotlight::CustomField, field: 'abc', configuration: { a: 1 }),
|
445
|
+
stub_model(Spotlight::CustomField, field: 'xyz', configuration: { x: 2 })
|
419
446
|
]))
|
420
447
|
|
421
448
|
expect(subject.custom_index_fields).to include 'abc', 'xyz'
|
@@ -424,36 +451,72 @@ describe Spotlight::BlacklightConfiguration, :type => :model do
|
|
424
451
|
end
|
425
452
|
end
|
426
453
|
|
427
|
-
describe
|
454
|
+
describe 'autocomplete configuration' do
|
428
455
|
before do
|
429
456
|
# undo the stubbing we've used elsewhere..
|
430
457
|
allow(subject).to receive(:default_blacklight_config).and_call_original
|
431
|
-
blacklight_config.show.title_field =
|
458
|
+
blacklight_config.show.title_field = 'x'
|
432
459
|
allow(Spotlight::Engine).to receive_messages blacklight_config: blacklight_config.deep_copy
|
433
460
|
end
|
434
461
|
|
435
|
-
context
|
462
|
+
context 'with the default search field' do
|
436
463
|
let(:search_field) do
|
437
464
|
subject.blacklight_config.search_fields[Spotlight::Engine.config.autocomplete_search_field]
|
438
465
|
end
|
439
466
|
|
440
|
-
it
|
467
|
+
it 'is hidden from the search field selector' do
|
441
468
|
expect(search_field.if).to eq false
|
442
469
|
end
|
443
470
|
|
444
|
-
it "
|
471
|
+
it "uses the engine's autocomplete parameters" do
|
445
472
|
expect(search_field.solr_parameters).to include Spotlight::Engine.config.default_autocomplete_params
|
446
473
|
end
|
447
474
|
|
448
|
-
it
|
449
|
-
Spotlight::Engine.blacklight_config.show.title_field =
|
475
|
+
it 'includes the relevant fields' do
|
476
|
+
Spotlight::Engine.blacklight_config.show.title_field = 'some_field'
|
450
477
|
expect(search_field.solr_parameters).to have_key :fl
|
451
|
-
expect(search_field.solr_parameters[:fl]).to include
|
452
|
-
expect(search_field.solr_parameters[:fl]).to include
|
453
|
-
expect(search_field.solr_parameters[:fl]).to include
|
454
|
-
expect(search_field.solr_parameters[:fl]).to include
|
455
|
-
expect(search_field.solr_parameters[:fl]).to include
|
478
|
+
expect(search_field.solr_parameters[:fl]).to include 'id'
|
479
|
+
expect(search_field.solr_parameters[:fl]).to include 'some_field'
|
480
|
+
expect(search_field.solr_parameters[:fl]).to include 'full_image_url_ssm'
|
481
|
+
expect(search_field.solr_parameters[:fl]).to include 'thumbnail_url_ssm'
|
482
|
+
expect(search_field.solr_parameters[:fl]).to include 'thumbnail_square_url_ssm'
|
456
483
|
end
|
457
484
|
end
|
458
485
|
end
|
486
|
+
|
487
|
+
describe '#document_index_view_types' do
|
488
|
+
it 'passes arrays through' do
|
489
|
+
array = [1, 2, 3]
|
490
|
+
subject.document_index_view_types = array
|
491
|
+
expect(subject.document_index_view_types).to match_array array
|
492
|
+
end
|
493
|
+
|
494
|
+
it 'is simplified from a hash to an array' do
|
495
|
+
checkboxes_from_form = { 'list' => '1', 'gallery' => '1', 'map' => '0' }
|
496
|
+
subject.document_index_view_types = checkboxes_from_form
|
497
|
+
expect(subject.document_index_view_types).to match_array %w(list gallery)
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
describe '#document_index_view_types_selected_hash' do
|
502
|
+
before do
|
503
|
+
subject.default_blacklight_config.view.list
|
504
|
+
subject.default_blacklight_config.view.gallery
|
505
|
+
subject.default_blacklight_config.view.map
|
506
|
+
subject.default_blacklight_config.view.rss.if = false
|
507
|
+
subject.document_index_view_types = %w(list gallery rss)
|
508
|
+
end
|
509
|
+
|
510
|
+
it 'includes selected view types as the value true' do
|
511
|
+
expect(subject.document_index_view_types_selected_hash.to_h).to include list: true, gallery: true
|
512
|
+
end
|
513
|
+
|
514
|
+
it 'disabled view types are not included' do
|
515
|
+
expect(subject.document_index_view_types_selected_hash.to_h).not_to include :map
|
516
|
+
end
|
517
|
+
|
518
|
+
it 'excludes view types disabled by configuration (not by curator settings)' do
|
519
|
+
expect(subject.document_index_view_types_selected_hash.to_h).not_to include :rss
|
520
|
+
end
|
521
|
+
end
|
459
522
|
end
|