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,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::SolrDocument::UploadedResource, type: :model do
|
4
|
-
let(:valid_resource) do
|
5
|
-
SolrDocument.new(id: '123',
|
6
|
-
full_image_url_ssm: ['http://example.com/png.png'],
|
7
|
-
spotlight_full_image_height_ssm: ['1400'],
|
8
|
-
spotlight_full_image_width_ssm: ['1000'],
|
9
|
-
spotlight_resource_type_ssim: ['spotlight/resources/uploads'])
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'SolrDocument.use_extension' do
|
13
|
-
it 'does not include the uploaded resource extension when the spotlight resource type is not correct' do
|
14
|
-
expect(SolrDocument.new(id: '123', spotlight_resource_type_ssim: ['not-correct'])).not_to be_a_kind_of(described_class)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'includes the uploaded resource extension when the correct fields are present with the correct data' do
|
18
|
-
expect(valid_resource).to be_a_kind_of(described_class)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'to_openseadragon' do
|
23
|
-
subject(:osd) { valid_resource.to_openseadragon }
|
24
|
-
|
25
|
-
let(:uploaded_resource) { instance_double(Spotlight::Resources::Upload, upload: upload) }
|
26
|
-
let(:upload) { instance_double(Spotlight::FeaturedImage, iiif_tilesource: '/whatever/info.json') }
|
27
|
-
|
28
|
-
before do
|
29
|
-
allow(valid_resource).to receive(:uploaded_resource).and_return(uploaded_resource)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'includes hashes for each full_image_url_ssm' do
|
33
|
-
expect(osd).to be_an Array
|
34
|
-
expect(osd.length).to eq 1
|
35
|
-
expect(osd.first).to end_with '/whatever/info.json'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::SolrDocumentSidecar, type: :model do
|
4
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
-
|
6
|
-
before do
|
7
|
-
allow(subject).to receive_messages exhibit: exhibit
|
8
|
-
allow(subject).to receive_messages document: SolrDocument.new(id: 'doc_id')
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#to_solr' do
|
12
|
-
before do
|
13
|
-
subject.data = { 'a_tesim' => 1, 'b_tesim' => 2, 'c_tesim' => 3 }
|
14
|
-
end
|
15
|
-
|
16
|
-
its(:to_solr) { is_expected.to include id: 'doc_id' }
|
17
|
-
its(:to_solr) { is_expected.to include "exhibit_#{exhibit.slug}_public_bsi".to_sym => true }
|
18
|
-
its(:to_solr) { is_expected.to include 'a_tesim', 'b_tesim', 'c_tesim' }
|
19
|
-
|
20
|
-
context 'with an uploaded item' do
|
21
|
-
before do
|
22
|
-
subject.data = { 'configured_fields' => { 'some_configured_field' => 'some value' } }
|
23
|
-
subject.resource = Spotlight::Resources::Upload.new
|
24
|
-
allow(Spotlight::Resources::Upload).to receive(:fields).with(exhibit).and_return([uploaded_field_config])
|
25
|
-
end
|
26
|
-
|
27
|
-
let(:uploaded_field_config) do
|
28
|
-
Spotlight::UploadFieldConfig.new(field_name: 'some_configured_field', solr_fields: ['the_solr_field'])
|
29
|
-
end
|
30
|
-
|
31
|
-
its(:to_solr) { is_expected.to include 'the_solr_field' => 'some value' }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with blank fields' do
|
35
|
-
before do
|
36
|
-
subject.data = {
|
37
|
-
'a_blank_field' => '',
|
38
|
-
'a_blank_multivalued_field' => ['', ''],
|
39
|
-
'a_multivalued_field_with_some_blanks' => ['', 'a']
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
its(:to_solr) { is_expected.to include 'a_blank_field' => nil }
|
44
|
-
its(:to_solr) { is_expected.to include 'a_blank_multivalued_field' => [] }
|
45
|
-
its(:to_solr) { is_expected.to include 'a_multivalued_field_with_some_blanks' => ['a'] }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::User do
|
4
|
-
subject { Class.new }
|
5
|
-
|
6
|
-
before { subject.extend described_class }
|
7
|
-
|
8
|
-
describe '#invite_pending?' do
|
9
|
-
it 'is false if the user was never invited in the first place' do
|
10
|
-
expect(subject).to receive_messages(invited_to_sign_up?: false)
|
11
|
-
expect(subject.invite_pending?).to be false
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'is true if the user was invited but has not accepted' do
|
15
|
-
expect(subject).to receive_messages(invited_to_sign_up?: true)
|
16
|
-
expect(subject).to receive_messages(invitation_accepted?: false)
|
17
|
-
expect(subject.invite_pending?).to be true
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'is false if the user was invited and has accpeted the invite' do
|
21
|
-
expect(subject).to receive_messages(invited_to_sign_up?: true)
|
22
|
-
expect(subject).to receive_messages(invitation_accepted?: true)
|
23
|
-
expect(subject.invite_pending?).to be false
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Translation, type: :model do
|
4
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
-
|
6
|
-
describe 'is unique by key, locale, and exhibit' do
|
7
|
-
it 'fails validation' do
|
8
|
-
described_class.create(exhibit_id: exhibit.id, key: 'abc', locale: 'fr', value: 'yo')
|
9
|
-
expect do
|
10
|
-
described_class.create(exhibit_id: exhibit.id, key: 'abc', locale: 'fr', value: 'lo')
|
11
|
-
end.to raise_error(ActiveRecord::RecordNotUnique)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '.to_h' do
|
16
|
-
it 'dumps the translations' do
|
17
|
-
expect(described_class.to_h).to be_a(Hash)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '.to_hash' do
|
22
|
-
it 'is not defined' do
|
23
|
-
expect(described_class).not_to respond_to(:to_hash)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::IiifManifestPresenter do
|
4
|
-
require 'iiif_manifest'
|
5
|
-
|
6
|
-
let(:resource) { SolrDocument.new(id: '1-1') }
|
7
|
-
let(:uploaded_resource) { FactoryBot.build(:uploaded_resource) }
|
8
|
-
let(:controller) { double(Spotlight::CatalogController) }
|
9
|
-
|
10
|
-
let(:subject) { described_class.new(resource, controller) }
|
11
|
-
|
12
|
-
let(:profile_url) { 'http://iiif.io/api/image/2/level2.json' }
|
13
|
-
|
14
|
-
before do
|
15
|
-
allow(resource).to receive(:uploaded_resource).and_return(uploaded_resource)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'public methods' do
|
19
|
-
let(:helpers) { double(document_presenter: presenter) }
|
20
|
-
let(:presenter) { instance_double(Blacklight::ShowPresenter, heading: title_field_value) }
|
21
|
-
|
22
|
-
let(:iiif_url) { 'https://iiif.test/images/1-1' }
|
23
|
-
let(:endpoint) { IIIFManifest::IIIFEndpoint.new(iiif_url, profile: profile_url) }
|
24
|
-
let(:manifest_url) { 'https://iiif.test/spotlight/test/catalog/1-1/manifest' }
|
25
|
-
let(:spotlight_route_helper) { double }
|
26
|
-
let(:blacklight_config) { double(Spotlight::BlacklightConfiguration) }
|
27
|
-
|
28
|
-
let(:id) { 123 }
|
29
|
-
let(:title_field_name) { 'title_field_name' }
|
30
|
-
let(:title_field_value) { 'title' }
|
31
|
-
let(:description_field_value) { 'description' }
|
32
|
-
let(:img_width) { 11 }
|
33
|
-
let(:img_height) { 10 }
|
34
|
-
|
35
|
-
before do
|
36
|
-
allow(spotlight_route_helper).to receive(:manifest_exhibit_solr_document_url).with(uploaded_resource.exhibit, resource).and_return(manifest_url)
|
37
|
-
allow(controller).to receive(:spotlight).and_return(spotlight_route_helper)
|
38
|
-
|
39
|
-
allow(blacklight_config).to receive(:view_config).with(:show).and_return(double(title_field: title_field_name))
|
40
|
-
allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
|
41
|
-
|
42
|
-
allow(resource).to receive(:first).with(title_field_name).and_return(title_field_value)
|
43
|
-
allow(resource).to receive(:first).with(Spotlight::Engine.config.upload_description_field).and_return(description_field_value)
|
44
|
-
allow(resource).to receive(:first).with(:spotlight_full_image_width_ssm).and_return(img_width)
|
45
|
-
allow(resource).to receive(:first).with(:spotlight_full_image_height_ssm).and_return(img_height)
|
46
|
-
|
47
|
-
allow(subject).to receive(:endpoint).and_return(endpoint)
|
48
|
-
allow(subject).to receive(:id).and_return(id)
|
49
|
-
allow(controller).to receive(:view_context).and_return(helpers)
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#display_image' do
|
53
|
-
it 'returns a properly configured instance of IIIFManifest::DisplayImage' do
|
54
|
-
# can't do:
|
55
|
-
# expect(subject.display_image).to eq(IIIFManifest::DisplayImage.new(0, width: 10, height: 10, format: 'image/jpeg', iiif_endpoint: endpoint))
|
56
|
-
# because IIIFManifest::DisplayImage doesn't implement #==
|
57
|
-
result = subject.display_image
|
58
|
-
expect(result.url).to eq id
|
59
|
-
expect(result.width).to eq img_width
|
60
|
-
expect(result.height).to eq img_height
|
61
|
-
expect(result.format).to eq 'image/jpeg'
|
62
|
-
expect(result.iiif_endpoint).to eq endpoint
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#file_set_presenters' do
|
67
|
-
it "returns a single-element list containing the presenter object on which it's called" do
|
68
|
-
expect(subject.file_set_presenters).to eq([subject])
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '#work_presenters' do
|
73
|
-
it "returns an empty list, because we don't yet support interstitial nodes in the document manifest" do
|
74
|
-
expect(subject.work_presenters).to eq([])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#manifest_url' do
|
79
|
-
it 'relays the value from the spotlight route url helper' do
|
80
|
-
expect(subject.manifest_url).to eq(manifest_url)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#description' do
|
85
|
-
it 'gets the description from the resource using the configured upload_description_field' do
|
86
|
-
expect(subject.description).to eq(description_field_value)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe '#to_s' do
|
91
|
-
it "uses the resource's title field value as the presenter's string representation" do
|
92
|
-
expect(subject.to_s).to eq(title_field_value)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#iiif_manifest' do
|
97
|
-
it 'builds a IIIFManifest object based on the presenter object info' do
|
98
|
-
result = subject.iiif_manifest
|
99
|
-
expect(result).to be_an_instance_of(IIIFManifest::ManifestBuilder)
|
100
|
-
expect(result.work).to be(subject)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe '#iiif_manifest_json' do
|
105
|
-
it 'returns json for the manifest generated from the presenter object info' do
|
106
|
-
expect(subject.iiif_manifest_json).to eq(subject.iiif_manifest.to_h.to_json)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe 'private methods' do
|
112
|
-
describe '#endpoint' do
|
113
|
-
it 'returns a properly configured instance of IIIFManifest::IIIFEndpoint' do
|
114
|
-
iiif_url = 'https://iiif.test/images/1-1'
|
115
|
-
allow(subject).to receive(:iiif_url).and_return(iiif_url)
|
116
|
-
|
117
|
-
result = subject.send(:endpoint)
|
118
|
-
expect(result.url).to eq(iiif_url)
|
119
|
-
expect(result.profile).to eq(profile_url)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe '#iiif_url' do
|
124
|
-
it 'returns the info_url from the Riiif engine routes, minus the trailing .json' do
|
125
|
-
riiif_route_helper = double(info_url: 'https://iiif.test/path/info.json')
|
126
|
-
allow(controller).to receive(:riiif).and_return(riiif_route_helper)
|
127
|
-
|
128
|
-
expect(subject.send(:iiif_url)).to eq('https://iiif.test/path')
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe 'Catalog controller', type: :routing do
|
4
|
-
describe 'routing' do
|
5
|
-
routes { Spotlight::Engine.routes }
|
6
|
-
|
7
|
-
it 'routes to #show with a format' do
|
8
|
-
expect(get('/1/catalog/dq287tq6352.xml')).to route_to('spotlight/catalog#show', exhibit_id: '1', id: 'dq287tq6352', format: 'xml')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'routes to #edit' do
|
12
|
-
expect(get('/1/catalog/dq287tq6352/edit')).to route_to('spotlight/catalog#edit', exhibit_id: '1', id: 'dq287tq6352')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'routes to #manifest' do
|
16
|
-
expect(get('/1/catalog/1-1/manifest.json')).to route_to('spotlight/catalog#manifest', exhibit_id: '1', id: '1-1', format: 'json')
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'when the routing constraint is set to allow periods' do
|
20
|
-
before do
|
21
|
-
allow(Spotlight::Engine.config.routes).to receive(:solr_documents).and_return(constraints: { id: %r{[^/]+} })
|
22
|
-
Rails.application.reload_routes!
|
23
|
-
end
|
24
|
-
|
25
|
-
after do
|
26
|
-
Rails.application.reload_routes!
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'routes to #show as expected' do
|
30
|
-
expect(get('/1/catalog/gallica.bnf.fr')).to route_to('spotlight/catalog#show', exhibit_id: '1', id: 'gallica.bnf.fr')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Featured Images Controller', type: :routing do
|
4
|
-
describe 'routing' do
|
5
|
-
routes { Spotlight::Engine.routes }
|
6
|
-
|
7
|
-
it 'routes to /contact_images to #create' do
|
8
|
-
expect(post('/contact_images')).to route_to 'spotlight/featured_images#create'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'routes to /exhibit_thumbnails to #create' do
|
12
|
-
expect(post('/exhibit_thumbnails')).to route_to 'spotlight/featured_images#create'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'routes to /mastheads to #create' do
|
16
|
-
expect(post('/mastheads')).to route_to 'spotlight/featured_images#create'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'routes to /featured_images to #create' do
|
20
|
-
expect(post('/featured_images')).to route_to 'spotlight/featured_images#create'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'FeaturePagesController and AboutPagesController', type: :routing do
|
4
|
-
describe 'routing' do
|
5
|
-
routes { Spotlight::Engine.routes }
|
6
|
-
|
7
|
-
it 'routes to #index' do
|
8
|
-
expect(get('/1/feature')).to route_to('spotlight/feature_pages#index', exhibit_id: '1')
|
9
|
-
expect(get('/1/about')).to route_to('spotlight/about_pages#index', exhibit_id: '1')
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'routes to #new' do
|
13
|
-
expect(get('/1/feature/new')).to route_to('spotlight/feature_pages#new', exhibit_id: '1')
|
14
|
-
expect(get('/1/about/new')).to route_to('spotlight/about_pages#new', exhibit_id: '1')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'routes to #show' do
|
18
|
-
expect(get('/1/feature/2')).to route_to('spotlight/feature_pages#show', id: '2', exhibit_id: '1')
|
19
|
-
expect(get('/1/about/2')).to route_to('spotlight/about_pages#show', id: '2', exhibit_id: '1')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'routes to #edit' do
|
23
|
-
expect(get('/1/feature/2/edit')).to route_to('spotlight/feature_pages#edit', id: '2', exhibit_id: '1')
|
24
|
-
expect(get('/1/about/2/edit')).to route_to('spotlight/about_pages#edit', id: '2', exhibit_id: '1')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'routes to #create' do
|
28
|
-
expect(post('/1/feature')).to route_to('spotlight/feature_pages#create', exhibit_id: '1')
|
29
|
-
expect(post('/1/about')).to route_to('spotlight/about_pages#create', exhibit_id: '1')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'routes to #update' do
|
33
|
-
expect(put('/1/feature/2')).to route_to('spotlight/feature_pages#update', id: '2', exhibit_id: '1')
|
34
|
-
expect(put('/1/about/2')).to route_to('spotlight/about_pages#update', id: '2', exhibit_id: '1')
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'routes to #destroy' do
|
38
|
-
expect(delete('/1/feature/2')).to route_to('spotlight/feature_pages#destroy', id: '2', exhibit_id: '1')
|
39
|
-
expect(delete('/1/about/2')).to route_to('spotlight/about_pages#destroy', id: '2', exhibit_id: '1')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Spotlight::BulkUpdatesCsvTemplateService do
|
6
|
-
subject(:service) { described_class.new(exhibit: exhibit) }
|
7
|
-
|
8
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
9
|
-
let!(:tag1) { FactoryBot.create(:tagging, tagger: exhibit, taggable: exhibit) }
|
10
|
-
let!(:tag2) { FactoryBot.create(:tagging, tagger: exhibit, taggable: exhibit) }
|
11
|
-
|
12
|
-
describe '#template' do
|
13
|
-
let(:view_context) { double('ViewContext', document_presenter: double('DocumentPresenter', heading: 'Document Title')) }
|
14
|
-
|
15
|
-
it 'has a row for every document (+ the header)' do
|
16
|
-
template = CSV.parse(service.template(view_context: view_context).to_a.join)
|
17
|
-
expect(template).to have_at_least(56).items
|
18
|
-
expect(template[0].join(',')).to match(/Item ID,Item Title,Visibility,Tag: tagging\d,Tag: tagging\d/)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'only has requested columns' do
|
22
|
-
template = CSV.parse(service.template(view_context: view_context, tags: false).to_a.join)
|
23
|
-
expect(template[0].join(',')).to eq 'Item ID,Item Title,Visibility'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Spotlight::CarrierwaveFileResolver do
|
6
|
-
let(:masthead) { FactoryBot.create(:masthead) }
|
7
|
-
let(:resolver) { described_class.new }
|
8
|
-
|
9
|
-
describe 'finding the file' do
|
10
|
-
subject { Riiif::Image.file_resolver.find(masthead.id) }
|
11
|
-
|
12
|
-
it 'is found' do
|
13
|
-
expect(subject).to be_kind_of Riiif::File
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Spotlight::CloneTranslatedPageFromLocale do
|
6
|
-
subject(:clone) { described_class.call(locale: language.locale, page: page) }
|
7
|
-
|
8
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
9
|
-
let!(:page) { FactoryBot.create(:feature_page, exhibit: exhibit) }
|
10
|
-
let!(:language) { FactoryBot.create(:language, locale: 'es', exhibit: exhibit) }
|
11
|
-
|
12
|
-
it 'clones the exhibit home page for a particular exhibit' do
|
13
|
-
expect(Spotlight::Page.where(locale: 'es')).not_to be_present
|
14
|
-
expect { clone.save }.to change(Spotlight::Page, :count).by(1)
|
15
|
-
expect(Spotlight::Page.unscope(:order).last.locale).to eq 'es'
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when a translated page already exists for that locale' do
|
19
|
-
let(:translated_page) { page.clone_for_locale('es') }
|
20
|
-
|
21
|
-
it 'destroys it first' do
|
22
|
-
expect(Spotlight::Page.where(locale: 'es')).not_to be_present
|
23
|
-
translated_page.save!
|
24
|
-
expect(Spotlight::Page.where(locale: 'es').count).to eq 1
|
25
|
-
expect { clone.save! }.to change(Spotlight::Page, :count).by(0) # because it deletes one and adds one
|
26
|
-
expect(Spotlight::Page.where(locale: 'es').count).to eq 1
|
27
|
-
expect(Spotlight::Page.unscope(:order).last.locale).to eq 'es'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Etl::Context do
|
4
|
-
subject(:context) { described_class.new(resource, **context_args) }
|
5
|
-
|
6
|
-
let(:resource) { instance_double(Spotlight::Resource, id: 123, document_model: SolrDocument) }
|
7
|
-
let(:context_args) { {} }
|
8
|
-
|
9
|
-
describe '#resource' do
|
10
|
-
it 'extracts the Spotlight::Resource from the argument list' do
|
11
|
-
expect(context.resource).to eq resource
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#unique_key' do
|
16
|
-
let(:data) { { id: '123' } }
|
17
|
-
|
18
|
-
it 'tries to get a usable unique key for a transformed document' do
|
19
|
-
expect(context.unique_key(data)).to eq '123'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#on_error' do
|
24
|
-
context 'with a class-level handler' do
|
25
|
-
let(:handler) { instance_double(Proc, call: nil) }
|
26
|
-
|
27
|
-
it 'calls the class-level handler' do
|
28
|
-
allow(described_class).to receive(:error_reporter).and_return(handler)
|
29
|
-
|
30
|
-
subject.on_error(nil, nil, {})
|
31
|
-
|
32
|
-
expect(handler).to have_received(:call)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with an instance-level handler' do
|
37
|
-
let(:context_args) { { on_error: handler } }
|
38
|
-
let(:handler) { instance_double(Proc, call: nil) }
|
39
|
-
|
40
|
-
it 'calls the instance-level handler' do
|
41
|
-
subject.on_error(nil, nil, {})
|
42
|
-
|
43
|
-
expect(handler).to have_received(:call)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with :log' do
|
48
|
-
it 'logs an error' do
|
49
|
-
allow(Rails.logger).to receive(:error)
|
50
|
-
|
51
|
-
subject.on_error(nil, nil, {})
|
52
|
-
|
53
|
-
expect(Rails.logger).to have_received(:error).with(/Pipeline error/)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'with :exception' do
|
58
|
-
let(:context_args) { { on_error: :exception } }
|
59
|
-
let(:e) { StandardError.new('asdf') }
|
60
|
-
|
61
|
-
it 'raises an exception' do
|
62
|
-
expect { subject.on_error(nil, e, {}) }.to raise_exception(e)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,149 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Etl::Executor do
|
4
|
-
subject(:executor) { described_class.new(pipeline, context) }
|
5
|
-
|
6
|
-
let(:pipeline) do
|
7
|
-
Spotlight::Etl::Pipeline.new do |pipeline|
|
8
|
-
pipeline.sources = [Spotlight::Etl::Sources::IdentitySource]
|
9
|
-
pipeline.transforms = [Spotlight::Etl::Transforms::IdentityTransform]
|
10
|
-
pipeline.loaders = [->(result, *) { arr << result }]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
let(:context) { Spotlight::Etl::Context.new(resource) }
|
14
|
-
let(:resource) { Spotlight::Resource.new }
|
15
|
-
let(:arr) { [] }
|
16
|
-
|
17
|
-
describe '#call' do
|
18
|
-
it 'provides the context to the sources' do
|
19
|
-
pipeline.sources = [->(context, *) { [{ context: context }] }]
|
20
|
-
|
21
|
-
executor.call
|
22
|
-
|
23
|
-
expect(arr).to eq [{ context: context }]
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'makes the current source available to transforms' do
|
27
|
-
pipeline.transforms = [->(_data, pipeline) { pipeline.source }]
|
28
|
-
|
29
|
-
executor.call
|
30
|
-
|
31
|
-
expect(arr).to eq [resource]
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'chains the calls to the transforms' do
|
35
|
-
pipeline.transforms = [
|
36
|
-
->(data, *) { data.merge(a: 1) },
|
37
|
-
->(data, *) { data.merge(b: 2) },
|
38
|
-
->(data, *) { data.merge(c: 3) }
|
39
|
-
]
|
40
|
-
|
41
|
-
executor.call
|
42
|
-
|
43
|
-
expect(arr).to eq [{ a: 1, b: 2, c: 3 }]
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'caches the step instances across sources' do
|
47
|
-
pipeline.sources = [->(*) { [1, 2, 3] }]
|
48
|
-
|
49
|
-
pipeline.transforms = [
|
50
|
-
Class.new do
|
51
|
-
def initialize
|
52
|
-
@sum = 0
|
53
|
-
end
|
54
|
-
|
55
|
-
def call(data, pipeline)
|
56
|
-
@sum += pipeline.source
|
57
|
-
|
58
|
-
data.merge(sum: @sum)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
]
|
62
|
-
|
63
|
-
executor.call
|
64
|
-
|
65
|
-
expect(arr).to eq [{ sum: 1 }, { sum: 3 }, { sum: 6 }]
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'loads resulting documents' do
|
69
|
-
loader = Spotlight::Etl::SolrLoader.new
|
70
|
-
pipeline.sources = [->(*) { [{}, {}, {}] }]
|
71
|
-
pipeline.loaders = [loader]
|
72
|
-
|
73
|
-
allow(loader).to receive(:call)
|
74
|
-
|
75
|
-
executor.call
|
76
|
-
|
77
|
-
expect(loader).to have_received(:call).exactly(3).times
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'allows steps to throw :skip to skip the current source' do
|
81
|
-
pipeline.pre_processes = [
|
82
|
-
->(*) { throw(:skip) }
|
83
|
-
]
|
84
|
-
|
85
|
-
executor.call
|
86
|
-
|
87
|
-
expect(arr).to be_blank
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'forwards errors to the context error handler' do
|
91
|
-
e = StandardError.new
|
92
|
-
pipeline.transforms = [->(*) { raise e }]
|
93
|
-
|
94
|
-
allow(context).to receive(:on_error)
|
95
|
-
executor.call
|
96
|
-
|
97
|
-
expect(context).to have_received(:on_error).with(executor, e, {})
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'after processing the data' do
|
101
|
-
it 'calls finalize on the loaders' do
|
102
|
-
loader = Spotlight::Etl::SolrLoader.new
|
103
|
-
pipeline.sources = [->(*) { [{}, {}, {}] }]
|
104
|
-
pipeline.loaders = [loader]
|
105
|
-
|
106
|
-
allow(loader).to receive(:call)
|
107
|
-
allow(loader).to receive(:finalize)
|
108
|
-
|
109
|
-
executor.call
|
110
|
-
|
111
|
-
expect(loader).to have_received(:call).exactly(3).times
|
112
|
-
expect(loader).to have_received(:finalize).once
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'resets the step cache' do
|
116
|
-
pipeline.transforms = [
|
117
|
-
Class.new do
|
118
|
-
def initialize
|
119
|
-
@count = 0
|
120
|
-
end
|
121
|
-
|
122
|
-
def call(data, *)
|
123
|
-
@count += 1
|
124
|
-
|
125
|
-
data.merge(count: @count)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
]
|
129
|
-
|
130
|
-
executor.call
|
131
|
-
executor.call
|
132
|
-
|
133
|
-
expect(arr).to eq [{ count: 1 }, { count: 1 }]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe '#estimated_size' do
|
139
|
-
let(:source) { ->(*) { [1, 2, 3, 4] } }
|
140
|
-
|
141
|
-
before do
|
142
|
-
pipeline.sources = [source]
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'estimates the final size from the sources' do
|
146
|
-
expect(executor.estimated_size).to eq 4
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|