blacklight-spotlight 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spotlight/roles_controller.rb +1 -1
- data/lib/spotlight/version.rb +1 -1
- metadata +6 -610
- data/spec/controllers/application_controller_spec.rb +0 -30
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +0 -239
- data/spec/controllers/spotlight/admin_users_controller_spec.rb +0 -53
- data/spec/controllers/spotlight/appearances_controller_spec.rb +0 -88
- data/spec/controllers/spotlight/application_controller_spec.rb +0 -11
- data/spec/controllers/spotlight/attachments_controller_spec.rb +0 -28
- data/spec/controllers/spotlight/browse_controller_spec.rb +0 -133
- data/spec/controllers/spotlight/bulk_actions_controller_spec.rb +0 -124
- data/spec/controllers/spotlight/bulk_updates_controller_spec.rb +0 -77
- data/spec/controllers/spotlight/catalog_controller_spec.rb +0 -552
- data/spec/controllers/spotlight/confirmations_controller_spec.rb +0 -38
- data/spec/controllers/spotlight/contact_email_controller_spec.rb +0 -65
- data/spec/controllers/spotlight/contact_forms_controller_spec.rb +0 -38
- data/spec/controllers/spotlight/contacts_controller_spec.rb +0 -103
- data/spec/controllers/spotlight/custom_fields_controller_spec.rb +0 -62
- data/spec/controllers/spotlight/custom_search_fields_controller_spec.rb +0 -62
- data/spec/controllers/spotlight/dashboards_controller_spec.rb +0 -68
- data/spec/controllers/spotlight/exhibits_controller_spec.rb +0 -216
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +0 -251
- data/spec/controllers/spotlight/featured_images_controller_spec.rb +0 -77
- data/spec/controllers/spotlight/filters_controller_spec.rb +0 -72
- data/spec/controllers/spotlight/groups_controller_spec.rb +0 -103
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +0 -126
- data/spec/controllers/spotlight/job_trackers_controller_spec.rb +0 -37
- data/spec/controllers/spotlight/languages_controller_spec.rb +0 -70
- data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +0 -93
- data/spec/controllers/spotlight/pages_controller_spec.rb +0 -50
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +0 -71
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +0 -55
- data/spec/controllers/spotlight/resources_controller_spec.rb +0 -85
- data/spec/controllers/spotlight/roles_controller_spec.rb +0 -141
- data/spec/controllers/spotlight/search_configurations_controller_spec.rb +0 -141
- data/spec/controllers/spotlight/searches_controller_spec.rb +0 -195
- data/spec/controllers/spotlight/sites_controller_spec.rb +0 -67
- data/spec/controllers/spotlight/solr_controller_spec.rb +0 -116
- data/spec/controllers/spotlight/tags_controller_spec.rb +0 -56
- data/spec/controllers/spotlight/translations_controller_spec.rb +0 -132
- data/spec/controllers/spotlight/versions_controller_spec.rb +0 -56
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +0 -35
- data/spec/examples.txt +0 -1515
- data/spec/factories/bulk_updates.rb +0 -21
- data/spec/factories/contact_emails.rb +0 -8
- data/spec/factories/contact_images.rb +0 -8
- data/spec/factories/contacts.rb +0 -11
- data/spec/factories/custom_fields.rb +0 -9
- data/spec/factories/custom_search_fields.rb +0 -9
- data/spec/factories/exhibit_thumbnails.rb +0 -8
- data/spec/factories/exhibits.rb +0 -17
- data/spec/factories/featured_images.rb +0 -16
- data/spec/factories/group.rb +0 -17
- data/spec/factories/job_trackers.rb +0 -11
- data/spec/factories/language.rb +0 -8
- data/spec/factories/main_navigation.rb +0 -9
- data/spec/factories/pages.rb +0 -34
- data/spec/factories/resources.rb +0 -14
- data/spec/factories/roles.rb +0 -9
- data/spec/factories/searches.rb +0 -33
- data/spec/factories/tags.rb +0 -14
- data/spec/factories/translation.rb +0 -8
- data/spec/factories/users.rb +0 -50
- data/spec/features/about_page_spec.rb +0 -46
- data/spec/features/add_contacts_spec.rb +0 -63
- data/spec/features/add_custom_field_metadata_spec.rb +0 -88
- data/spec/features/add_iiif_manifest_spec.rb +0 -46
- data/spec/features/add_items_spec.rb +0 -135
- data/spec/features/autocomplete_typeahead_spec.rb +0 -89
- data/spec/features/browse_category_admin_spec.rb +0 -163
- data/spec/features/browse_category_navigation_spec.rb +0 -44
- data/spec/features/browse_category_spec.rb +0 -158
- data/spec/features/bulk_actions_spec.rb +0 -72
- data/spec/features/catalog_spec.rb +0 -57
- data/spec/features/confirm_email_spec.rb +0 -21
- data/spec/features/create_exhibit_spec.rb +0 -65
- data/spec/features/create_page_spec.rb +0 -21
- data/spec/features/dashboard_spec.rb +0 -34
- data/spec/features/edit_contact_spec.rb +0 -21
- data/spec/features/edit_search_fields_spec.rb +0 -79
- data/spec/features/exhibit_masthead_spec.rb +0 -112
- data/spec/features/exhibit_themes_spec.rb +0 -30
- data/spec/features/exhibits/add_tags_spec.rb +0 -35
- data/spec/features/exhibits/administration_spec.rb +0 -141
- data/spec/features/exhibits/custom_metadata_fields_spec.rb +0 -97
- data/spec/features/exhibits/custom_search_fields_spec.rb +0 -55
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +0 -49
- data/spec/features/exhibits/language_create_edit_spec.rb +0 -59
- data/spec/features/exhibits/translation_editing_spec.rb +0 -463
- data/spec/features/exhibits_index_spec.rb +0 -55
- data/spec/features/feature_page_spec.rb +0 -155
- data/spec/features/home_page_spec.rb +0 -102
- data/spec/features/import_exhibit_spec.rb +0 -58
- data/spec/features/item_admin_spec.rb +0 -59
- data/spec/features/javascript/about_page_admin_spec.rb +0 -21
- data/spec/features/javascript/block_controls_spec.rb +0 -42
- data/spec/features/javascript/blocks/browse_group_categories_block_spec.rb +0 -64
- data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +0 -46
- data/spec/features/javascript/blocks/featured_pages_block_spec.rb +0 -61
- data/spec/features/javascript/blocks/link_to_search_block_spec.rb +0 -46
- data/spec/features/javascript/blocks/rule_block_spec.rb +0 -23
- data/spec/features/javascript/blocks/search_result_block_spec.rb +0 -47
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +0 -232
- data/spec/features/javascript/blocks/solr_documents_carousel_block_spec.rb +0 -29
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +0 -94
- data/spec/features/javascript/browse_group_admin_spec.rb +0 -45
- data/spec/features/javascript/edit_in_place_spec.rb +0 -93
- data/spec/features/javascript/feature_page_admin_spec.rb +0 -140
- data/spec/features/javascript/home_page_edit_spec.rb +0 -34
- data/spec/features/javascript/locale_selector_spec.rb +0 -66
- data/spec/features/javascript/metadata_admin_spec.rb +0 -41
- data/spec/features/javascript/multi_image_select_spec.rb +0 -50
- data/spec/features/javascript/reindex_monitor_spec.rb +0 -23
- data/spec/features/javascript/roles_admin_spec.rb +0 -38
- data/spec/features/javascript/search_config_admin_spec.rb +0 -140
- data/spec/features/javascript/search_context_spec.rb +0 -88
- data/spec/features/main_navigation_spec.rb +0 -96
- data/spec/features/metadata_admin_spec.rb +0 -18
- data/spec/features/report_a_problem_spec.rb +0 -62
- data/spec/features/site_masthead_spec.rb +0 -91
- data/spec/features/site_users_management_spec.rb +0 -74
- data/spec/features/slideshow_spec.rb +0 -21
- data/spec/features/translation_scope_spec.rb +0 -27
- data/spec/fixtures/800x600.png +0 -0
- data/spec/fixtures/avatar.png +0 -0
- data/spec/fixtures/bulk-update-template.csv +0 -57
- data/spec/fixtures/csv-upload-fixture.csv +0 -4
- data/spec/fixtures/gk446cj2442-manifest.json +0 -58
- data/spec/fixtures/iiif_responses.rb +0 -312
- data/spec/fixtures/json-upload-fixture.json +0 -3
- data/spec/fixtures/sample_solr_documents.yml +0 -9385
- data/spec/fixtures/updated-bulk-update-template-no-cols.csv +0 -4
- data/spec/fixtures/updated-bulk-update-template-w-tags.csv +0 -4
- data/spec/fixtures/updated-bulk-update-template.csv +0 -4
- data/spec/helpers/spotlight/application_helper_spec.rb +0 -196
- data/spec/helpers/spotlight/browse_helper_spec.rb +0 -13
- data/spec/helpers/spotlight/crop_helper_spec.rb +0 -11
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +0 -163
- data/spec/helpers/spotlight/languages_helper_spec.rb +0 -79
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +0 -101
- data/spec/helpers/spotlight/masthead_helper_spec.rb +0 -51
- data/spec/helpers/spotlight/meta_helper_spec.rb +0 -33
- data/spec/helpers/spotlight/navbar_helper_spec.rb +0 -24
- data/spec/helpers/spotlight/pages_helper_spec.rb +0 -123
- data/spec/helpers/spotlight/roles_helper_spec.rb +0 -7
- data/spec/helpers/spotlight/search_configurations_helper_spec.rb +0 -23
- data/spec/helpers/spotlight/title_helper_spec.rb +0 -64
- data/spec/helpers/spotlight/translations_helper_spec.rb +0 -16
- data/spec/i18n_spec.rb +0 -27
- data/spec/jobs/spotlight/add_tags_job_spec.rb +0 -34
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +0 -58
- data/spec/jobs/spotlight/change_visibility_job_spec.rb +0 -30
- data/spec/jobs/spotlight/default_thumbnail_job_spec.rb +0 -14
- data/spec/jobs/spotlight/process_bulk_updates_csv_job_spec.rb +0 -86
- data/spec/jobs/spotlight/reindex_exhibit_job_spec.rb +0 -43
- data/spec/jobs/spotlight/reindex_job_spec.rb +0 -79
- data/spec/jobs/spotlight/remove_tags_job_spec.rb +0 -39
- data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +0 -33
- data/spec/lib/migration/iiif_spec.rb +0 -91
- data/spec/lib/migration/page_language_spec.rb +0 -25
- data/spec/lib/spotlight/catalog_spec.rb +0 -0
- data/spec/lib/spotlight/controller_spec.rb +0 -102
- data/spec/lib/spotlight/upload_field_config_spec.rb +0 -40
- data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +0 -42
- data/spec/models/sir_trevor_rails/block_spec.rb +0 -72
- data/spec/models/sir_trevor_rails/blocks/browse_block_spec.rb +0 -42
- data/spec/models/sir_trevor_rails/blocks/browse_group_categories_block_spec.rb +0 -41
- data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +0 -50
- data/spec/models/sir_trevor_rails/blocks/search_results_block_spec.rb +0 -23
- data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +0 -59
- data/spec/models/sir_trevor_rails/blocks/textable_spec.rb +0 -42
- data/spec/models/solr_document_spec.rb +0 -214
- data/spec/models/spotlight/ability_spec.rb +0 -118
- data/spec/models/spotlight/about_page_spec.rb +0 -19
- data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +0 -82
- data/spec/models/spotlight/analytics/ga_spec.rb +0 -22
- data/spec/models/spotlight/background_job_progress_spec.rb +0 -137
- data/spec/models/spotlight/blacklight_configuration_spec.rb +0 -649
- data/spec/models/spotlight/browse_category_search_builder_spec.rb +0 -51
- data/spec/models/spotlight/contact_email_spec.rb +0 -48
- data/spec/models/spotlight/contact_form_spec.rb +0 -94
- data/spec/models/spotlight/contact_image_spec.rb +0 -11
- data/spec/models/spotlight/contact_spec.rb +0 -38
- data/spec/models/spotlight/custom_field_spec.rb +0 -204
- data/spec/models/spotlight/custom_search_field_spec.rb +0 -56
- data/spec/models/spotlight/custom_translation_extension_spec.rb +0 -24
- data/spec/models/spotlight/exhibit_spec.rb +0 -383
- data/spec/models/spotlight/exhibit_thumbnail_spec.rb +0 -10
- data/spec/models/spotlight/feature_page_spec.rb +0 -87
- data/spec/models/spotlight/featured_image_spec.rb +0 -110
- data/spec/models/spotlight/field_metadata_spec.rb +0 -58
- data/spec/models/spotlight/filter_spec.rb +0 -19
- data/spec/models/spotlight/group_spec.rb +0 -19
- data/spec/models/spotlight/home_page_spec.rb +0 -38
- data/spec/models/spotlight/language_spec.rb +0 -42
- data/spec/models/spotlight/main_navigation_spec.rb +0 -19
- data/spec/models/spotlight/masthead_spec.rb +0 -45
- data/spec/models/spotlight/page_configurations_spec.rb +0 -45
- data/spec/models/spotlight/page_spec.rb +0 -293
- data/spec/models/spotlight/resource_spec.rb +0 -137
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +0 -52
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +0 -178
- data/spec/models/spotlight/resources/iiif_service_spec.rb +0 -57
- data/spec/models/spotlight/resources/upload_spec.rb +0 -71
- data/spec/models/spotlight/resources/web_spec.rb +0 -25
- data/spec/models/spotlight/role_spec.rb +0 -51
- data/spec/models/spotlight/search_spec.rb +0 -125
- data/spec/models/spotlight/site_spec.rb +0 -9
- data/spec/models/spotlight/sitemap_spec.rb +0 -113
- data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +0 -56
- data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +0 -38
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +0 -48
- data/spec/models/spotlight/user_spec.rb +0 -26
- data/spec/models/translation_spec.rb +0 -26
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +0 -132
- data/spec/routing/spotlight/exhibit_catalog_spec.rb +0 -34
- data/spec/routing/spotlight/featured_images_spec.rb +0 -23
- data/spec/routing/spotlight/pages_routing_spec.rb +0 -42
- data/spec/services/spotlight/bulk_updates_csv_template_service_spec.rb +0 -26
- data/spec/services/spotlight/carrierwave_file_resolver_spec.rb +0 -16
- data/spec/services/spotlight/clone_translated_page_from_locale_spec.rb +0 -30
- data/spec/services/spotlight/etl/context_spec.rb +0 -66
- data/spec/services/spotlight/etl/executor_spec.rb +0 -149
- data/spec/services/spotlight/etl/pipeline_spec.rb +0 -22
- data/spec/services/spotlight/etl/solr_loader_spec.rb +0 -76
- data/spec/services/spotlight/etl/step_spec.rb +0 -70
- data/spec/services/spotlight/exhibit_import_export_service_spec.rb +0 -569
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +0 -94
- data/spec/services/spotlight/invite_users_service_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -146
- data/spec/support/controllers/engine_helpers.rb +0 -9
- data/spec/support/disable_friendly_id_deprecation_warnings.rb +0 -11
- data/spec/support/features/capybara_default_max_wait_metadata_helper.rb +0 -20
- data/spec/support/features/test_features_helpers.rb +0 -92
- data/spec/support/helpers/controller_level_helpers.rb +0 -25
- data/spec/support/stub_iiif_response.rb +0 -26
- data/spec/support/views/test_view_helpers.rb +0 -21
- data/spec/test_app_templates/Gemfile.extra +0 -2
- data/spec/test_app_templates/carrierwave.rb +0 -8
- data/spec/test_app_templates/catalog_controller.rb +0 -108
- data/spec/test_app_templates/fixture.css +0 -0
- data/spec/test_app_templates/fixture.png +0 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -71
- data/spec/test_app_templates/spotlight_test.rake +0 -14
- data/spec/uploaders/spotlight/attachment_uploader_spec.rb +0 -27
- data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +0 -33
- data/spec/views/shared/_analytics.html.erb_spec.rb +0 -17
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +0 -127
- data/spec/views/shared/_header_navbar.html.erb_spec.rb +0 -12
- data/spec/views/shared/_masthead.html.erb_spec.rb +0 -91
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +0 -102
- data/spec/views/spotlight/about_pages/_empty.html.erb_spec.rb +0 -28
- data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +0 -24
- data/spec/views/spotlight/about_pages/index.html.erb_spec.rb +0 -69
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +0 -22
- data/spec/views/spotlight/browse/show.html.erb_spec.rb +0 -65
- data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +0 -63
- data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +0 -39
- data/spec/views/spotlight/catalog/edit.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +0 -43
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +0 -45
- data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +0 -94
- data/spec/views/spotlight/dashboards/analytics.html.erb_spec.rb +0 -33
- data/spec/views/spotlight/exhibits/_exhibit_card.html.erb_spec.rb +0 -46
- data/spec/views/spotlight/exhibits/_form.html.erb_spec.rb +0 -38
- data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +0 -29
- data/spec/views/spotlight/exhibits/index.html.erb_spec.rb +0 -140
- data/spec/views/spotlight/feature_pages/_empty.html.erb_spec.rb +0 -28
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +0 -45
- data/spec/views/spotlight/featured_images/_form.html.erb_spec.rb +0 -32
- data/spec/views/spotlight/featured_images/_upload_form.html.erb_spec.rb +0 -32
- data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +0 -28
- data/spec/views/spotlight/home_pages/_sidebar.html.erb_spec.rb +0 -12
- data/spec/views/spotlight/job_trackers/show.html.erb_spec.rb +0 -65
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +0 -23
- data/spec/views/spotlight/pages/_form.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/pages/edit.html.erb_spec.rb +0 -68
- data/spec/views/spotlight/pages/index.html.erb_spec.rb +0 -42
- data/spec/views/spotlight/pages/new.html.erb_spec.rb +0 -21
- data/spec/views/spotlight/pages/show.html.erb_spec.rb +0 -84
- data/spec/views/spotlight/resources/_external_resources_form.html.erb_spec.rb +0 -36
- data/spec/views/spotlight/resources/new.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/roles/index.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/search_configurations/_facet_metadata.html.erb_spec.rb +0 -58
- data/spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb +0 -54
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +0 -54
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +0 -40
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +0 -37
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +0 -40
- data/spec/views/spotlight/searches/index.html.erb_spec.rb +0 -33
- data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +0 -10
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +0 -43
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +0 -34
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +0 -53
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +0 -54
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +0 -42
- data/spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb +0 -25
- data/spec/views/spotlight/tags/index.html.erb_spec.rb +0 -27
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +0 -24
- data/spec/views/spotlight/translations/_page.html.erb_spec.rb +0 -76
@@ -1,141 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::SearchConfigurationsController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
|
-
|
7
|
-
describe 'when the user is not authorized' do
|
8
|
-
before do
|
9
|
-
sign_in FactoryBot.create(:exhibit_visitor)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'GET edit' do
|
13
|
-
it 'denies access' do
|
14
|
-
get :edit, params: { exhibit_id: exhibit }
|
15
|
-
expect(response).to redirect_to main_app.root_path
|
16
|
-
expect(flash[:alert]).to be_present
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'when not logged in' do
|
22
|
-
describe 'PATCH update' do
|
23
|
-
it 'denies access' do
|
24
|
-
patch :update, params: { exhibit_id: exhibit }
|
25
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'GET edit' do
|
30
|
-
it 'denies access' do
|
31
|
-
get :edit, params: { exhibit_id: exhibit }
|
32
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'when signed in' do
|
38
|
-
let(:user) { FactoryBot.create(:exhibit_admin, exhibit: exhibit) }
|
39
|
-
|
40
|
-
before { sign_in user }
|
41
|
-
|
42
|
-
describe 'GET edit' do
|
43
|
-
it 'is successful' do
|
44
|
-
expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
|
45
|
-
expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
|
46
|
-
expect(controller).to receive(:add_breadcrumb).with('Search', edit_exhibit_search_configuration_path(exhibit))
|
47
|
-
get :edit, params: { exhibit_id: exhibit }
|
48
|
-
expect(response).to be_successful
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'assigns the field metadata' do
|
52
|
-
get :edit, params: { exhibit_id: exhibit }
|
53
|
-
expect(assigns(:field_metadata)).to be_an_instance_of(Spotlight::FieldMetadata)
|
54
|
-
expect(assigns(:field_metadata).repository).to be_an_instance_of(controller.blacklight_config.repository_class)
|
55
|
-
expect(assigns(:field_metadata).blacklight_config).to eq controller.blacklight_config
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'PATCH update' do
|
60
|
-
it 'updates facet fields' do
|
61
|
-
patch :update, params: {
|
62
|
-
exhibit_id: exhibit,
|
63
|
-
blacklight_configuration: {
|
64
|
-
facet_fields: { 'genre_ssim' => { enabled: '1', label: 'Label' } }
|
65
|
-
}
|
66
|
-
}
|
67
|
-
expect(flash[:notice]).to eq 'The exhibit was successfully updated.'
|
68
|
-
expect(response).to redirect_to edit_exhibit_search_configuration_path(exhibit)
|
69
|
-
assigns[:exhibit].tap do |saved|
|
70
|
-
expect(saved.blacklight_configuration.facet_fields.keys).to eq ['genre_ssim']
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'updates sort fields' do
|
75
|
-
patch :update, params: {
|
76
|
-
exhibit_id: exhibit,
|
77
|
-
blacklight_configuration: {
|
78
|
-
sort_fields: {
|
79
|
-
'relevance' => { 'enabled' => '1', 'label' => 'Relevance' },
|
80
|
-
'title' => { 'enabled' => '1', 'label' => 'Title' },
|
81
|
-
'type' => { 'enabled' => '1', 'label' => 'Type' },
|
82
|
-
'date' => { 'enabled' => '0', 'label' => 'Date' },
|
83
|
-
'source' => { 'enabled' => '0', 'label' => 'Source' },
|
84
|
-
'identifier' => { 'enabled' => '0', 'label' => 'Identifier' }
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
expect(flash[:notice]).to eq 'The exhibit was successfully updated.'
|
89
|
-
expect(response).to redirect_to edit_exhibit_search_configuration_path(exhibit)
|
90
|
-
assigns[:exhibit].tap do |saved|
|
91
|
-
expect(saved.blacklight_configuration.sort_fields).to eq(
|
92
|
-
'relevance' => { 'label' => 'Relevance', 'enabled' => true },
|
93
|
-
'title' => { 'label' => 'Title', 'enabled' => true },
|
94
|
-
'type' => { 'label' => 'Type', 'enabled' => true },
|
95
|
-
'date' => { 'label' => 'Date', 'enabled' => false },
|
96
|
-
'source' => { 'label' => 'Source', 'enabled' => false },
|
97
|
-
'identifier' => { 'label' => 'Identifier', 'enabled' => false }
|
98
|
-
)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'updates search fields' do
|
103
|
-
patch :update, params: {
|
104
|
-
exhibit_id: exhibit,
|
105
|
-
blacklight_configuration: {
|
106
|
-
search_fields: {
|
107
|
-
'all_fields' => { 'enabled' => '1' },
|
108
|
-
'title' => { 'enabled' => '0', 'label' => 'Title' },
|
109
|
-
'author' => { 'enabled' => '1', 'label' => 'Primary Author' }
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
expect(flash[:notice]).to eq 'The exhibit was successfully updated.'
|
114
|
-
expect(response).to redirect_to edit_exhibit_search_configuration_path(exhibit)
|
115
|
-
assigns[:exhibit].tap do |saved|
|
116
|
-
expect(saved.blacklight_configuration.search_fields).to eq(
|
117
|
-
'all_fields' => { 'label' => 'Everything', 'enabled' => true },
|
118
|
-
'title' => { 'label' => 'Title', 'enabled' => false },
|
119
|
-
'author' => { 'label' => 'Primary Author', 'enabled' => true }
|
120
|
-
)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'updates appearance fields' do
|
125
|
-
patch :update, params: {
|
126
|
-
exhibit_id: exhibit,
|
127
|
-
blacklight_configuration: {
|
128
|
-
document_index_view_types: { 'list' => '1', 'gallery' => '1', 'map' => '0' },
|
129
|
-
default_per_page: '50'
|
130
|
-
}
|
131
|
-
}
|
132
|
-
expect(flash[:notice]).to eq 'The exhibit was successfully updated.'
|
133
|
-
expect(response).to redirect_to edit_exhibit_search_configuration_path(exhibit)
|
134
|
-
assigns[:exhibit].tap do |saved|
|
135
|
-
expect(saved.blacklight_configuration.document_index_view_types).to eq %w[list gallery]
|
136
|
-
expect(saved.blacklight_configuration.default_per_page).to eq 50
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
@@ -1,195 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::SearchesController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
|
-
|
7
|
-
before do
|
8
|
-
allow(Spotlight::DefaultThumbnailJob).to receive(:perform_later)
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'when the user is not authorized' do
|
12
|
-
before do
|
13
|
-
sign_in FactoryBot.create(:exhibit_visitor)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'POST create' do
|
17
|
-
it 'denies access' do
|
18
|
-
post :create, params: { exhibit_id: exhibit }
|
19
|
-
expect(response).to redirect_to main_app.root_path
|
20
|
-
expect(flash[:alert]).to be_present
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'GET index' do
|
25
|
-
it 'denies access' do
|
26
|
-
get :index, params: { exhibit_id: exhibit }
|
27
|
-
expect(response).to redirect_to main_app.root_path
|
28
|
-
expect(flash[:alert]).to be_present
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'when the user is a curator' do
|
34
|
-
before do
|
35
|
-
sign_in FactoryBot.create(:exhibit_curator, exhibit: exhibit)
|
36
|
-
end
|
37
|
-
|
38
|
-
let(:search) { FactoryBot.create(:search, exhibit: exhibit) }
|
39
|
-
|
40
|
-
it 'creates a saved search' do
|
41
|
-
request.env['HTTP_REFERER'] = '/referring_url'
|
42
|
-
post :create, params: { 'search' => { 'title' => 'A bunch of maps' }, 'f' => { 'genre_ssim' => ['map'] }, exhibit_id: exhibit }
|
43
|
-
expect(response).to redirect_to '/referring_url'
|
44
|
-
expect(flash[:notice]).to eq 'The browse category was created.'
|
45
|
-
expect(assigns[:search].title).to eq 'A bunch of maps'
|
46
|
-
expect(assigns[:search].query_params).to eq('f' => { 'genre_ssim' => ['map'] })
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'GET index' do
|
50
|
-
let!(:search) { FactoryBot.create(:search, exhibit: exhibit) }
|
51
|
-
let(:group) { FactoryBot.create(:group, published: true, title: 'Good group', exhibit: exhibit, searches: [search]) }
|
52
|
-
|
53
|
-
it 'shows all the items' do
|
54
|
-
expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
|
55
|
-
expect(controller).to receive(:add_breadcrumb).with('Curation', exhibit_dashboard_path(exhibit))
|
56
|
-
expect(controller).to receive(:add_breadcrumb).with('Browse', exhibit_searches_path(exhibit))
|
57
|
-
get :index, params: { exhibit_id: search.exhibit_id }
|
58
|
-
expect(response).to be_successful
|
59
|
-
expect(assigns[:exhibit]).to eq search.exhibit
|
60
|
-
expect(assigns[:searches]).to include search
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'assigns groups and group' do
|
64
|
-
get :index, params: { exhibit_id: search.exhibit_id }
|
65
|
-
expect(response).to be_successful
|
66
|
-
expect(assigns[:groups]).to eq [group]
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'has a JSON response with published resources' do
|
70
|
-
search.published = true
|
71
|
-
search.save!
|
72
|
-
|
73
|
-
get :index, params: { exhibit_id: exhibit, format: 'json' }
|
74
|
-
expect(response).to be_successful
|
75
|
-
json = JSON.parse(response.body)
|
76
|
-
expect(json.last).to include('id' => search.id, 'title' => search.title)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe 'GET autocomplete' do
|
81
|
-
let(:search) do
|
82
|
-
FactoryBot.create(:search, exhibit: exhibit, title: 'New Mexico Maps', query_params: { q: 'New Mexico' })
|
83
|
-
end
|
84
|
-
|
85
|
-
let(:search_fq) do
|
86
|
-
FactoryBot.create(:search, exhibit: exhibit, title: 'New Mexico Maps', query_params: { f: { subject_geographic_ssim: ['Pacific Ocean'] } })
|
87
|
-
end
|
88
|
-
|
89
|
-
it "shows all the items returned search's query_params" do
|
90
|
-
pending("A search defined by a query doesn't work with autocomplete correctly.")
|
91
|
-
get :autocomplete, params: { exhibit_id: exhibit, id: search, format: 'json' }
|
92
|
-
expect(response).to be_successful
|
93
|
-
docs = JSON.parse(response.body)['docs']
|
94
|
-
doc_ids = docs.map { |d| d['id'] }
|
95
|
-
expect(docs.length).to eq 2
|
96
|
-
expect(doc_ids).to include 'cz507zk0531'
|
97
|
-
expect(doc_ids).to include 'rz818vx8201'
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'searches within the items returned in the query_params' do
|
101
|
-
get :autocomplete, params: { exhibit_id: exhibit, id: search_fq, q: 'California', format: 'json' }
|
102
|
-
expect(response).to be_successful
|
103
|
-
docs = JSON.parse(response.body)['docs']
|
104
|
-
expect(docs.length).to eq 1
|
105
|
-
expect(docs.first['id']).to eq 'sn161bw2027'
|
106
|
-
expect(docs.first['description']).to eq 'sn161bw2027'
|
107
|
-
expect(docs.first['title']).to match(/Pas-caart van Zuyd-Zee/)
|
108
|
-
expect(docs.first).to have_key('thumbnail')
|
109
|
-
expect(docs.first).to have_key('url')
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe 'GET edit' do
|
114
|
-
it 'shows edit page' do
|
115
|
-
get :edit, params: { id: search, exhibit_id: search.exhibit }
|
116
|
-
expect(response).to be_successful
|
117
|
-
expect(assigns[:search]).to eq search
|
118
|
-
expect(assigns[:exhibit]).to eq search.exhibit
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe 'PATCH update' do
|
123
|
-
it 'shows edit page' do
|
124
|
-
patch :update, params: {
|
125
|
-
id: search,
|
126
|
-
exhibit_id: search.exhibit,
|
127
|
-
search: {
|
128
|
-
title: 'Hey man',
|
129
|
-
long_description: 'long',
|
130
|
-
featured_image: 'http://lorempixel.com/64/64/',
|
131
|
-
masthead_attributes: { iiif_url: '' },
|
132
|
-
thumbnail_attributes: { iiif_url: '' }
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
expect(assigns[:search].title).to eq 'Hey man'
|
137
|
-
expect(response).to redirect_to exhibit_searches_path(search.exhibit)
|
138
|
-
end
|
139
|
-
|
140
|
-
it "renders edit if there's an error" do
|
141
|
-
expect_any_instance_of(Spotlight::Search).to receive(:update).and_return(false)
|
142
|
-
patch :update, params: {
|
143
|
-
id: search,
|
144
|
-
exhibit_id: search.exhibit,
|
145
|
-
search: {
|
146
|
-
title: 'Hey man',
|
147
|
-
long_description: 'long',
|
148
|
-
featured_image: 'http://lorempixel.com/64/64/'
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
expect(response).to be_successful
|
153
|
-
expect(response).to render_template 'edit'
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe 'DELETE destroy' do
|
158
|
-
let!(:search) { FactoryBot.create(:search, exhibit: exhibit) }
|
159
|
-
|
160
|
-
it 'removes it' do
|
161
|
-
expect do
|
162
|
-
delete :destroy, params: { id: search, exhibit_id: search.exhibit }
|
163
|
-
end.to change(Spotlight::Search, :count).by(-1)
|
164
|
-
expect(response).to redirect_to exhibit_searches_path(search.exhibit)
|
165
|
-
expect(flash[:alert]).to eq 'The browse category was deleted.'
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
describe 'POST update_all' do
|
170
|
-
let!(:search2) { FactoryBot.create(:search, exhibit: exhibit, published: true) }
|
171
|
-
let!(:search3) { FactoryBot.create(:search, exhibit: exhibit, published: true) }
|
172
|
-
|
173
|
-
before { request.env['HTTP_REFERER'] = '/whatever' }
|
174
|
-
|
175
|
-
it 'updates whether they are on the landing page' do
|
176
|
-
post :update_all, params: {
|
177
|
-
exhibit_id: exhibit,
|
178
|
-
exhibit: {
|
179
|
-
searches_attributes: [
|
180
|
-
{ id: search.id, published: true, weight: '1' },
|
181
|
-
{ id: search2.id, published: false, weight: '0' }
|
182
|
-
]
|
183
|
-
}
|
184
|
-
}
|
185
|
-
|
186
|
-
expect(search.reload.published).to be_truthy
|
187
|
-
expect(search.weight).to eq 1
|
188
|
-
expect(search2.reload.published).to be_falsey
|
189
|
-
expect(search3.reload.published).to be_truthy # should remain untouched since it wasn't present
|
190
|
-
expect(response).to redirect_to end_with('/whatever')
|
191
|
-
expect(flash[:notice]).to eq 'Browse categories were successfully updated.'
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::SitesController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
|
6
|
-
describe 'when user does not have access' do
|
7
|
-
before { sign_in FactoryBot.create(:exhibit_visitor) }
|
8
|
-
|
9
|
-
describe 'GET edit' do
|
10
|
-
it 'denies access' do
|
11
|
-
get :edit
|
12
|
-
expect(response).to redirect_to main_app.root_path
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'when user is an admin' do
|
18
|
-
let(:admin) { FactoryBot.create(:site_admin) }
|
19
|
-
|
20
|
-
before { sign_in admin }
|
21
|
-
|
22
|
-
describe 'GET edit' do
|
23
|
-
it 'allows access' do
|
24
|
-
get :edit
|
25
|
-
expect(response).to be_successful
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'GET edit_exhibits' do
|
30
|
-
it 'allows access' do
|
31
|
-
get :edit_exhibits
|
32
|
-
expect(response).to be_successful
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'PATCH update' do
|
37
|
-
let!(:exhibit_a) { FactoryBot.create(:exhibit) }
|
38
|
-
let!(:exhibit_b) { FactoryBot.create(:exhibit) }
|
39
|
-
|
40
|
-
it 'changes the exhibit order' do
|
41
|
-
patch :update, params: {
|
42
|
-
site: {
|
43
|
-
exhibits_attributes: [{ id: exhibit_a.id, weight: 5 }, { id: exhibit_b.id, weight: 2 }],
|
44
|
-
masthead_attributes: { display: 0 }
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
expect(response).to redirect_to(exhibits_path)
|
49
|
-
|
50
|
-
expect(Spotlight::Exhibit.ordered_by_weight.first).to eq exhibit_b
|
51
|
-
expect(exhibit_a.reload.weight).to eq 5
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'GET tags' do
|
56
|
-
let!(:exhibit_a) { FactoryBot.create(:exhibit, tag_list: 'a') }
|
57
|
-
|
58
|
-
it 'serializes the exhibit-level tags' do
|
59
|
-
get :tags, params: { format: 'json' }
|
60
|
-
expect(response).to be_successful
|
61
|
-
data = JSON.parse(response.body)
|
62
|
-
|
63
|
-
expect(data).to include 'a'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::SolrController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
|
-
|
7
|
-
describe 'when user does not have access' do
|
8
|
-
before { sign_in FactoryBot.create(:exhibit_visitor) }
|
9
|
-
|
10
|
-
describe 'POST update' do
|
11
|
-
it 'does not allow update' do
|
12
|
-
post :update, params: { exhibit_id: exhibit }
|
13
|
-
expect(response).to redirect_to main_app.root_path
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'when user is an admin' do
|
19
|
-
let(:admin) { FactoryBot.create(:site_admin) }
|
20
|
-
let(:role) { admin.roles.first }
|
21
|
-
let(:connection) { instance_double(RSolr::Client) }
|
22
|
-
let(:repository) { instance_double(Blacklight::Solr::Repository, connection: connection) }
|
23
|
-
let!(:custom_field) { FactoryBot.create :custom_field, exhibit: exhibit, slug: 'custom_field' }
|
24
|
-
|
25
|
-
before { sign_in admin }
|
26
|
-
|
27
|
-
before do
|
28
|
-
allow(controller).to receive(:repository).and_return(repository)
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'POST update' do
|
32
|
-
it 'passes through the request data' do
|
33
|
-
doc = {}
|
34
|
-
expect(connection).to receive(:update) do |params|
|
35
|
-
doc = JSON.parse(params[:data], symbolize_names: true)
|
36
|
-
end
|
37
|
-
|
38
|
-
post_update_with_json_body(exhibit, a: 1)
|
39
|
-
|
40
|
-
expect(response).to be_successful
|
41
|
-
expect(doc.first).to include a: 1
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when the index is not writable' do
|
45
|
-
before do
|
46
|
-
allow(Spotlight::Engine.config).to receive_messages(writable_index: false)
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'raises an error' do
|
50
|
-
post_update_with_json_body(exhibit, a: 1)
|
51
|
-
|
52
|
-
expect(response.code).to eq '409'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'enriches the request with exhibit solr data' do
|
57
|
-
doc = {}
|
58
|
-
expect(connection).to receive(:update) do |params|
|
59
|
-
doc = JSON.parse(params[:data], symbolize_names: true)
|
60
|
-
end
|
61
|
-
|
62
|
-
post_update_with_json_body(exhibit, a: 1)
|
63
|
-
|
64
|
-
expect(response).to be_successful
|
65
|
-
expect(doc.first).to include exhibit.solr_data
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'enriches the request with sidecar data' do
|
69
|
-
doc = {}
|
70
|
-
expect(connection).to receive(:update) do |params|
|
71
|
-
doc = JSON.parse(params[:data], symbolize_names: true)
|
72
|
-
end
|
73
|
-
|
74
|
-
allow_any_instance_of(SolrDocument).to receive(:to_solr).and_return(b: 1)
|
75
|
-
|
76
|
-
post_update_with_json_body(exhibit, a: 1)
|
77
|
-
|
78
|
-
expect(response).to be_successful
|
79
|
-
expect(doc.first).to include b: 1
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'creates sidecars for data that matches custom field slugs' do
|
83
|
-
doc = {}
|
84
|
-
expect(connection).to receive(:update) do |params|
|
85
|
-
doc = JSON.parse(params[:data], symbolize_names: true)
|
86
|
-
end
|
87
|
-
|
88
|
-
expect do
|
89
|
-
post_update_with_json_body(exhibit, a: 1, custom_field: 'abc')
|
90
|
-
end.to change(Spotlight::SolrDocumentSidecar, :count).by(1)
|
91
|
-
|
92
|
-
expect(response).to be_successful
|
93
|
-
expect(doc.first).to include a: 1
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'with a file upload' do
|
97
|
-
let(:json) { fixture_file_upload(File.expand_path(File.join('..', 'spec', 'fixtures', 'json-upload-fixture.json'), Rails.root), 'application/json') }
|
98
|
-
|
99
|
-
it 'parses the uploaded file' do
|
100
|
-
doc = {}
|
101
|
-
expect(connection).to receive(:update) do |params|
|
102
|
-
doc = JSON.parse(params[:data], symbolize_names: true)
|
103
|
-
end
|
104
|
-
post :update, params: { resources_json_upload: { json: json }, exhibit_id: exhibit }
|
105
|
-
|
106
|
-
expect(response).to redirect_to exhibit_resources_path(exhibit)
|
107
|
-
expect(doc.first).to include a: 1
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def post_update_with_json_body(exhibit, hash)
|
114
|
-
post :update, body: hash.to_json, params: { exhibit_id: exhibit }, as: :json
|
115
|
-
end
|
116
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::TagsController, type: :controller do
|
4
|
-
include ActiveJob::TestHelper
|
5
|
-
|
6
|
-
routes { Spotlight::Engine.routes }
|
7
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
exhibit.tag(SolrDocument.new(id: 'x').sidecar(exhibit), with: 'paris, normandy', on: :tags)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'when not signed in' do
|
14
|
-
describe 'GET index' do
|
15
|
-
it 'redirects to sign inl' do
|
16
|
-
get :index, params: { exhibit_id: exhibit }
|
17
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'when signed in as a curator' do
|
23
|
-
before { sign_in FactoryBot.create(:exhibit_curator, exhibit: exhibit) }
|
24
|
-
|
25
|
-
describe 'GET index' do
|
26
|
-
it 'is successful' do
|
27
|
-
expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
|
28
|
-
expect(controller).to receive(:add_breadcrumb).with('Curation', exhibit_dashboard_path(exhibit))
|
29
|
-
expect(controller).to receive(:add_breadcrumb).with('Tags', exhibit_tags_path(exhibit))
|
30
|
-
get :index, params: { exhibit_id: exhibit }
|
31
|
-
expect(response).to be_successful
|
32
|
-
expect(assigns[:tags].length).to eq 2
|
33
|
-
expect(assigns[:tags].map(&:name)).to match_array %w[paris normandy]
|
34
|
-
expect(assigns[:exhibit]).to eq exhibit
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'has a json serialization' do
|
38
|
-
get :index, params: { exhibit_id: exhibit, format: 'json' }
|
39
|
-
expect(response).to be_successful
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'DELETE destroy' do
|
44
|
-
let!(:tagging) { FactoryBot.create(:tagging, tagger: exhibit, taggable: exhibit) }
|
45
|
-
|
46
|
-
it 'is successful' do
|
47
|
-
expect do
|
48
|
-
perform_enqueued_jobs do
|
49
|
-
delete :destroy, params: { exhibit_id: exhibit, id: tagging.tag }
|
50
|
-
end
|
51
|
-
end.to change(ActsAsTaggableOn::Tagging, :count).by(-1)
|
52
|
-
expect(response).to redirect_to exhibit_tags_path(exhibit)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|