blacklight-spotlight 3.0.0.alpha.9 → 3.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/assets/images/blacklight/arrow-alt-circle-left.svg +1 -0
- data/app/assets/images/blacklight/arrow-alt-circle-right.svg +1 -0
- data/app/assets/javascripts/spotlight/admin/{add_new_page_button.js → add_new_button.js} +7 -0
- data/app/assets/javascripts/spotlight/admin/block_mixins/autocompleteable.js +4 -4
- data/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +55 -1
- data/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
- data/app/assets/javascripts/spotlight/admin/blocks/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/admin/blocks/solr_documents_base_block.js +1 -1
- data/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +7 -2
- data/app/assets/javascripts/spotlight/admin/crop.es6 +11 -0
- data/app/assets/javascripts/spotlight/admin/croppable.js +1 -1
- data/app/assets/javascripts/spotlight/admin/index.js +0 -2
- data/app/assets/javascripts/spotlight/admin/reindex_monitor.js +1 -0
- data/app/assets/javascripts/spotlight/admin/search_typeahead.js +2 -2
- data/app/assets/javascripts/spotlight/admin/sir-trevor/block_controls.js +21 -12
- data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +11 -3
- data/app/assets/javascripts/spotlight/user/browse_group_categories.js +59 -0
- data/app/assets/javascripts/spotlight/user/index.js +1 -0
- data/app/assets/stylesheets/spotlight/_accessibility.scss +1 -1
- data/app/assets/stylesheets/spotlight/_breadcrumbs.scss +8 -0
- data/app/assets/stylesheets/spotlight/_browse.scss +16 -0
- data/app/assets/stylesheets/spotlight/_catalog.scss +6 -6
- data/app/assets/stylesheets/spotlight/_curation.scss +6 -0
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +214 -83
- data/app/assets/stylesheets/spotlight/_header.scss +1 -1
- data/app/assets/stylesheets/spotlight/_item_text_block.scss +6 -0
- data/app/assets/stylesheets/spotlight/_pages.scss +9 -4
- data/app/assets/stylesheets/spotlight/_report_a_problem.scss +5 -2
- data/app/assets/stylesheets/spotlight/_spotlight.scss +2 -0
- data/app/assets/stylesheets/spotlight/_translations.scss +7 -0
- data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +92 -0
- data/app/builders/spotlight/bootstrap_breadcrumbs_builder.rb +1 -2
- data/app/controllers/concerns/spotlight/search_helper.rb +2 -8
- data/app/controllers/spotlight/appearances_controller.rb +0 -12
- data/app/controllers/spotlight/browse_controller.rb +7 -3
- data/app/controllers/spotlight/catalog_controller.rb +5 -2
- data/app/controllers/spotlight/concerns/application_controller.rb +13 -2
- data/app/controllers/spotlight/dashboards_controller.rb +1 -1
- data/app/controllers/spotlight/exhibits_controller.rb +2 -3
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/groups_controller.rb +80 -0
- data/app/controllers/spotlight/pages_controller.rb +6 -9
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +7 -19
- data/app/controllers/spotlight/translations_controller.rb +46 -0
- data/app/helpers/spotlight/application_helper.rb +20 -1
- data/app/helpers/spotlight/crop_helper.rb +4 -1
- data/app/helpers/spotlight/crud_link_helpers.rb +1 -1
- data/app/helpers/spotlight/main_app_helpers.rb +1 -1
- data/app/helpers/spotlight/pages_helper.rb +1 -1
- data/app/jobs/concerns/spotlight/job_tracking.rb +47 -0
- data/app/jobs/concerns/spotlight/limit_concurrency.rb +33 -0
- data/app/jobs/spotlight/add_uploads_from_csv.rb +34 -6
- data/app/jobs/spotlight/application_job.rb +8 -0
- data/app/jobs/spotlight/cleanup_job_trackers_job.rb +13 -0
- data/app/jobs/spotlight/default_thumbnail_job.rb +1 -3
- data/app/jobs/spotlight/reindex_exhibit_job.rb +36 -0
- data/app/jobs/spotlight/reindex_job.rb +49 -41
- data/app/jobs/spotlight/rename_sidecar_field_job.rb +2 -2
- data/app/jobs/spotlight/update_job_trackers_job.rb +20 -0
- data/app/mailers/spotlight/indexing_complete_mailer.rb +3 -2
- data/app/models/concerns/spotlight/exhibit_defaults.rb +1 -1
- data/app/models/concerns/spotlight/translatables.rb +17 -1
- data/app/models/concerns/spotlight/user.rb +2 -1
- data/app/models/sir_trevor_rails/blocks/browse_group_categories_block.rb +25 -0
- data/app/models/spotlight/ability.rb +2 -0
- data/app/models/spotlight/about_page.rb +3 -1
- data/app/models/spotlight/blacklight_configuration.rb +2 -1
- data/app/models/spotlight/contact.rb +1 -1
- data/app/models/spotlight/custom_field.rb +3 -3
- data/app/models/spotlight/event.rb +13 -0
- data/app/models/spotlight/exhibit.rb +18 -14
- data/app/models/spotlight/feature_page.rb +3 -1
- data/app/models/spotlight/featured_image.rb +29 -12
- data/app/models/spotlight/group.rb +22 -0
- data/app/models/spotlight/group_member.rb +11 -0
- data/app/models/spotlight/home_page.rb +3 -1
- data/app/models/spotlight/job_tracker.rb +105 -0
- data/app/models/spotlight/main_navigation.rb +2 -2
- data/app/models/spotlight/masthead.rb +1 -1
- data/app/models/spotlight/page.rb +5 -1
- data/app/models/spotlight/page_configurations.rb +6 -0
- data/app/models/spotlight/page_content.rb +2 -0
- data/app/models/spotlight/reindex_progress.rb +44 -27
- data/app/models/spotlight/resource.rb +24 -58
- data/app/models/spotlight/resources/csv_upload.rb +2 -1
- data/app/models/spotlight/resources/iiif_harvester.rb +10 -1
- data/app/models/spotlight/resources/iiif_manifest.rb +11 -7
- data/app/models/spotlight/resources/iiif_service.rb +1 -1
- data/app/models/spotlight/resources/json_upload.rb +12 -0
- data/app/models/spotlight/resources/upload.rb +25 -2
- data/app/models/spotlight/search.rb +10 -1
- data/app/models/spotlight/solr_document_sidecar.rb +9 -6
- data/app/models/spotlight/temporary_image.rb +8 -0
- data/app/services/spotlight/etl.rb +7 -0
- data/app/services/spotlight/etl/context.rb +52 -0
- data/app/services/spotlight/etl/executor.rb +194 -0
- data/app/services/spotlight/etl/loaders.rb +12 -0
- data/app/services/spotlight/etl/pipeline.rb +81 -0
- data/app/services/spotlight/etl/solr_loader.rb +96 -0
- data/app/services/spotlight/etl/sources.rb +25 -0
- data/app/services/spotlight/etl/step.rb +82 -0
- data/app/services/spotlight/etl/transforms.rb +64 -0
- data/app/services/spotlight/exhibit_import_export_service.rb +482 -0
- data/app/services/spotlight/validity_checker.rb +5 -5
- data/app/values/custom_field_name.rb +1 -0
- data/app/views/catalog/_save_search.html.erb +1 -1
- data/app/views/spotlight/about_pages/_empty.html.erb +5 -5
- data/app/views/spotlight/browse/_search.html.erb +5 -3
- data/app/views/spotlight/browse/_search_title.html.erb +2 -1
- data/app/views/spotlight/browse/index.html.erb +13 -0
- data/app/views/spotlight/catalog/_document.html.erb +2 -4
- data/app/views/spotlight/catalog/index.iiif_json.jbuilder +22 -0
- data/app/views/spotlight/contacts/_form.html.erb +1 -1
- data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +6 -6
- data/app/views/spotlight/feature_pages/_empty.html.erb +5 -5
- data/app/views/spotlight/featured_images/_form.html.erb +1 -1
- data/app/views/spotlight/featured_images/_upload_form.html.erb +1 -1
- data/app/views/spotlight/home_pages/_empty.html.erb +3 -3
- data/app/views/spotlight/indexing_complete_mailer/documents_indexed.html.erb +9 -0
- data/app/views/spotlight/pages/_form.html.erb +2 -2
- data/app/views/spotlight/searches/_form.html.erb +13 -0
- data/app/views/spotlight/searches/_group.html.erb +27 -0
- data/app/views/spotlight/searches/_search.html.erb +1 -0
- data/app/views/spotlight/searches/index.html.erb +58 -17
- data/app/views/spotlight/shared/_honeypot_field.html.erb +4 -0
- data/app/views/spotlight/shared/_locale_picker.html.erb +1 -1
- data/app/views/spotlight/shared/_report_a_problem.html.erb +7 -10
- data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -0
- data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +45 -0
- data/app/views/spotlight/sir_trevor/blocks/_uploaded_items_block.html.erb +7 -1
- data/app/views/spotlight/translations/_browse_categories.html.erb +29 -3
- data/app/views/spotlight/translations/_general.html.erb +7 -7
- data/app/views/spotlight/translations/_groups.html.erb +34 -0
- data/app/views/spotlight/translations/_import.html.erb +24 -0
- data/app/views/spotlight/translations/_metadata.html.erb +1 -1
- data/app/views/spotlight/translations/_page.html.erb +5 -5
- data/app/views/spotlight/translations/_pages.html.erb +4 -4
- data/app/views/spotlight/translations/_pages_table.html.erb +5 -5
- data/app/views/spotlight/translations/_search_fields.html.erb +3 -3
- data/app/views/spotlight/translations/edit.html.erb +14 -6
- data/app/views/spotlight/translations/show.yaml.yamlbuilder +81 -0
- data/config/i18n-tasks.yml +7 -0
- data/config/locales/spotlight.ar.yml +57 -24
- data/config/locales/spotlight.en.yml +184 -128
- data/config/routes.rb +16 -1
- data/db/migrate/20200403161512_add_subtitle_to_searches.rb +7 -0
- data/db/migrate/20210113092223_create_spotlight_groups.rb +23 -0
- data/db/migrate/20210122082032_create_job_trackers.rb +22 -0
- data/db/migrate/20210126123041_create_events.rb +15 -0
- data/lib/generators/spotlight/install_generator.rb +23 -2
- data/lib/generators/spotlight/scaffold_resource_generator.rb +5 -13
- data/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb +10 -0
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +3 -1
- data/lib/spotlight/engine.rb +35 -4
- data/lib/spotlight/upload_field_config.rb +1 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/browse_controller_spec.rb +24 -1
- data/spec/controllers/spotlight/catalog_controller_spec.rb +4 -2
- data/spec/controllers/spotlight/contacts_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +11 -0
- data/spec/controllers/spotlight/groups_controller_spec.rb +103 -0
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/searches_controller_spec.rb +10 -3
- data/spec/controllers/spotlight/translations_controller_spec.rb +53 -2
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +1 -1
- data/spec/examples.txt +1448 -125
- data/spec/factories/featured_images.rb +4 -0
- data/spec/factories/group.rb +17 -0
- data/spec/factories/job_trackers.rb +9 -0
- data/spec/factories/searches.rb +11 -1
- data/spec/features/add_contacts_spec.rb +1 -1
- data/spec/features/add_items_spec.rb +9 -4
- data/spec/features/browse_category_admin_spec.rb +39 -7
- data/spec/features/browse_category_navigation_spec.rb +44 -0
- data/spec/features/browse_category_spec.rb +2 -2
- data/spec/features/catalog_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +5 -4
- data/spec/features/dashboard_spec.rb +7 -7
- data/spec/features/edit_search_fields_spec.rb +2 -2
- data/spec/features/exhibits/administration_spec.rb +3 -3
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +1 -1
- data/spec/features/exhibits/language_create_edit_spec.rb +3 -3
- data/spec/features/exhibits/translation_editing_spec.rb +57 -8
- data/spec/features/home_page_spec.rb +13 -4
- data/spec/features/item_admin_spec.rb +4 -4
- data/spec/features/javascript/about_page_admin_spec.rb +1 -1
- data/spec/features/javascript/block_controls_spec.rb +3 -1
- data/spec/features/javascript/blocks/browse_group_categories_block_spec.rb +64 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +4 -1
- data/spec/features/javascript/browse_group_admin_spec.rb +45 -0
- data/spec/features/javascript/edit_in_place_spec.rb +3 -3
- data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
- data/spec/features/javascript/reindex_monitor_spec.rb +1 -1
- data/spec/features/javascript/search_config_admin_spec.rb +1 -1
- data/spec/features/report_a_problem_spec.rb +6 -5
- data/spec/features/site_users_management_spec.rb +4 -4
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +3 -3
- data/spec/helpers/spotlight/pages_helper_spec.rb +10 -2
- data/spec/i18n_spec.rb +0 -2
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +13 -1
- data/spec/jobs/spotlight/reindex_exhibit_job_spec.rb +43 -0
- data/spec/jobs/spotlight/reindex_job_spec.rb +30 -59
- data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +11 -1
- data/spec/models/sir_trevor_rails/blocks/browse_group_categories_block_spec.rb +41 -0
- data/spec/models/solr_document_spec.rb +2 -3
- data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -0
- data/spec/models/spotlight/exhibit_spec.rb +21 -59
- data/spec/models/spotlight/featured_image_spec.rb +27 -0
- data/spec/models/spotlight/group_spec.rb +19 -0
- data/spec/models/spotlight/main_navigation_spec.rb +1 -1
- data/spec/models/spotlight/page_spec.rb +6 -1
- data/spec/models/spotlight/reindex_progress_spec.rb +89 -87
- data/spec/models/spotlight/resource_spec.rb +69 -90
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +9 -10
- data/spec/models/spotlight/resources/upload_spec.rb +43 -79
- data/spec/models/spotlight/role_spec.rb +3 -3
- data/spec/models/spotlight/search_spec.rb +30 -3
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +1 -0
- data/spec/services/spotlight/etl/context_spec.rb +66 -0
- data/spec/services/spotlight/etl/executor_spec.rb +149 -0
- data/spec/services/spotlight/etl/pipeline_spec.rb +22 -0
- data/spec/services/spotlight/etl/solr_loader_spec.rb +76 -0
- data/spec/services/spotlight/etl/step_spec.rb +70 -0
- data/spec/{serializers/spotlight/exhibit_export_serializer_spec.rb → services/spotlight/exhibit_import_export_service_spec.rb} +168 -23
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -6
- data/spec/support/features/test_features_helpers.rb +15 -0
- data/spec/test_app_templates/Gemfile.extra +1 -3
- data/spec/test_app_templates/catalog_controller.rb +6 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +2 -0
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +28 -25
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +3 -3
- data/spec/views/spotlight/pages/show.html.erb_spec.rb +1 -0
- data/spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +7 -8
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +24 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +46 -21
- data/vendor/assets/javascripts/tiny-slider.js +3218 -0
- data/vendor/assets/stylesheets/tiny-slider.css +1 -0
- metadata +444 -289
- data/app/models/concerns/spotlight/resources/open_graph.rb +0 -36
- data/app/models/spotlight/reindexing_log_entry.rb +0 -42
- data/app/serializers/spotlight/exhibit_export_serializer.rb +0 -205
- data/app/serializers/spotlight/featured_image_representer.rb +0 -29
- data/app/serializers/spotlight/main_navigation_representer.rb +0 -13
- data/app/serializers/spotlight/page_representer.rb +0 -33
- data/app/services/spotlight/resources/iiif_builder.rb +0 -19
- data/app/services/spotlight/solr_document_builder.rb +0 -76
- data/app/services/spotlight/upload_solr_document_builder.rb +0 -57
- data/spec/factories/reindexing_log_entries.rb +0 -54
- data/spec/models/spotlight/reindexing_log_entry_spec.rb +0 -129
- data/spec/models/spotlight/resources/open_graph_spec.rb +0 -65
- data/spec/services/spotlight/solr_document_builder_spec.rb +0 -66
- data/vendor/assets/javascripts/handlebars-v1.3.0.js +0 -2746
@@ -3,12 +3,11 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Spotlight::Resources::IiifHarvester do
|
6
|
+
subject(:harvester) { described_class.create(exhibit_id: exhibit.id, url: url) }
|
7
|
+
|
6
8
|
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
|
-
let(:harvester) { described_class.create(exhibit_id: exhibit.id, url: url) }
|
8
9
|
|
9
10
|
describe 'Validation' do
|
10
|
-
subject { harvester }
|
11
|
-
|
12
11
|
context 'when given an invalid URL' do
|
13
12
|
before do
|
14
13
|
stub_request(:head, 'http://example.com').to_return(status: 200, headers: { 'Content-Type' => 'text/html' })
|
@@ -38,16 +37,16 @@ describe Spotlight::Resources::IiifHarvester do
|
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
|
-
describe '#
|
42
|
-
subject { harvester.document_builder }
|
43
|
-
|
40
|
+
describe '#reindex' do
|
44
41
|
let(:url) { 'uri://for-top-level-collection' }
|
45
42
|
|
46
|
-
before
|
43
|
+
before do
|
44
|
+
stub_default_collection
|
45
|
+
allow(Spotlight::Engine.config).to receive(:writable_index).and_return(false)
|
46
|
+
end
|
47
47
|
|
48
|
-
it '
|
49
|
-
expect(subject.
|
50
|
-
expect(subject.documents_to_index.count).to eq 8
|
48
|
+
it 'indexes all the solr documents' do
|
49
|
+
expect(subject.reindex).to eq 8
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
@@ -1,107 +1,71 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe Spotlight::Resources::Upload, type: :model do
|
4
|
-
|
5
|
-
let!(:custom_field) { FactoryBot.create :custom_field, exhibit: exhibit }
|
6
|
-
let(:resource) { described_class.new(exhibit: exhibit) }
|
7
|
-
let(:doc_builder) { resource.document_builder }
|
4
|
+
subject(:upload) { described_class.new(id: 42, exhibit: exhibit) }
|
8
5
|
|
9
|
-
let(:
|
10
|
-
let(:title_field) { Spotlight::UploadFieldConfig.new(field_name: 'configured_title_field') }
|
11
|
-
let(:upload_data) do
|
12
|
-
{
|
13
|
-
title_field.field_name => 'Title Data',
|
14
|
-
'spotlight_upload_description_tesim' => 'Description Data',
|
15
|
-
'spotlight_upload_attribution_tesim' => 'Attribution Data',
|
16
|
-
'spotlight_upload_date_tesim' => 'Date Data',
|
17
|
-
custom_field.slug => 'Custom Field Data'
|
18
|
-
}
|
19
|
-
end
|
20
|
-
let(:featured_image) { FactoryBot.create(:featured_image, image: File.open(File.join(FIXTURES_PATH, '800x600.png'))) }
|
21
|
-
|
22
|
-
before do
|
23
|
-
Rails.cache.clear # wipes out any cached image info.
|
24
|
-
allow(resource).to receive(:configured_fields).and_return configured_fields
|
25
|
-
allow(described_class).to receive(:fields).and_return configured_fields
|
26
|
-
|
27
|
-
allow(resource.send(:blacklight_solr)).to receive(:update)
|
28
|
-
allow(Spotlight::Engine.config).to receive(:upload_title_field).and_return(title_field)
|
29
|
-
resource.data = upload_data
|
30
|
-
resource.upload = featured_image
|
31
|
-
resource.save
|
32
|
-
end
|
6
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
33
7
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
8
|
+
describe '.fields' do
|
9
|
+
it "includes the exhibit's uploaded resource fields" do
|
10
|
+
expect(described_class.fields(exhibit)).to include(*exhibit.uploaded_resource_fields)
|
11
|
+
end
|
38
12
|
|
39
|
-
|
40
|
-
it '
|
41
|
-
|
13
|
+
context 'title field' do
|
14
|
+
it 'is an UploadFieldConfig object for the configured index title_field' do
|
15
|
+
upload_config = described_class.fields(exhibit).first
|
16
|
+
expect(upload_config).to be_a Spotlight::UploadFieldConfig
|
17
|
+
expect(upload_config.field_name).to eq exhibit.blacklight_config.index.title_field
|
42
18
|
end
|
43
19
|
end
|
44
20
|
end
|
45
21
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Spotlight::UploadFieldConfig.new(field_name: 'some_field', solr_fields: %w[a b])
|
50
|
-
]
|
51
|
-
end
|
52
|
-
|
53
|
-
let :upload_data do
|
54
|
-
{ 'some_field' => 'value' }
|
22
|
+
describe '#compound_id' do
|
23
|
+
it 'appends the object ID w/ the exhibit ID' do
|
24
|
+
expect(upload.compound_id).to eq "#{exhibit.id}-42"
|
55
25
|
end
|
26
|
+
end
|
56
27
|
|
57
|
-
|
58
|
-
|
28
|
+
describe '#sidecar' do
|
29
|
+
it 'is a SolrDocumentSidecar with the correct relationships' do
|
30
|
+
sidecar = upload.sidecar
|
59
31
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
expect(subject['b']).to eq 'value'
|
64
|
-
end
|
32
|
+
expect(sidecar).to be_a Spotlight::SolrDocumentSidecar
|
33
|
+
expect(sidecar.exhibit_id).to eq exhibit.id
|
34
|
+
expect(sidecar.document_id).to eq "#{exhibit.id}-42"
|
65
35
|
end
|
66
36
|
end
|
67
37
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
it 'has the exhibit id and the upload id as the solr id' do
|
72
|
-
expect(subject[:id]).to eq "#{resource.exhibit.id}-#{resource.id}"
|
38
|
+
context 'when creating' do
|
39
|
+
before do
|
40
|
+
allow(upload).to receive(:write?).and_return(false)
|
73
41
|
end
|
74
42
|
|
75
|
-
it '
|
76
|
-
expect(
|
77
|
-
|
43
|
+
it 'the sidecar is updated with the apporpriate data from configured fields' do
|
44
|
+
expect(upload.sidecar).to receive(:update).with(
|
45
|
+
data: {
|
46
|
+
'configured_fields' => {
|
47
|
+
'full_title_tesim' => 'My Upload Title',
|
48
|
+
'spotlight_upload_date_tesim' => 'My Upload Date'
|
49
|
+
}
|
50
|
+
}
|
51
|
+
)
|
78
52
|
|
79
|
-
|
80
|
-
expect(subject[:spotlight_upload_description_tesim]).to eq 'Description Data'
|
81
|
-
expect(subject[:spotlight_upload_attribution_tesim]).to eq 'Attribution Data'
|
82
|
-
expect(subject[:spotlight_upload_date_tesim]).to eq 'Date Data'
|
83
|
-
end
|
53
|
+
upload.data = { 'full_title_tesim' => 'My Upload Title', 'spotlight_upload_date_tesim' => 'My Upload Date' }
|
84
54
|
|
85
|
-
|
86
|
-
expect(subject[:spotlight_resource_type_ssim]).to eq 'spotlight/resources/uploads'
|
55
|
+
upload.save
|
87
56
|
end
|
88
57
|
|
89
|
-
it '
|
90
|
-
|
91
|
-
|
58
|
+
it 'the sidecar is updated with the appropriate data from custom fields' do
|
59
|
+
FactoryBot.create(:custom_field, exhibit: exhibit, slug: 'custom_field_1')
|
60
|
+
FactoryBot.create(:custom_field, exhibit: exhibit, slug: 'custom_field_2')
|
92
61
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
62
|
+
expect(upload.sidecar).to receive(:update).with(
|
63
|
+
data: hash_including('custom_field_1' => 'Custom Field 1 Data', 'custom_field_2' => 'Custom Field 2 Data')
|
64
|
+
)
|
97
65
|
|
98
|
-
|
99
|
-
expect(subject[custom_field.solr_field]).to eq 'Custom Field Data'
|
100
|
-
end
|
66
|
+
upload.data = { 'custom_field_1' => 'Custom Field 1 Data', 'custom_field_2' => 'Custom Field 2 Data' }
|
101
67
|
|
102
|
-
|
103
|
-
manifest_path = Spotlight::Engine.routes.url_helpers.manifest_exhibit_solr_document_path(exhibit, resource.compound_id)
|
104
|
-
expect(subject[Spotlight::Engine.config.iiif_manifest_field]).to eq(manifest_path)
|
68
|
+
upload.save
|
105
69
|
end
|
106
70
|
end
|
107
71
|
end
|
@@ -9,7 +9,7 @@ describe Spotlight::Role, type: :model do
|
|
9
9
|
|
10
10
|
it 'does not be valid' do
|
11
11
|
expect(subject).not_to be_valid
|
12
|
-
expect(subject.errors.messages).to include(role: ['is not included in the list'], 'user.email': ["can't be blank"])
|
12
|
+
expect(subject.errors.messages.transform_values(&:to_a)).to include(role: ['is not included in the list'], 'user.email': ["can't be blank"])
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -37,10 +37,10 @@ describe Spotlight::Role, type: :model do
|
|
37
37
|
|
38
38
|
describe 'that points at a user with an existing role' do
|
39
39
|
let(:user) { FactoryBot.create(:user) }
|
40
|
-
before { described_class.create!(role: 'curator', user: user) }
|
41
|
-
|
42
40
|
let(:args) { { role: 'curator', user_key: user.email } }
|
43
41
|
|
42
|
+
before { described_class.create!(role: 'curator', user: user) }
|
43
|
+
|
44
44
|
it 'is valid' do
|
45
45
|
expect(subject).not_to be_valid
|
46
46
|
expect(subject.errors.messages).to eq(user_key: ['already a member of this exhibit'])
|
@@ -5,7 +5,7 @@ describe Spotlight::Search, type: :model do
|
|
5
5
|
|
6
6
|
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
7
|
|
8
|
-
let(:query_params) { { 'f' => { '
|
8
|
+
let(:query_params) { { 'f' => { 'genre_ssim' => ['map'] } } }
|
9
9
|
|
10
10
|
let(:blacklight_config) { ::CatalogController.blacklight_config }
|
11
11
|
let(:document) do
|
@@ -17,7 +17,10 @@ describe Spotlight::Search, type: :model do
|
|
17
17
|
let(:query_params) { {} }
|
18
18
|
|
19
19
|
it 'has items' do
|
20
|
-
|
20
|
+
# Add some fuzziness to this. Running locally it should be 55 but in some
|
21
|
+
# CI environments, spec/features/add_items_spec.rb will end up adding new
|
22
|
+
# records and cannot ensure deletion of them.
|
23
|
+
expect(subject.documents.size).to be_within(1).of(55)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
@@ -31,6 +34,16 @@ describe Spotlight::Search, type: :model do
|
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
37
|
+
describe '.unpublished' do
|
38
|
+
let!(:search1) { FactoryBot.create(:search, published: true) }
|
39
|
+
let!(:search2) { FactoryBot.create(:search, published: false) }
|
40
|
+
let!(:search3) { FactoryBot.create(:search, published: nil) }
|
41
|
+
|
42
|
+
it 'accounts for nil and false values' do
|
43
|
+
expect(described_class.unpublished.count).to eq 5
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
34
47
|
describe '#slug' do
|
35
48
|
let(:search) { FactoryBot.create(:search) }
|
36
49
|
|
@@ -54,7 +67,7 @@ describe Spotlight::Search, type: :model do
|
|
54
67
|
|
55
68
|
describe '#search_params' do
|
56
69
|
it 'maps the search to the appropriate facet values' do
|
57
|
-
expect(subject.search_params.to_hash).to include 'fq' => array_including('{!term f=
|
70
|
+
expect(subject.search_params.to_hash).to include 'fq' => array_including('{!term f=genre_ssim}map')
|
58
71
|
end
|
59
72
|
|
60
73
|
context 'with filter_resources_by_exhibit configured' do
|
@@ -95,4 +108,18 @@ describe Spotlight::Search, type: :model do
|
|
95
108
|
expect(search_params).to include user_params
|
96
109
|
end
|
97
110
|
end
|
111
|
+
|
112
|
+
describe '#groups' do
|
113
|
+
let(:search) { FactoryBot.create(:search_with_groups, groups_count: 3) }
|
114
|
+
|
115
|
+
it do
|
116
|
+
expect(search.groups.count).to eq 3
|
117
|
+
end
|
118
|
+
|
119
|
+
it do
|
120
|
+
search.groups.all do |group|
|
121
|
+
expect(group).to be_an Spotlight::Group
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
98
125
|
end
|
@@ -20,6 +20,7 @@ describe Spotlight::SolrDocumentSidecar, type: :model do
|
|
20
20
|
context 'with an uploaded item' do
|
21
21
|
before do
|
22
22
|
subject.data = { 'configured_fields' => { 'some_configured_field' => 'some value' } }
|
23
|
+
subject.resource = Spotlight::Resources::Upload.new
|
23
24
|
allow(Spotlight::Resources::Upload).to receive(:fields).with(exhibit).and_return([uploaded_field_config])
|
24
25
|
end
|
25
26
|
|
@@ -0,0 +1,66 @@
|
|
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
|
@@ -0,0 +1,149 @@
|
|
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
|