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,6 +3,22 @@
|
|
3
3
|
describe Spotlight::FeaturedImage do
|
4
4
|
subject(:featured_image) { described_class.new }
|
5
5
|
|
6
|
+
let(:temp_image) { FactoryBot.create(:temporary_image) }
|
7
|
+
|
8
|
+
context 'with an uploaded image' do
|
9
|
+
it 'copies the temporary uploaded image to this model' do
|
10
|
+
featured_image.source = 'remote'
|
11
|
+
featured_image.upload_id = temp_image.id
|
12
|
+
|
13
|
+
featured_image.save
|
14
|
+
|
15
|
+
expect(featured_image.image.filename).to eq temp_image.image.filename
|
16
|
+
expect(featured_image.image.read).to eq temp_image.image.read
|
17
|
+
|
18
|
+
expect { temp_image.reload }.to raise_exception ActiveRecord::RecordNotFound
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
describe '#iiif_url' do
|
7
23
|
let(:iiif_tilesource) { 'http://example.com/iiif/abc123/info.json' }
|
8
24
|
let(:iiif_region) { '0,0,400,300' }
|
@@ -17,6 +33,17 @@ describe Spotlight::FeaturedImage do
|
|
17
33
|
expect(subject.iiif_url).to match(%r{^http://example.com/iiif/abc123/})
|
18
34
|
expect(subject.iiif_url).not_to include('info.json')
|
19
35
|
end
|
36
|
+
|
37
|
+
context 'with an uploaded image' do
|
38
|
+
before do
|
39
|
+
featured_image.image = temp_image.image
|
40
|
+
featured_image.save!
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'points at the RIIIF endpoint' do
|
44
|
+
expect(subject.iiif_url).to match(%r{^/images/\d+/})
|
45
|
+
end
|
46
|
+
end
|
20
47
|
end
|
21
48
|
|
22
49
|
describe 'region' do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Spotlight::Group, type: :model do
|
4
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
+
|
6
|
+
describe '#searches' do
|
7
|
+
let(:group) { FactoryBot.create(:group_with_searches, exhibit: exhibit, searches_count: 4) }
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect(group.searches.count).to eq 4
|
11
|
+
end
|
12
|
+
|
13
|
+
it do
|
14
|
+
group.searches.all do |search|
|
15
|
+
expect(search).to be_an Spotlight::Search
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -7,7 +7,7 @@ describe Spotlight::MainNavigation, type: :model do
|
|
7
7
|
|
8
8
|
it 'has a default_label' do
|
9
9
|
subject.nav_type = :curated_features
|
10
|
-
expect(subject.default_label).to eq 'Curated
|
10
|
+
expect(subject.default_label).to eq 'Curated features'
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'returns the use the default label in the absence of a label' do
|
@@ -119,7 +119,7 @@ describe Spotlight::Page, type: :model do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
describe '#slug' do
|
122
|
-
let(:page) { FactoryBot.create(:
|
122
|
+
let(:page) { FactoryBot.create(:about_page) }
|
123
123
|
|
124
124
|
it 'gets a default slug' do
|
125
125
|
expect(page.slug).not_to be_blank
|
@@ -130,6 +130,11 @@ describe Spotlight::Page, type: :model do
|
|
130
130
|
expect(page.slug).to eq 'abc'
|
131
131
|
end
|
132
132
|
|
133
|
+
it 'blacklists contacts' do
|
134
|
+
page.update(title: 'contacts')
|
135
|
+
expect(page.slug).not_to eq 'contacts'
|
136
|
+
end
|
137
|
+
|
133
138
|
context 'with a custom slug' do
|
134
139
|
let(:page) { FactoryBot.create(:feature_page, slug: 'xyz') }
|
135
140
|
|
@@ -1,122 +1,124 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe Spotlight::ReindexProgress, type: :model do
|
4
|
-
|
5
|
-
|
4
|
+
subject(:progress) { described_class.new(exhibit) }
|
5
|
+
|
6
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
|
+
let!(:job_tracker) do
|
8
|
+
FactoryBot.create(
|
9
|
+
:job_tracker,
|
10
|
+
resource: exhibit,
|
11
|
+
on: exhibit,
|
12
|
+
job_class: 'Spotlight::ReindexExhibitJob',
|
13
|
+
updated_at: Time.zone.now,
|
14
|
+
**job_tracker_args
|
15
|
+
)
|
6
16
|
end
|
17
|
+
let(:job_tracker_args) { {} }
|
7
18
|
|
8
|
-
|
19
|
+
context 'with a completed job' do
|
20
|
+
let(:job_tracker_args) { { status: 'completed', data: { progress: 50, total: 50 } } }
|
9
21
|
|
10
|
-
|
11
|
-
|
12
|
-
|
22
|
+
it 'reports on reindexing progress' do
|
23
|
+
expect(progress.as_json).to include(
|
24
|
+
completed: 50,
|
25
|
+
total: 50,
|
26
|
+
finished: true,
|
27
|
+
errored: false,
|
28
|
+
recently_in_progress: true
|
29
|
+
)
|
13
30
|
end
|
14
31
|
end
|
15
32
|
|
16
|
-
|
17
|
-
|
18
|
-
expect(subject.updated_at).to eq reindexing_log_entry.updated_at
|
19
|
-
end
|
20
|
-
end
|
33
|
+
context 'with a failed job' do
|
34
|
+
let(:job_tracker_args) { { status: 'failed', data: { progress: 32, total: 50 } } }
|
21
35
|
|
22
|
-
|
23
|
-
|
24
|
-
|
36
|
+
it 'reports on reindexing progress' do
|
37
|
+
expect(progress.as_json).to include(
|
38
|
+
completed: 32,
|
39
|
+
total: 50,
|
40
|
+
finished: true,
|
41
|
+
errored: true
|
42
|
+
)
|
25
43
|
end
|
26
44
|
end
|
27
45
|
|
28
|
-
|
29
|
-
|
30
|
-
|
46
|
+
context 'with an in-progress job' do
|
47
|
+
before do
|
48
|
+
FactoryBot.create(:job_tracker, on: job_tracker, resource: exhibit, data: { progress: 32, total: 32 }, status: 'completed')
|
49
|
+
FactoryBot.create(:job_tracker, on: job_tracker, resource: exhibit, data: { progress: 16, total: 50 }, status: 'in_progress')
|
31
50
|
end
|
32
|
-
end
|
33
51
|
|
34
|
-
|
35
|
-
it 'returns items_reindexed_estimate for current_log_entry' do
|
36
|
-
expect(subject.total).to be 12
|
37
|
-
end
|
38
|
-
end
|
52
|
+
let(:job_tracker_args) { { status: 'in_progress' } }
|
39
53
|
|
40
|
-
|
41
|
-
|
42
|
-
|
54
|
+
it 'harvests total and completed data from the child jobs' do
|
55
|
+
expect(progress.as_json).to include(
|
56
|
+
completed: 48,
|
57
|
+
total: 82
|
58
|
+
)
|
43
59
|
end
|
44
|
-
end
|
45
60
|
|
46
|
-
|
47
|
-
|
48
|
-
expect(subject).to be_errored
|
49
|
-
end
|
50
|
-
end
|
61
|
+
it 'is not completed until all the child jobs are finished' do
|
62
|
+
job_tracker.update(status: 'failed')
|
51
63
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
recently_in_progress: subject.recently_in_progress?,
|
56
|
-
started_at: I18n.l(reindexing_log_entry.start_time, format: :long),
|
57
|
-
finished_at: I18n.l(reindexing_log_entry.end_time, format: :long),
|
58
|
-
updated_at: I18n.l(reindexing_log_entry.updated_at, format: :long),
|
59
|
-
total: subject.total,
|
60
|
-
completed: subject.completed,
|
61
|
-
errored: subject.errored?,
|
62
|
-
finished: subject.finished?
|
64
|
+
expect(progress.as_json).to include(
|
65
|
+
finished: false,
|
66
|
+
errored: true
|
63
67
|
)
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
it 'returns true' do
|
72
|
-
expect(subject).to be_recently_in_progress
|
73
|
-
end
|
71
|
+
context 'with no job' do
|
72
|
+
before do
|
73
|
+
job_tracker.delete
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
it 'reports on reindexing progress' do
|
77
|
+
expect(progress.as_json).to include(
|
78
|
+
completed: 0,
|
79
|
+
total: 0,
|
80
|
+
finished: false,
|
81
|
+
errored: false,
|
82
|
+
recently_in_progress: false
|
83
|
+
)
|
82
84
|
end
|
85
|
+
end
|
83
86
|
|
84
|
-
|
85
|
-
|
87
|
+
context 'with multiple job trackers' do
|
88
|
+
let(:job_tracker_args) { { status: 'in_progress' } }
|
89
|
+
|
90
|
+
before do
|
91
|
+
FactoryBot.create(
|
92
|
+
:job_tracker,
|
93
|
+
resource: exhibit,
|
94
|
+
on: exhibit,
|
95
|
+
job_class: 'Spotlight::ReindexExhibitJob',
|
96
|
+
updated_at: Time.zone.now,
|
97
|
+
status: 'completed'
|
98
|
+
)
|
99
|
+
end
|
86
100
|
|
87
|
-
|
88
|
-
|
89
|
-
end
|
101
|
+
it 'uses the currently in-progress tracker' do
|
102
|
+
expect(progress.as_json).to include(finished: false)
|
90
103
|
end
|
91
104
|
end
|
92
105
|
|
93
|
-
context '
|
94
|
-
let(:
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
expect(subject.completed).to be nil
|
105
|
-
expect(subject.errored?).to be false
|
106
|
-
expect(subject.send(:localized_start_time)).to be nil
|
107
|
-
expect(subject.send(:localized_finish_time)).to be nil
|
108
|
-
expect(subject.send(:localized_updated_time)).to be nil
|
109
|
-
expect(subject.as_json).to eq(
|
110
|
-
recently_in_progress: false,
|
111
|
-
started_at: nil,
|
112
|
-
finished_at: nil,
|
113
|
-
updated_at: nil,
|
114
|
-
total: nil,
|
115
|
-
completed: nil,
|
116
|
-
errored: false,
|
117
|
-
finished: false
|
106
|
+
context 'with multiple in-progress trackers' do
|
107
|
+
let(:job_tracker_args) { { status: 'in_progress' } }
|
108
|
+
|
109
|
+
before do
|
110
|
+
FactoryBot.create(
|
111
|
+
:job_tracker,
|
112
|
+
resource: exhibit,
|
113
|
+
on: exhibit,
|
114
|
+
job_class: 'Spotlight::ReindexExhibitJob',
|
115
|
+
updated_at: Time.zone.now - 5.years,
|
116
|
+
status: 'in_progress'
|
118
117
|
)
|
119
118
|
end
|
120
|
-
|
119
|
+
|
120
|
+
it 'uses the most recently updated tracker' do
|
121
|
+
expect(Time.zone.parse(progress.as_json[:updated_at]).year).to eq job_tracker.updated_at.year
|
122
|
+
end
|
121
123
|
end
|
122
124
|
end
|
@@ -1,126 +1,105 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe Spotlight::Resource, type: :model do
|
4
|
-
|
5
|
-
allow_any_instance_of(described_class).to receive(:update_index)
|
6
|
-
end
|
4
|
+
subject(:resource) { described_class.create(id: 123, exhibit: exhibit) }
|
7
5
|
|
8
6
|
let(:exhibit) { FactoryBot.create(:exhibit) }
|
9
7
|
|
10
|
-
describe '#
|
11
|
-
|
12
|
-
subject
|
13
|
-
|
14
|
-
|
8
|
+
describe '#save_and_index' do
|
9
|
+
before do
|
10
|
+
allow(subject).to receive(:save)
|
11
|
+
allow(subject).to receive(:reindex_later)
|
12
|
+
end
|
15
13
|
|
16
|
-
|
14
|
+
it 'saves the object' do
|
15
|
+
expect(subject).to receive(:save).and_return(true)
|
16
|
+
subject.save_and_index
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
it 'reindexes after save' do
|
20
|
+
expect(subject).to receive(:save).and_return(true)
|
21
|
+
expect(subject).to receive(:reindex_later)
|
22
|
+
subject.save_and_index
|
23
|
+
end
|
21
24
|
|
22
|
-
|
25
|
+
context 'if the save fails' do
|
26
|
+
it 'does not reindex' do
|
27
|
+
expect(subject).to receive(:save).and_return(false)
|
28
|
+
expect(subject).not_to receive(:reindex_later)
|
29
|
+
subject.save_and_index
|
23
30
|
end
|
31
|
+
end
|
32
|
+
end
|
24
33
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
doc = data.first
|
31
|
-
|
32
|
-
break if doc.first == :commit
|
33
|
-
|
34
|
-
expect(doc).to include document_data: true
|
35
|
-
end
|
36
|
-
|
37
|
-
subject.reindex
|
38
|
-
end
|
34
|
+
describe '#reindex' do
|
35
|
+
before do
|
36
|
+
# sneak some data into the pipeline
|
37
|
+
subject.indexing_pipeline.transforms = [->(*) { { id: '123' } }] + subject.indexing_pipeline.transforms
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
let(:indexed_document) do
|
41
|
+
result = nil
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
expect(subject.send(:blacklight_solr)).not_to receive(:update)
|
43
|
+
subject.reindex(**index_args) do |data, *|
|
44
|
+
result = data
|
46
45
|
|
47
|
-
|
48
|
-
|
46
|
+
# skip actually indexing the document into the solr index
|
47
|
+
throw :skip
|
49
48
|
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
allow(subject.send(:blacklight_solr)).to receive(:update)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'updates the count of reindexed items in the log entry' do
|
57
|
-
reindexing_log_entry = double(Spotlight::ReindexingLogEntry)
|
58
|
-
expect(reindexing_log_entry).to receive(:update).with(items_reindexed_count: 1)
|
59
|
-
subject.reindex reindexing_log_entry
|
60
|
-
end
|
61
|
-
end
|
50
|
+
result
|
51
|
+
end
|
62
52
|
|
63
|
-
|
64
|
-
before do
|
65
|
-
allow(Spotlight::Engine.config).to receive_messages(writable_index: false)
|
66
|
-
end
|
53
|
+
let(:index_args) { {} }
|
67
54
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
55
|
+
it 'returns the number of items indexed' do
|
56
|
+
expect(subject.reindex { |*| throw :skip }).to eq 1
|
57
|
+
end
|
73
58
|
|
74
|
-
|
75
|
-
|
59
|
+
it 'applies exhibit-specific metadata from the sidecar' do
|
60
|
+
expect(indexed_document).to include Spotlight::SolrDocumentSidecar.new(document: SolrDocument.new(id: '123'), exhibit: exhibit).to_solr
|
61
|
+
end
|
76
62
|
|
77
|
-
|
78
|
-
|
79
|
-
|
63
|
+
it 'includes metata from each sidecar' do
|
64
|
+
a = Spotlight::SolrDocumentSidecar.create(document: SolrDocument.new(id: '123'), exhibit: exhibit)
|
65
|
+
b = Spotlight::SolrDocumentSidecar.create(document: SolrDocument.new(id: '123'), exhibit: FactoryBot.build(:exhibit))
|
80
66
|
|
81
|
-
|
82
|
-
|
83
|
-
end
|
67
|
+
expect(indexed_document).to include(a.to_solr).and(include(b.to_solr))
|
68
|
+
end
|
84
69
|
|
85
|
-
|
86
|
-
|
70
|
+
it 'persists a sidecar document' do
|
71
|
+
expect { indexed_document }.to change(Spotlight::SolrDocumentSidecar, :count).by(1)
|
87
72
|
|
88
|
-
|
89
|
-
|
73
|
+
expect(Spotlight::SolrDocumentSidecar.last).to have_attributes(document_id: '123', exhibit: exhibit)
|
74
|
+
end
|
90
75
|
|
91
|
-
|
92
|
-
|
76
|
+
it 'applies application metadata' do
|
77
|
+
expect(indexed_document).to include(spotlight_resource_id_ssim: resource.to_global_id.to_s, spotlight_resource_type_ssim: 'spotlight/resources')
|
78
|
+
end
|
93
79
|
|
94
|
-
|
80
|
+
context 'with some provided metadata' do
|
81
|
+
let(:index_args) { { additional_metadata: { a: 1 } } }
|
95
82
|
|
96
|
-
|
97
|
-
|
83
|
+
it 'applies externally provided metadata' do
|
84
|
+
expect(indexed_document).to include a: 1
|
98
85
|
end
|
99
86
|
end
|
100
|
-
end
|
101
87
|
|
102
|
-
|
103
|
-
|
104
|
-
allow(subject.send(:blacklight_solr)).to receive(:update)
|
105
|
-
allow(subject).to receive(:reindex_later)
|
106
|
-
end
|
88
|
+
it 'touches the exhibit to bust any caches' do
|
89
|
+
allow(exhibit).to receive(:touch)
|
107
90
|
|
108
|
-
|
109
|
-
expect(subject).to receive(:save).and_return(true)
|
110
|
-
subject.save_and_index
|
111
|
-
end
|
91
|
+
indexed_document
|
112
92
|
|
113
|
-
|
114
|
-
expect(subject).to receive(:save).and_return(true)
|
115
|
-
expect(subject).to receive(:reindex_later)
|
116
|
-
subject.save_and_index
|
93
|
+
expect(exhibit).to have_received(:touch)
|
117
94
|
end
|
118
95
|
|
119
|
-
context '
|
120
|
-
it 'does not
|
121
|
-
|
122
|
-
|
123
|
-
subject.
|
96
|
+
context 'with touch: false' do
|
97
|
+
it 'does not touch the exhibit' do
|
98
|
+
allow(exhibit).to receive(:touch)
|
99
|
+
|
100
|
+
expect(subject.reindex(touch: false) { |*| throw :skip }).to eq 1
|
101
|
+
|
102
|
+
expect(exhibit).not_to have_received(:touch)
|
124
103
|
end
|
125
104
|
end
|
126
105
|
end
|