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,70 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::LanguagesController do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
|
6
|
-
describe '#create' do
|
7
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
8
|
-
|
9
|
-
context 'when not signed in' do
|
10
|
-
it 'is not successful' do
|
11
|
-
post :create, params: { exhibit_id: exhibit, language: { locale: 'es' } }
|
12
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'when signed in as a site admin' do
|
17
|
-
before { sign_in user }
|
18
|
-
|
19
|
-
let(:user) { FactoryBot.create(:site_admin) }
|
20
|
-
|
21
|
-
it 'is successful' do
|
22
|
-
post :create, params: { exhibit_id: exhibit, language: { locale: 'es' } }
|
23
|
-
expect(response).to redirect_to edit_exhibit_path(exhibit, tab: 'language')
|
24
|
-
expect(assigns[:exhibit].languages.first.locale).to eq 'es'
|
25
|
-
expect(flash[:notice]).to eq 'The language was created.'
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'validates language params' do
|
29
|
-
post :create, params: { exhibit_id: exhibit, language: { locale: nil } }
|
30
|
-
expect(response).to redirect_to edit_exhibit_path(exhibit, tab: 'language')
|
31
|
-
expect(flash[:alert]).to include "Language can't be blank"
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'creates a published home page for the language' do
|
35
|
-
expect(Spotlight::HomePage.for_locale('es')).to be_blank
|
36
|
-
|
37
|
-
post :create, params: { exhibit_id: exhibit, language: { locale: 'es' } }
|
38
|
-
locale_pages = Spotlight::HomePage.for_locale('es')
|
39
|
-
expect(locale_pages.length).to eq 1
|
40
|
-
expect(locale_pages.first.exhibit).to eq exhibit
|
41
|
-
expect(locale_pages.first).to be_published
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#destroy' do
|
47
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
48
|
-
let(:language) { FactoryBot.create(:language, exhibit: exhibit) }
|
49
|
-
|
50
|
-
context 'when not signed in' do
|
51
|
-
it 'is not successful' do
|
52
|
-
delete :destroy, params: { exhibit_id: exhibit, id: language }
|
53
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'when signed in as a site admin' do
|
58
|
-
before { sign_in user }
|
59
|
-
|
60
|
-
let(:user) { FactoryBot.create(:site_admin) }
|
61
|
-
|
62
|
-
it 'is successful' do
|
63
|
-
delete :destroy, params: { exhibit_id: exhibit, id: language }
|
64
|
-
expect(response).to redirect_to edit_exhibit_path(exhibit, tab: 'language')
|
65
|
-
expect(assigns[:exhibit].languages.count).to eq 0
|
66
|
-
expect(flash[:notice]).to eq 'The language was deleted.'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::MetadataConfigurationsController, 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 show' do
|
13
|
-
it 'denies access' do
|
14
|
-
get :show, 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
|
-
|
20
|
-
describe 'GET edit' do
|
21
|
-
it 'denies access' do
|
22
|
-
get :edit, params: { exhibit_id: exhibit }
|
23
|
-
expect(response).to redirect_to main_app.root_path
|
24
|
-
expect(flash[:alert]).to be_present
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'when not logged in' do
|
30
|
-
describe 'PATCH update' do
|
31
|
-
it 'denies access' do
|
32
|
-
patch :update, params: { exhibit_id: exhibit }
|
33
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'GET edit' do
|
38
|
-
it 'denies access' do
|
39
|
-
get :edit, params: { exhibit_id: exhibit }
|
40
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'when signed in' do
|
46
|
-
let(:user) { FactoryBot.create(:exhibit_admin, exhibit: exhibit) }
|
47
|
-
|
48
|
-
before { sign_in user }
|
49
|
-
|
50
|
-
describe 'GET edit' do
|
51
|
-
it 'is successful' do
|
52
|
-
expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
|
53
|
-
expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
|
54
|
-
expect(controller).to receive(:add_breadcrumb).with('Metadata', edit_exhibit_metadata_configuration_path(exhibit))
|
55
|
-
get :edit, params: { exhibit_id: exhibit }
|
56
|
-
expect(response).to be_successful
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'GET show' do
|
61
|
-
it 'is successful' do
|
62
|
-
get :show, params: { exhibit_id: exhibit, format: 'json' }
|
63
|
-
expect(response).to be_successful
|
64
|
-
expect(JSON.parse(response.body).keys).to eq exhibit.blacklight_config.index_fields.keys
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe 'PATCH update' do
|
69
|
-
it 'updates metadata fields' do
|
70
|
-
blacklight_config = Blacklight::Configuration.new
|
71
|
-
blacklight_config.add_index_field %w[a b c d e f]
|
72
|
-
allow(::CatalogController).to receive_messages(blacklight_config: blacklight_config)
|
73
|
-
patch :update, params: {
|
74
|
-
exhibit_id: exhibit,
|
75
|
-
blacklight_configuration: {
|
76
|
-
index_fields: {
|
77
|
-
c: { enabled: true, show: true },
|
78
|
-
d: { enabled: true, show: true },
|
79
|
-
e: { enabled: true, list: true },
|
80
|
-
f: { enabled: true, list: true }
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
expect(flash[:notice]).to eq 'The exhibit was successfully updated.'
|
86
|
-
expect(response).to redirect_to edit_exhibit_metadata_configuration_path(exhibit)
|
87
|
-
assigns[:exhibit].tap do |saved|
|
88
|
-
expect(saved.blacklight_configuration.index_fields).to include 'c', 'd', 'e', 'f'
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::PagesController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
|
-
let(:feature_page) { FactoryBot.create(:feature_page, exhibit: exhibit, published: false) }
|
7
|
-
let(:about_page) { FactoryBot.create(:about_page, exhibit: exhibit, published: false) }
|
8
|
-
let(:update_all_params) do
|
9
|
-
{
|
10
|
-
exhibit: {
|
11
|
-
pages_attributes: {
|
12
|
-
0 => {
|
13
|
-
id: feature_page.id,
|
14
|
-
published: 1
|
15
|
-
},
|
16
|
-
1 => {
|
17
|
-
id: about_page.id,
|
18
|
-
published: 1
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'when signed in as a curator' do
|
26
|
-
let(:user) { FactoryBot.create(:exhibit_curator, exhibit: exhibit) }
|
27
|
-
|
28
|
-
before do
|
29
|
-
sign_in user
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'the feature and about pages are updated' do
|
33
|
-
expect(Spotlight::Page.find(feature_page.id)).not_to be_published
|
34
|
-
expect(Spotlight::Page.find(about_page.id)).not_to be_published
|
35
|
-
put :update_all, params: update_all_params.merge(exhibit_id: exhibit.id)
|
36
|
-
expect(Spotlight::Page.find(feature_page.id)).to be_published
|
37
|
-
expect(Spotlight::Page.find(about_page.id)).to be_published
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'when user is not authenticated' do
|
42
|
-
it 'does not allow publishing pages' do
|
43
|
-
put :update_all, params: update_all_params.merge(exhibit_id: exhibit.id)
|
44
|
-
expect(Spotlight::Page.find(feature_page.id)).not_to be_published
|
45
|
-
expect(Spotlight::Page.find(about_page.id)).not_to be_published
|
46
|
-
expect(flash['alert']).to eq 'You need to sign in or sign up before continuing.'
|
47
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Resources::CsvUploadController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
|
-
|
7
|
-
describe 'when not logged in' do
|
8
|
-
describe 'POST create' do
|
9
|
-
it 'is not allowed' do
|
10
|
-
post :create, params: { exhibit_id: exhibit }
|
11
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'when signed in as a curator' do
|
17
|
-
let(:user) { FactoryBot.create(:exhibit_curator, exhibit: exhibit) }
|
18
|
-
|
19
|
-
before { sign_in user }
|
20
|
-
|
21
|
-
describe 'POST create' do
|
22
|
-
let(:csv) { fixture_file_upload(File.expand_path(File.join('..', 'spec', 'fixtures', 'csv-upload-fixture.csv'), Rails.root), 'text/csv') }
|
23
|
-
let(:serialized_csv) do
|
24
|
-
[
|
25
|
-
{
|
26
|
-
'url' => 'http://lorempixel.com/800/500/',
|
27
|
-
'full_title_tesim' => 'A random image',
|
28
|
-
'spotlight_upload_description_tesim' => 'A random 800 by 500 image from lorempixel',
|
29
|
-
'spotlight_upload_attribution_tesim' => 'lorempixel.com',
|
30
|
-
'spotlight_upload_date_tesim' => '2015'
|
31
|
-
},
|
32
|
-
{
|
33
|
-
'url' => 'http://lorempixel.com/900/600/',
|
34
|
-
'full_title_tesim' => 'Another random image',
|
35
|
-
'spotlight_upload_description_tesim' => 'A random 900 by 600 image from lorempixel',
|
36
|
-
'spotlight_upload_attribution_tesim' => 'lorempixel.com',
|
37
|
-
'spotlight_upload_date_tesim' => '2014'
|
38
|
-
},
|
39
|
-
{
|
40
|
-
'url' => 'http://lorempixel.com/900/600/',
|
41
|
-
'full_title_tesim' => 'Yet another random image to test UTF8 text',
|
42
|
-
'spotlight_upload_description_tesim' => 'A random 900 by 600 image from lorempixel and some UTF8: Hüsker Dü',
|
43
|
-
'spotlight_upload_attribution_tesim' => 'lorempixel.com',
|
44
|
-
'spotlight_upload_date_tesim' => '2016'
|
45
|
-
}
|
46
|
-
]
|
47
|
-
end
|
48
|
-
|
49
|
-
before do
|
50
|
-
request.env['HTTP_REFERER'] = 'http://test.host/'
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'starts an AddUploadsFromCsv job with the serialized CSV' do
|
54
|
-
expect(Spotlight::AddUploadsFromCsv).to receive(:perform_later).with(serialized_csv, exhibit, user).and_return(nil)
|
55
|
-
post :create, params: { exhibit_id: exhibit, resources_csv_upload: { url: csv } }
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'sets the flash message' do
|
59
|
-
expect(Spotlight::AddUploadsFromCsv).to receive(:perform_later).and_return(nil)
|
60
|
-
post :create, params: { exhibit_id: exhibit, resources_csv_upload: { url: csv } }
|
61
|
-
expect(flash[:notice]).to eq "'csv-upload-fixture.csv' has been uploaded. An email will be sent to you once indexing is complete."
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'redirects back' do
|
65
|
-
expect(Spotlight::AddUploadsFromCsv).to receive(:perform_later).and_return(nil)
|
66
|
-
post :create, params: { exhibit_id: exhibit, resources_csv_upload: { url: csv } }
|
67
|
-
expect(response).to redirect_to "http://test.host/spotlight/#{exhibit.slug}/catalog/admin"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Resources::UploadController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
|
-
|
7
|
-
describe 'when not logged in' do
|
8
|
-
describe 'POST create' do
|
9
|
-
it 'is not allowed' do
|
10
|
-
post :create, params: { exhibit_id: exhibit }
|
11
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'when signed in as a curator' do
|
17
|
-
let(:user) { FactoryBot.create(:exhibit_curator, exhibit: exhibit) }
|
18
|
-
|
19
|
-
before { sign_in user }
|
20
|
-
|
21
|
-
describe 'POST create' do
|
22
|
-
let(:blacklight_solr) { double }
|
23
|
-
|
24
|
-
before do
|
25
|
-
allow_any_instance_of(Spotlight::Resource).to receive(:reindex).and_return(true)
|
26
|
-
allow_any_instance_of(Spotlight::Resource).to receive(:blacklight_solr).and_return blacklight_solr
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'create a Spotlight::Resources::Upload resource' do
|
30
|
-
expect_any_instance_of(Spotlight::Resource).to receive(:reindex_later)
|
31
|
-
post :create, params: { exhibit_id: exhibit, resources_upload: { url: 'url-data' } }
|
32
|
-
expect(assigns[:resource]).to be_persisted
|
33
|
-
expect(assigns[:resource]).to be_a(Spotlight::Resources::Upload)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'redirects to the item admin page' do
|
37
|
-
post :create, params: { exhibit_id: exhibit, resources_upload: { url: 'url-data' } }
|
38
|
-
expect(flash[:notice]).to eq 'Object uploaded successfully.'
|
39
|
-
expect(response).to redirect_to admin_exhibit_catalog_path(exhibit, sort: :timestamp)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'redirects to the upload form when the add-and-continue parameter is present' do
|
43
|
-
post :create, params: { exhibit_id: exhibit, 'add-and-continue' => 'true', resources_upload: { url: 'url-data' } }
|
44
|
-
expect(flash[:notice]).to eq 'Object uploaded successfully.'
|
45
|
-
expect(response).to redirect_to new_exhibit_resource_path(exhibit, tab: 'upload')
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'can add multivalued fields' do
|
49
|
-
field = FactoryBot.create(:custom_field, exhibit: exhibit, is_multiple: true)
|
50
|
-
post :create, params: { exhibit_id: exhibit, resources_upload: { data: { field.slug => %w[1 2 3] } } }
|
51
|
-
expect(assigns[:resource].sidecar.data).to include(field.slug => %w[1 2 3])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::ResourcesController, type: :controller do
|
4
|
-
routes { Spotlight::Engine.routes }
|
5
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
|
-
|
7
|
-
describe 'when not logged in' do
|
8
|
-
describe 'GET new' do
|
9
|
-
it 'is not allowed' do
|
10
|
-
get :new, params: { exhibit_id: exhibit }
|
11
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'GET monitor' do
|
16
|
-
it 'is not allowed' do
|
17
|
-
get :monitor, params: { exhibit_id: exhibit }
|
18
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'POST create' do
|
23
|
-
it 'is not allowed' do
|
24
|
-
post :create, params: { exhibit_id: exhibit }
|
25
|
-
expect(response).to redirect_to main_app.new_user_session_path
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'POST reindex_all' do
|
30
|
-
it 'is not allowed' do
|
31
|
-
post :reindex_all, 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 as a curator' do
|
38
|
-
let(:user) { FactoryBot.create(:exhibit_curator, exhibit: exhibit) }
|
39
|
-
|
40
|
-
before { sign_in user }
|
41
|
-
|
42
|
-
describe 'GET new' do
|
43
|
-
it 'renders form' do
|
44
|
-
get :new, params: { exhibit_id: exhibit }
|
45
|
-
expect(response).to render_template 'spotlight/resources/new'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'GET monitor' do
|
50
|
-
it 'succesfully renders json' do
|
51
|
-
get :monitor, params: { exhibit_id: exhibit }
|
52
|
-
expect(response).to be_successful
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'POST create' do
|
57
|
-
let(:blacklight_solr) { double }
|
58
|
-
let(:invalid_resource) { Spotlight::Resource.new.tap { |x| x.errors.add(:url, 'is invalid') } }
|
59
|
-
|
60
|
-
it 'create a resource' do
|
61
|
-
expect_any_instance_of(Spotlight::Resource).to receive(:reindex_later).and_return(true)
|
62
|
-
allow_any_instance_of(Spotlight::Resource).to receive(:blacklight_solr).and_return blacklight_solr
|
63
|
-
post :create, params: { exhibit_id: exhibit, resource: { url: 'info:uri' } }
|
64
|
-
expect(assigns[:resource]).to be_persisted
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'adds errors to the flash message' do
|
68
|
-
allow_any_instance_of(Spotlight::Resource).to receive_messages(save: false)
|
69
|
-
allow_any_instance_of(Spotlight::Resource).to receive(:errors).and_return invalid_resource.errors
|
70
|
-
post :create, params: { exhibit_id: exhibit, resource: { url: 'info:uri' } }
|
71
|
-
expect(assigns[:resource]).not_to be_persisted
|
72
|
-
expect(flash[:error]).to include 'Url is invalid'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe 'POST reindex_all' do
|
77
|
-
it 'triggers a reindex' do
|
78
|
-
expect_any_instance_of(Spotlight::Exhibit).to receive(:reindex_later)
|
79
|
-
post :reindex_all, params: { exhibit_id: exhibit }
|
80
|
-
expect(response).to redirect_to admin_exhibit_catalog_path(exhibit)
|
81
|
-
expect(flash[:notice]).to include 'Reindexing'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,141 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::RolesController, 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 'GET index' do
|
11
|
-
it 'denies access' do
|
12
|
-
get :index, 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(:exhibit_admin, exhibit: exhibit) }
|
20
|
-
let(:user) { FactoryBot.create(:user) }
|
21
|
-
let(:role) { admin.roles.first }
|
22
|
-
|
23
|
-
before { sign_in admin }
|
24
|
-
|
25
|
-
it 'allows index' do
|
26
|
-
expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
|
27
|
-
expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
|
28
|
-
expect(controller).to receive(:add_breadcrumb).with('Users', exhibit_roles_path(exhibit))
|
29
|
-
get :index, params: { exhibit_id: exhibit }
|
30
|
-
expect(response).to be_successful
|
31
|
-
expect(assigns[:roles].to_a).to eq [admin.roles.first]
|
32
|
-
end
|
33
|
-
|
34
|
-
describe 'PATCH update_all' do
|
35
|
-
it 'creates new roles' do
|
36
|
-
patch :update_all, params: {
|
37
|
-
exhibit_id: exhibit,
|
38
|
-
'exhibit' => {
|
39
|
-
'roles_attributes' => {
|
40
|
-
'0' => { 'role' => 'curator', 'user_key' => user.email }
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
expect(exhibit.roles.last.role).to eq 'curator'
|
46
|
-
expect(exhibit.roles.last.user.email).to eq user.email
|
47
|
-
expect(flash[:notice]).to eq 'User has been updated.'
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'invites new users' do
|
51
|
-
expect do
|
52
|
-
patch :update_all, params: {
|
53
|
-
exhibit_id: exhibit,
|
54
|
-
'exhibit' => {
|
55
|
-
'roles_attributes' => {
|
56
|
-
'0' => { 'role' => 'curator', 'user_key' => 'something@example.com' }
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
60
|
-
end.to change { Devise::Mailer.deliveries.count }.by(1)
|
61
|
-
|
62
|
-
expect(exhibit.roles.last.user.email).to eq 'something@example.com'
|
63
|
-
expect(exhibit.roles.last.user.invitation_sent_at).to be_present
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'updates roles' do
|
67
|
-
patch :update_all, params: {
|
68
|
-
exhibit_id: exhibit,
|
69
|
-
'exhibit' => {
|
70
|
-
'roles_attributes' => {
|
71
|
-
'0' => { 'role' => 'curator', 'id' => role.id }
|
72
|
-
}
|
73
|
-
}
|
74
|
-
}
|
75
|
-
expect(response).to redirect_to exhibit_roles_path(exhibit)
|
76
|
-
expect(flash[:notice]).to eq 'User has been updated.'
|
77
|
-
|
78
|
-
admin.reload
|
79
|
-
|
80
|
-
expect(admin.roles.first.role).to eq 'curator'
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'ignores empty roles' do
|
84
|
-
expect do
|
85
|
-
patch :update_all, params: {
|
86
|
-
exhibit_id: exhibit,
|
87
|
-
'exhibit' => {
|
88
|
-
'roles_attributes' => {
|
89
|
-
'0' => { 'user_key' => '', 'role' => '' }
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
end.not_to change { exhibit.roles.length }
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'authorizes records' do
|
97
|
-
allow(controller).to receive(:authorize!).and_raise(CanCan::AccessDenied)
|
98
|
-
patch :update_all, params: {
|
99
|
-
exhibit_id: exhibit,
|
100
|
-
'exhibit' => {
|
101
|
-
'roles_attributes' => {
|
102
|
-
'0' => { 'role' => 'curator', 'id' => role.id }
|
103
|
-
}
|
104
|
-
}
|
105
|
-
}
|
106
|
-
expect(response).to redirect_to main_app.root_path
|
107
|
-
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
|
108
|
-
expect(admin.reload.roles.first.role).to eq 'admin'
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'destroys records' do
|
112
|
-
patch :update_all, params: {
|
113
|
-
exhibit_id: exhibit,
|
114
|
-
'exhibit' => {
|
115
|
-
'roles_attributes' => {
|
116
|
-
'0' => { 'role' => 'curator', 'id' => role.id, '_destroy' => '1' }
|
117
|
-
}
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
expect(response).to redirect_to exhibit_roles_path(exhibit)
|
122
|
-
expect(admin.reload.roles).to be_empty
|
123
|
-
expect(flash[:notice]).to eq 'User has been removed.'
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'handles failure' do
|
127
|
-
allow_any_instance_of(Spotlight::Exhibit).to receive_messages(update: false)
|
128
|
-
patch :update_all, params: {
|
129
|
-
exhibit_id: exhibit,
|
130
|
-
'exhibit' => {
|
131
|
-
'roles_attributes' => {
|
132
|
-
'0' => { 'role' => 'curator', 'id' => role.id }
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
136
|
-
expect(response).to be_successful
|
137
|
-
expect(flash[:alert]).to eq 'There was a problem saving the user.'
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|