blacklight-spotlight 3.4.0 → 3.4.2.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 -579
- 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/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/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,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
def tag_names(exhibit, id)
|
4
|
-
exhibit.blacklight_config.repository.find(id).documents.first.sidecar(exhibit).taggings.includes(:tag).map { |tagging| tagging&.tag&.name }
|
5
|
-
end
|
6
|
-
|
7
|
-
describe Spotlight::ProcessBulkUpdatesCsvJob do
|
8
|
-
subject { described_class.new(exhibit, bulk_update) }
|
9
|
-
|
10
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
11
|
-
|
12
|
-
describe 'visibility' do
|
13
|
-
let(:bulk_update) { FactoryBot.create(:bulk_update, exhibit: exhibit) }
|
14
|
-
|
15
|
-
it 'is updated' do
|
16
|
-
allow(SolrDocument.index.connection).to receive(:update).and_call_original
|
17
|
-
expect(exhibit.blacklight_config.repository.find('dq287tq6352').documents.first).not_to be_private(exhibit)
|
18
|
-
|
19
|
-
subject.perform_now
|
20
|
-
|
21
|
-
expect(exhibit.blacklight_config.repository.find('dq287tq6352').documents.first).to be_private(exhibit)
|
22
|
-
expect(SolrDocument.index.connection).to have_received(:update)
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with a row that does not change visibility' do
|
26
|
-
before do
|
27
|
-
sidecar = exhibit.solr_document_sidecars.find_or_create_by(document_type: 'SolrDocument', document_id: 'dq287tq6352')
|
28
|
-
sidecar.private!
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'does not update solr' do
|
32
|
-
allow(SolrDocument.index.connection).to receive(:update)
|
33
|
-
|
34
|
-
subject.perform_now
|
35
|
-
|
36
|
-
expect(SolrDocument.index.connection).not_to have_received(:update)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'without a visibility column' do
|
41
|
-
let(:bulk_update) { FactoryBot.create(:bulk_update_no_cols, exhibit: exhibit) }
|
42
|
-
|
43
|
-
it 'does nothing with the data' do
|
44
|
-
expect { subject.perform_now }.not_to(change { exhibit.reload.solr_document_sidecars.where(public: false).count })
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'tags' do
|
50
|
-
let(:bulk_update) { FactoryBot.create(:tagged_bulk_update, exhibit: exhibit) }
|
51
|
-
|
52
|
-
before do
|
53
|
-
document = exhibit.blacklight_config.repository.find('cz507zk0531').documents.first
|
54
|
-
exhibit.tag(document.sidecar(exhibit), with: 'CSV Tag1', on: :tags)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'are added/removed' do
|
58
|
-
allow(SolrDocument.index.connection).to receive(:update).and_call_original
|
59
|
-
expect(tag_names(exhibit, 'bm387cy2596')).to be_empty
|
60
|
-
expect(tag_names(exhibit, 'cz507zk0531')).to eq(['CSV Tag1'])
|
61
|
-
expect(tag_names(exhibit, 'dq287tq6352')).to be_empty
|
62
|
-
subject.perform_now
|
63
|
-
expect(tag_names(exhibit, 'bm387cy2596')).to eq(['CSV Tag1', 'CSV Tag2'])
|
64
|
-
expect(tag_names(exhibit, 'cz507zk0531')).to eq(['CSV Tag2'])
|
65
|
-
expect(tag_names(exhibit, 'dq287tq6352')).to eq(['CSV Tag1', 'CSV Tag2'])
|
66
|
-
|
67
|
-
# 3 updates plus the final commit
|
68
|
-
expect(SolrDocument.index.connection).to have_received(:update).exactly(4).times
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'with a row that does not change visibility' do
|
72
|
-
before do
|
73
|
-
# set up the documents to match what's the in the spreadsheet already
|
74
|
-
subject.perform_now
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'does not update solr' do
|
78
|
-
allow(SolrDocument.index.connection).to receive(:update)
|
79
|
-
|
80
|
-
subject.perform_now
|
81
|
-
|
82
|
-
expect(SolrDocument.index.connection).not_to have_received(:update)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::ReindexExhibitJob do
|
4
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
-
|
6
|
-
before do
|
7
|
-
FactoryBot.create_list(:resource, 10, exhibit: exhibit)
|
8
|
-
allow(Spotlight::ReindexJob).to receive(:perform_now)
|
9
|
-
allow(Spotlight::ReindexJob).to receive(:perform_later)
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'with a single batch' do
|
13
|
-
it 'runs the index job inline' do
|
14
|
-
described_class.perform_now(exhibit, batch_count: 1)
|
15
|
-
|
16
|
-
expect(Spotlight::ReindexJob).to have_received(:perform_now).once.with(exhibit, anything)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with a fixed batch count' do
|
21
|
-
it 'enqueues that number of batches' do
|
22
|
-
described_class.perform_now(exhibit, batch_count: 2)
|
23
|
-
|
24
|
-
expect(Spotlight::ReindexJob).to have_received(:perform_later).twice.with(exhibit, hash_including(:start, :finish))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'with a dynamically generated batch count' do
|
29
|
-
it 'enqueues the right number of batches' do
|
30
|
-
described_class.perform_now(exhibit, batch_count: nil, batch_size: 2)
|
31
|
-
|
32
|
-
expect(Spotlight::ReindexJob).to have_received(:perform_later).exactly(5).times.with(exhibit, hash_including(:start, :finish))
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with a dynamically generated batch size' do
|
37
|
-
it 'figues out that number of batches' do
|
38
|
-
described_class.perform_now(exhibit, batch_count: nil, batch_size: nil)
|
39
|
-
|
40
|
-
expect(Spotlight::ReindexJob).to have_received(:perform_later).exactly(3).times.with(exhibit, hash_including(:start, :finish))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::ReindexJob do
|
4
|
-
include ActiveJob::TestHelper
|
5
|
-
|
6
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
|
-
let(:resource) { FactoryBot.create(:resource, exhibit: exhibit) }
|
8
|
-
let(:user) { FactoryBot.create(:user) }
|
9
|
-
|
10
|
-
before do
|
11
|
-
allow_any_instance_of(Spotlight::Resource).to receive(:reindex)
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'with a resource' do
|
15
|
-
subject { described_class.new(resource) }
|
16
|
-
|
17
|
-
it 'attempts to reindex every resource in the exhibit' do
|
18
|
-
expect(resource).to receive(:reindex)
|
19
|
-
subject.perform_now
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'adds some job tracking events' do
|
23
|
-
expect { subject.perform_now }.to change(Spotlight::Event, :count).by(1)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'validity' do
|
28
|
-
subject { described_class.new(resource, 'validity_token' => 'xyz') }
|
29
|
-
|
30
|
-
let(:mock_checker) { instance_double(Spotlight::ValidityChecker) }
|
31
|
-
|
32
|
-
before do
|
33
|
-
allow(described_class).to receive(:validity_checker).and_return(mock_checker)
|
34
|
-
allow(mock_checker).to receive(:mint).with(anything).and_return('xyz')
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'mints a new validity token' do
|
38
|
-
expect { described_class.perform_later(resource) }.to have_enqueued_job(described_class).with(resource, 'validity_token' => 'xyz')
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'does nothing if the token is no longer valid' do
|
42
|
-
allow(mock_checker).to receive(:check).with(subject, validity_token: 'xyz').and_return(false)
|
43
|
-
expect(resource).not_to receive(:reindex)
|
44
|
-
|
45
|
-
subject.perform_now
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'indexes the resource if the token is valid' do
|
49
|
-
allow(mock_checker).to receive(:check).with(subject, validity_token: 'xyz').and_return(true)
|
50
|
-
expect(resource).to receive(:reindex)
|
51
|
-
|
52
|
-
subject.perform_now
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with start and finish' do
|
57
|
-
it 'indexes the resources within that page' do
|
58
|
-
count = 0
|
59
|
-
allow_any_instance_of(Spotlight::Resource).to receive(:reindex) do
|
60
|
-
count += 1
|
61
|
-
end
|
62
|
-
|
63
|
-
described_class.perform_now(exhibit, start: 0, finish: resource.id)
|
64
|
-
|
65
|
-
expect(count).to eq 1
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'does not index resources off that page' do
|
69
|
-
count = 0
|
70
|
-
allow_any_instance_of(Spotlight::Resource).to receive(:reindex) do
|
71
|
-
count += 1
|
72
|
-
end
|
73
|
-
|
74
|
-
described_class.perform_now(exhibit, start: resource.id + 1, finish: resource.id + 500)
|
75
|
-
|
76
|
-
expect(count).to eq 0
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::RemoveTagsJob do
|
4
|
-
subject { described_class.new(solr_params: solr_params, exhibit: exhibit, tags: tags) }
|
5
|
-
|
6
|
-
let(:solr_params) { { q: 'map' } }
|
7
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
8
|
-
let(:tags) { %w[hello world] }
|
9
|
-
|
10
|
-
before do
|
11
|
-
allow(Spotlight::Engine.config).to receive_messages(bulk_actions_batch_size: 5)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'removes tags from SolrDocumentSidecar objects' do
|
15
|
-
response = exhibit.blacklight_config.repository.search(solr_params.merge('rows' => 999_999_999))
|
16
|
-
expect(response.total).to eq 55
|
17
|
-
response.documents.each do |document|
|
18
|
-
exhibit.tag(document.sidecar(exhibit), with: %w[hello world], on: :tags)
|
19
|
-
document.reindex
|
20
|
-
end
|
21
|
-
subject.perform_now
|
22
|
-
response = exhibit.blacklight_config.repository.search(solr_params.merge('rows' => 999_999_999))
|
23
|
-
expect(response.total).to eq 55
|
24
|
-
expect(Spotlight::JobTracker.last).to have_attributes(
|
25
|
-
status: 'completed',
|
26
|
-
total: 55,
|
27
|
-
progress: 55,
|
28
|
-
job_class: 'Spotlight::RemoveTagsJob'
|
29
|
-
)
|
30
|
-
response.documents.each do |document|
|
31
|
-
expect(document.sidecar(exhibit).all_tags_list).to eq []
|
32
|
-
end
|
33
|
-
exhibit.owned_tags.destroy_all
|
34
|
-
response.documents.each do |document|
|
35
|
-
document.sidecar(exhibit).destroy
|
36
|
-
document.reindex
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::RenameSidecarFieldJob do
|
4
|
-
include ActiveJob::TestHelper
|
5
|
-
|
6
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
|
-
let(:sidecar) { SolrDocument.new(id: 'test').sidecar(exhibit).tap(&:save!) }
|
8
|
-
|
9
|
-
it 'updates the sidecar data and reindex affected documents' do
|
10
|
-
expect_any_instance_of(::SolrDocument).to receive(:reindex)
|
11
|
-
|
12
|
-
sidecar.data['old_field'] = 'some value'
|
13
|
-
sidecar.save!
|
14
|
-
|
15
|
-
perform_enqueued_jobs do
|
16
|
-
described_class.perform_later(exhibit, 'old_field', 'new_field')
|
17
|
-
end
|
18
|
-
|
19
|
-
sidecar.reload
|
20
|
-
expect(sidecar.data['new_field']).to eq 'some value'
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'does not touch unaffected documents' do
|
24
|
-
expect_any_instance_of(::SolrDocument).not_to receive(:reindex)
|
25
|
-
|
26
|
-
sidecar.data['other_field'] = 'some value'
|
27
|
-
sidecar.save!
|
28
|
-
|
29
|
-
perform_enqueued_jobs do
|
30
|
-
described_class.perform_later(exhibit, 'old_field', 'new_field')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'migration/iiif'
|
4
|
-
|
5
|
-
RSpec.describe Migration::IIIF do
|
6
|
-
let(:instance) { described_class.new('http://test.host') }
|
7
|
-
|
8
|
-
describe '#migrate_featured_images' do
|
9
|
-
let!(:old_exhibit_thumbnail) { FactoryBot.create(:featured_image, type: nil, iiif_tilesource: nil) }
|
10
|
-
let!(:exhibit) { FactoryBot.create(:exhibit, thumbnail_id: old_exhibit_thumbnail.id) }
|
11
|
-
let(:updated_thumb) { Spotlight::FeaturedImage.find(old_exhibit_thumbnail.id) }
|
12
|
-
|
13
|
-
context "when it's an exhibit thumbnail" do
|
14
|
-
it 'migrates to an ExhibitThumbnail class and stores the image in the correct directory' do
|
15
|
-
instance.run
|
16
|
-
expect(updated_thumb.class).to eq Spotlight::ExhibitThumbnail
|
17
|
-
expect(Spotlight::Exhibit.find(exhibit.id).thumbnail).to eq updated_thumb
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'stores the image in the correct directory for the ExhibitThumbnail class' do
|
21
|
-
instance.run
|
22
|
-
expect(updated_thumb.image.file.file).to match(%r{/spotlight/exhibit_thumbnail/image/#{old_exhibit_thumbnail.id}})
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when it's any FeaturedImage" do
|
27
|
-
it 'updates the iiif_tilesource attribute based on the given host and image resource' do
|
28
|
-
instance.run
|
29
|
-
expect(updated_thumb.iiif_tilesource).to match %r{http://test.host/images/#{updated_thumb.id}-.*/info.json}
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns a nil region if one was not set' do
|
33
|
-
instance.run
|
34
|
-
expect(updated_thumb.iiif_region).to be_nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'updates the iiif_region attribute based on the legacy crop coordinates' do
|
38
|
-
old_exhibit_thumbnail.image_crop_x = '1'
|
39
|
-
old_exhibit_thumbnail.image_crop_y = '1'
|
40
|
-
old_exhibit_thumbnail.image_crop_w = '400'
|
41
|
-
old_exhibit_thumbnail.image_crop_h = '400'
|
42
|
-
old_exhibit_thumbnail.save
|
43
|
-
|
44
|
-
instance.run
|
45
|
-
expect(updated_thumb.iiif_region).to eq '1,1,400,400'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#migrate_upload_images' do
|
51
|
-
let(:file) { double }
|
52
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
53
|
-
let!(:upload) { Spotlight::Resources::Upload.create(exhibit: exhibit) }
|
54
|
-
|
55
|
-
before do
|
56
|
-
allow(File).to receive(:exist?).and_return(true)
|
57
|
-
allow(File).to receive(:new).and_return(file)
|
58
|
-
expect_any_instance_of(Spotlight::Resources::Upload).to receive('read_attribute_before_type_cast').with('url').and_return('file1.jpg')
|
59
|
-
# allow other calls (from rails 4)
|
60
|
-
allow_any_instance_of(Spotlight::Resources::Upload).to receive('read_attribute_before_type_cast').with(anything).and_call_original
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'migrates and saves' do
|
64
|
-
expect_any_instance_of(Spotlight::Resources::Upload).to receive(:save_and_index)
|
65
|
-
expect do
|
66
|
-
instance.send :migrate_upload_images
|
67
|
-
end.to change(Spotlight::FeaturedImage, :count).by(1)
|
68
|
-
expect(Spotlight::FeaturedImage.all.pluck(:id)).to include Spotlight::Resources::Upload.last.id
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '#migrate_contact_avatars' do
|
73
|
-
let(:file) { double }
|
74
|
-
let!(:contact1) { Spotlight::Contact.create }
|
75
|
-
|
76
|
-
before do
|
77
|
-
allow(File).to receive(:exist?).and_return(true)
|
78
|
-
allow(File).to receive(:new).and_return(file)
|
79
|
-
expect_any_instance_of(Spotlight::Contact).to receive('read_attribute_before_type_cast').with('avatar').and_return('file1.jpg')
|
80
|
-
# allow other calls (from rails 4)
|
81
|
-
allow_any_instance_of(Spotlight::Contact).to receive('read_attribute_before_type_cast').with(anything).and_call_original
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'migrates' do
|
85
|
-
expect do
|
86
|
-
instance.send :migrate_contact_avatars
|
87
|
-
end.to change(Spotlight::FeaturedImage, :count).by(1)
|
88
|
-
expect(Spotlight::Contact.all.pluck(:avatar_id)).to eq Spotlight::FeaturedImage.all.pluck(:id)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'migration/page_language'
|
4
|
-
|
5
|
-
RSpec.describe Migration::PageLanguage do
|
6
|
-
describe '#migrate_pages' do
|
7
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
8
|
-
let(:page) { FactoryBot.create(:feature_page, exhibit: exhibit) }
|
9
|
-
let(:slug) { FriendlyId::Slug.find(page.id) }
|
10
|
-
|
11
|
-
before do
|
12
|
-
# Remove the locale scope (anticipating pre translation state of scope)
|
13
|
-
slug.scope = slug.scope.sub(',locale:en', '')
|
14
|
-
slug.save
|
15
|
-
slug.reload
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'sets the scope to the default locale' do
|
19
|
-
expect(slug.scope).not_to include(',locale:en')
|
20
|
-
subject.run
|
21
|
-
slug.reload
|
22
|
-
expect(slug.scope).to eq "exhibit_id:#{page.exhibit.id},locale:en"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
File without changes
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Controller do
|
4
|
-
class MockController < ActionController::Base
|
5
|
-
include Spotlight::Controller
|
6
|
-
end
|
7
|
-
|
8
|
-
subject { MockController.new }
|
9
|
-
|
10
|
-
let(:params) { { action: 'show' } }
|
11
|
-
|
12
|
-
before do
|
13
|
-
allow(subject).to receive_messages(params: ActionController::Parameters.new(params))
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#current_exhibit' do
|
17
|
-
it 'is nil by default' do
|
18
|
-
expect(subject.current_exhibit).to be_nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#exhibit_masthead?' do
|
23
|
-
let(:masthead) { double('masthead', display?: true) }
|
24
|
-
|
25
|
-
before do
|
26
|
-
allow(subject).to receive_messages(current_exhibit: nil, current_masthead: nil)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'is false if there is no exhibit' do
|
30
|
-
expect(subject).not_to be_exhibit_masthead
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'is false if there is no custom exhibit masthead' do
|
34
|
-
allow(subject).to receive_messages(current_exhibit: double(masthead: nil), current_masthead: nil)
|
35
|
-
expect(subject).not_to be_exhibit_masthead
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'is true if there is an exhibit masthead, but it is not set to display' do
|
39
|
-
allow(subject).to receive_messages(current_exhibit: double(masthead: double(display?: false)))
|
40
|
-
expect(subject).not_to be_exhibit_masthead
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'is true if there is an exhibit masthead' do
|
44
|
-
allow(subject).to receive_messages(current_exhibit: double(masthead: double(display?: true)))
|
45
|
-
expect(subject).to be_exhibit_masthead
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#current_masthead' do
|
50
|
-
let(:search_masthead) { double('search-masthead', display?: true) }
|
51
|
-
let(:no_display_search_masthead) { double('no-display-search-masthead', display?: false) }
|
52
|
-
let(:exhibit_masthead) { double('exhibit-masthead', display?: true) }
|
53
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
54
|
-
let(:search) { FactoryBot.create(:search) }
|
55
|
-
|
56
|
-
it 'is nil by default' do
|
57
|
-
expect(subject.current_masthead).to be_nil
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'returns the exhibit masthead if available' do
|
61
|
-
allow(exhibit).to receive_messages(masthead: exhibit_masthead)
|
62
|
-
subject.instance_variable_set(:@exhibit, exhibit)
|
63
|
-
expect(subject.current_masthead).to eq exhibit_masthead
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'allows the masthead to be set' do
|
67
|
-
subject.current_masthead = search_masthead
|
68
|
-
expect(subject.current_masthead).to eq search_masthead
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'with a resource masthead' do
|
72
|
-
before do
|
73
|
-
allow(subject).to receive(:resource_masthead?).and_return(true)
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'checks if the current resource has a masthead' do
|
77
|
-
pending
|
78
|
-
expect(subject.current_masthead).to eq search_masthead
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '#resource_masthead?' do
|
84
|
-
it 'is false by default' do
|
85
|
-
expect(subject.resource_masthead?).to eq false
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe '#exhibit_search_facet_path' do
|
90
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
91
|
-
let(:params) { { action: 'index', q: 'xyz' } }
|
92
|
-
|
93
|
-
before do
|
94
|
-
allow(subject).to receive(:current_exhibit).and_return(exhibit)
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'adds the current exhibit context to the route' do
|
98
|
-
expect(subject.spotlight).to receive(:facet_exhibit_catalog_url).with(exhibit, id: 'some_field', q: 'xyz')
|
99
|
-
subject.exhibit_search_facet_path(id: 'some_field')
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Spotlight::UploadFieldConfig do
|
4
|
-
describe '#label' do
|
5
|
-
it 'accepts a proc and calls it' do
|
6
|
-
label = -> { 'returned string' }
|
7
|
-
expect(described_class.new(field_name: 'something', label: label).label).to eq 'returned string'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'returns any non-proc value' do
|
11
|
-
expect(described_class.new(field_name: 'something', label: 'String').label).to eq 'String'
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'falls back to the field name when no label is given' do
|
15
|
-
expect(described_class.new(field_name: 'something').label).to eq 'something'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#solr_field' do
|
20
|
-
it 'is an alias of the #solr_field method so it can be polymorphic with other Blacklight configurations' do
|
21
|
-
expect(described_class.new(field_name: 'something').solr_field).to eq 'something'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#solr_fields' do
|
26
|
-
it 'is backwards compatible with the old way of configuring fields' do
|
27
|
-
expect(described_class.new(field_name: 'something').solr_fields).to eq ['something']
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#data_to_solr' do
|
32
|
-
it 'returns a hash of the various solr fields mapped to the provided value' do
|
33
|
-
expect(described_class.new(field_name: 'something', solr_fields: %w[a b]).data_to_solr('value')).to eq 'a' => 'value', 'b' => 'value'
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'supports configuring a lambda to pre-process data for a field' do
|
37
|
-
expect(described_class.new(field_name: 'something', solr_fields: [int_field: ->(value) { value.to_i }]).data_to_solr('123value')).to eq int_field: 123
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::IndexingCompleteMailer do
|
4
|
-
subject { described_class.documents_indexed [1, 2, 3], exhibit, user, indexed_count: 3 }
|
5
|
-
|
6
|
-
let(:user) { double(email: 'test@example.com') }
|
7
|
-
let(:exhibit) { double(title: 'Exhibit title') }
|
8
|
-
|
9
|
-
it 'renders the receiver email' do
|
10
|
-
expect(subject.to).to eql([user.email])
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'includes a title' do
|
14
|
-
expect(subject.body.encoded).to match 'Your CSV file has just finished being processed'
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'describes how many documents were indexed' do
|
18
|
-
expect(subject.body.encoded).to match '3 documents'
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'single item' do
|
22
|
-
subject { described_class.documents_indexed [1], exhibit, user }
|
23
|
-
|
24
|
-
it 'handles pluralization when only a single item was indexed' do
|
25
|
-
expect(subject.body.encoded).to match '1 document has'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'includes the exhibit title' do
|
30
|
-
expect(subject.body.encoded).to match exhibit.title
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with errors' do
|
34
|
-
subject { described_class.documents_indexed [], exhibit, user, indexed_count: 0, errors: { 1 => ['missing title'], 20 => ['whatever'] } }
|
35
|
-
|
36
|
-
it 'includes some errors' do
|
37
|
-
expect(subject.body.encoded).to match 'Errors'
|
38
|
-
expect(subject.body.encoded).to match 'Row 1: missing title'
|
39
|
-
expect(subject.body.encoded).to match 'Row 20: whatever'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe SirTrevorRails::Block do
|
6
|
-
describe '.block_class' do
|
7
|
-
subject { described_class }
|
8
|
-
|
9
|
-
describe 'for known type' do
|
10
|
-
let(:klass) { subject.block_class('browse') }
|
11
|
-
|
12
|
-
it 'returns class' do
|
13
|
-
expect(klass).to eq SirTrevorRails::Blocks::BrowseBlock
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'returned class is the one defined in file' do
|
17
|
-
expect(klass.method_defined?(:searches)).to be true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'for unknown type' do
|
22
|
-
let(:klass) { subject.block_class('unknown') }
|
23
|
-
|
24
|
-
it 'defines and returns class' do
|
25
|
-
expect(klass).to eq SirTrevorRails::Blocks::UnknownBlock
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'defines class that inherits from Block' do
|
29
|
-
expect(klass.superclass).to eq described_class
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '.from_hash' do
|
35
|
-
let(:source_hash) { { type: 'test', data: {} } }
|
36
|
-
let(:block) { described_class.from_hash(source_hash, nil) }
|
37
|
-
|
38
|
-
it 'initializes new block based on type field' do
|
39
|
-
expect(block).to be_a_kind_of SirTrevorRails::Blocks::TestBlock
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'creates accessors for all fields defined in data field' do
|
43
|
-
source_hash[:data].merge!(width: '100')
|
44
|
-
|
45
|
-
expect(block.width).to eq '100'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'JSON representation' do
|
50
|
-
let(:empty_source_hash) { { type: 'test', data: {} } }
|
51
|
-
let(:empty_block) { described_class.from_hash(empty_source_hash, nil) }
|
52
|
-
let(:data_source_hash) { { type: 'test', data: { one: 2, three: 4 } } }
|
53
|
-
let(:data_block) { described_class.from_hash(data_source_hash, nil) }
|
54
|
-
|
55
|
-
it 'returns source hash when #as_json is called' do
|
56
|
-
expect(empty_block.as_json).to eq empty_source_hash
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'serializes block data' do
|
60
|
-
expect(data_block.as_json).to eq data_source_hash
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'partial view lookup' do
|
65
|
-
let(:source_hash) { { type: 'test', data: {} } }
|
66
|
-
let(:block) { described_class.from_hash(source_hash, nil) }
|
67
|
-
|
68
|
-
it 'uses block type to find view paritals' do
|
69
|
-
expect(block.to_partial_path).to eq 'sir_trevor/blocks/test_block'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|