blacklight-spotlight 3.0.0.alpha.8 → 3.0.0.rc3
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/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 +10 -5
- 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 +69 -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 +1 -1
- data/app/controllers/spotlight/concerns/application_controller.rb +13 -2
- 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 +1 -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/jobs/spotlight/add_uploads_from_csv.rb +30 -5
- 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/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/exhibit.rb +18 -4
- 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/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/resources/csv_upload.rb +2 -1
- data/app/models/spotlight/resources/iiif_manifest.rb +8 -6
- data/app/models/spotlight/resources/upload.rb +1 -1
- data/app/models/spotlight/search.rb +10 -1
- data/app/models/spotlight/solr_document_sidecar.rb +7 -5
- data/app/models/spotlight/temporary_image.rb +8 -0
- data/app/services/spotlight/exhibit_import_export_service.rb +482 -0
- data/app/services/spotlight/solr_document_builder.rb +1 -0
- 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/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/_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 +44 -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 +47 -24
- data/config/locales/spotlight.en.yml +182 -127
- 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/lib/generators/spotlight/install_generator.rb +23 -2
- 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 +27 -3
- 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 +1 -1
- 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/resources/upload_controller_spec.rb +2 -2
- 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 +1437 -1389
- data/spec/factories/featured_images.rb +4 -0
- data/spec/factories/group.rb +17 -0
- data/spec/factories/searches.rb +11 -1
- data/spec/features/add_contacts_spec.rb +1 -1
- 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/search_config_admin_spec.rb +1 -1
- data/spec/features/report_a_problem_spec.rb +6 -5
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +3 -3
- data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
- data/spec/i18n_spec.rb +0 -2
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +13 -1
- 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 +18 -2
- 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/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/{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/services/spotlight/solr_document_builder_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- 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 +6 -6
- 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 +399 -284
- 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/vendor/assets/javascripts/handlebars-v1.3.0.js +0 -2746
@@ -4,14 +4,13 @@ describe SolrDocument, type: :model do
|
|
4
4
|
subject { document }
|
5
5
|
|
6
6
|
let(:document) { described_class.new(id: 'abcd123') }
|
7
|
+
let(:exhibit_alt) { FactoryBot.create(:exhibit) }
|
8
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
9
|
|
8
10
|
before do
|
9
11
|
allow(subject).to receive_messages(reindex: nil)
|
10
12
|
end
|
11
13
|
|
12
|
-
let(:exhibit_alt) { FactoryBot.create(:exhibit) }
|
13
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
14
|
-
|
15
14
|
its(:to_key) { is_expected.to eq ['abcd123'] }
|
16
15
|
its(:persisted?) { is_expected.to be_truthy }
|
17
16
|
|
@@ -19,6 +19,14 @@ describe Spotlight::Exhibit, type: :model do
|
|
19
19
|
expect(subject.description).to eq 'Test description'
|
20
20
|
end
|
21
21
|
|
22
|
+
it 'has reserved slugs' do
|
23
|
+
subject.slug = 'site'
|
24
|
+
|
25
|
+
expect do
|
26
|
+
subject.save!
|
27
|
+
end.to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Slug is reserved')
|
28
|
+
end
|
29
|
+
|
22
30
|
describe 'validations' do
|
23
31
|
it 'validates the presence of the title' do
|
24
32
|
exhibit.title = ''
|
@@ -28,7 +36,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
28
36
|
end
|
29
37
|
|
30
38
|
it 'does not validate the presence of the title under a non-default locale' do
|
31
|
-
|
39
|
+
allow(I18n).to receive(:locale).and_return(:fr)
|
32
40
|
exhibit.title = ''
|
33
41
|
expect do
|
34
42
|
exhibit.save
|
@@ -147,7 +155,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
147
155
|
it 'removes the default browse category' do
|
148
156
|
subject.save
|
149
157
|
expect { subject.import({}) }.to change { subject.searches.count }.by(0)
|
150
|
-
expect { subject.import('searches' => [{ 'title' => 'All
|
158
|
+
expect { subject.import('searches' => [{ 'title' => 'All exhibit items', 'slug' => 'all-exhibit-items' }]) }.to change { subject.searches.count }.by(0)
|
151
159
|
end
|
152
160
|
|
153
161
|
it 'imports nested attributes from the hash' do
|
@@ -402,6 +410,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
402
410
|
I18n.locale = 'fr'
|
403
411
|
persisted_exhibit.reload
|
404
412
|
expect(persisted_exhibit.title).to eq 'Titre français'
|
413
|
+
expect(persisted_exhibit.translated_title).to eq 'Titre français'
|
405
414
|
end
|
406
415
|
|
407
416
|
it 'has a translatable subtitle' do
|
@@ -417,5 +426,12 @@ describe Spotlight::Exhibit, type: :model do
|
|
417
426
|
persisted_exhibit.reload
|
418
427
|
expect(persisted_exhibit.description).to eq 'Description français'
|
419
428
|
end
|
429
|
+
|
430
|
+
it 'is nil if no translation has been prrovided' do
|
431
|
+
expect(persisted_exhibit.title).to eq 'Sample'
|
432
|
+
I18n.locale = 'es'
|
433
|
+
persisted_exhibit.reload
|
434
|
+
expect(persisted_exhibit.translated_title(default: '')).to eq nil
|
435
|
+
end
|
420
436
|
end
|
421
437
|
end
|
@@ -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,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.field => '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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
describe Spotlight::
|
3
|
+
describe Spotlight::ExhibitImportExportService do
|
4
4
|
subject { JSON.parse(described_class.new(source_exhibit).to_json) }
|
5
5
|
|
6
6
|
let!(:source_exhibit) { FactoryBot.create(:exhibit) }
|
@@ -24,6 +24,10 @@ describe Spotlight::ExhibitExportSerializer do
|
|
24
24
|
expect(subject['searches']).to have(source_exhibit.searches.count).searches
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'has group attributes' do
|
28
|
+
expect(subject['groups']).to have(source_exhibit.groups.count).groups
|
29
|
+
end
|
30
|
+
|
27
31
|
it 'has home page attributes' do
|
28
32
|
expect(subject).to have_key 'home_page'
|
29
33
|
expect(subject['home_page']).not_to have_key 'id'
|
@@ -83,29 +87,43 @@ describe Spotlight::ExhibitExportSerializer do
|
|
83
87
|
|
84
88
|
describe 'should round-trip data' do
|
85
89
|
subject do
|
86
|
-
|
87
|
-
|
90
|
+
destination_exhibit.import(export)
|
91
|
+
destination_exhibit
|
88
92
|
end
|
89
93
|
|
90
|
-
|
91
|
-
sidecar = source_exhibit.solr_document_sidecars.create! document: SolrDocument.new(id: 1), public: false
|
92
|
-
source_exhibit.tag(sidecar, with: 'xyz', on: :tags)
|
93
|
-
end
|
94
|
+
let(:destination_exhibit) { FactoryBot.create(:exhibit) }
|
94
95
|
|
95
96
|
let :export do
|
96
97
|
described_class.new(source_exhibit).as_json
|
97
98
|
end
|
98
99
|
|
100
|
+
before do
|
101
|
+
sidecar = source_exhibit.solr_document_sidecars.create! document: SolrDocument.new(id: 1), public: false
|
102
|
+
source_exhibit.tag(sidecar, with: 'xyz', on: :tags)
|
103
|
+
end
|
104
|
+
|
99
105
|
it 'has exhibit properties' do
|
100
106
|
expect(subject.title).to eq source_exhibit.title
|
101
107
|
end
|
102
108
|
|
109
|
+
context 'with a theme that does not exist in the destination' do
|
110
|
+
it 'ignores the invalid theme' do
|
111
|
+
source_exhibit.theme = 'xyz'
|
112
|
+
expect(subject.theme).to eq nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
103
116
|
it 'does not duplicate saved searches' do
|
104
117
|
expect(subject.searches).to have(1).item
|
105
118
|
end
|
106
119
|
|
107
120
|
it 'has blacklight configuration properties' do
|
121
|
+
subject.blacklight_configuration.index_fields_will_change!
|
122
|
+
subject.blacklight_configuration.index_fields['language_ssm'] = { some_value: true }
|
123
|
+
subject.blacklight_configuration.save
|
124
|
+
|
108
125
|
expect(subject.blacklight_configuration).to be_persisted
|
126
|
+
expect(subject.blacklight_configuration.blacklight_config.index_fields['language_ssm'].to_h).to include some_value: true
|
109
127
|
end
|
110
128
|
|
111
129
|
context 'for an exhibit without search fields' do
|
@@ -221,7 +239,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
221
239
|
before do
|
222
240
|
feature_page.content = { data: [{ type: 'text', data: { text: 'xyz' } }] }.to_json
|
223
241
|
feature_page.thumbnail = thumbnail
|
224
|
-
feature_page.save
|
242
|
+
feature_page.save!
|
225
243
|
end
|
226
244
|
|
227
245
|
it 'copies the masthead' do
|
@@ -239,6 +257,21 @@ describe Spotlight::ExhibitExportSerializer do
|
|
239
257
|
expect(subject.feature_pages.first.content.length).to eq 1
|
240
258
|
expect(subject.feature_pages.first.content.first).to be_a_kind_of SirTrevorRails::Blocks::TextBlock
|
241
259
|
end
|
260
|
+
|
261
|
+
context 'with a translation' do
|
262
|
+
before do
|
263
|
+
localized_page = feature_page.clone_for_locale('ar')
|
264
|
+
localized_page.content = { data: [{ type: 'text', data: { text: 'xyz-in-ar' } }] }.to_json
|
265
|
+
localized_page.save!
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'transfers the localized page' do
|
269
|
+
expect(subject.feature_pages.first.translated_pages.length).to eq 1
|
270
|
+
expect(JSON.parse(subject.feature_pages.first.translated_page_for('ar').read_attribute(:content))).to have_key 'data'
|
271
|
+
expect(subject.feature_pages.first.translated_page_for('ar').content.length).to eq 1
|
272
|
+
expect(subject.feature_pages.first.translated_page_for('ar').content.first).to be_a_kind_of SirTrevorRails::Blocks::TextBlock
|
273
|
+
end
|
274
|
+
end
|
242
275
|
end
|
243
276
|
|
244
277
|
it 'assigns STI resources the correct class' do
|
@@ -259,19 +292,31 @@ describe Spotlight::ExhibitExportSerializer do
|
|
259
292
|
let(:masthead) { FactoryBot.create(:masthead) }
|
260
293
|
let(:thumbnail) { FactoryBot.create(:featured_image) }
|
261
294
|
let!(:search) { FactoryBot.create(:search, exhibit: source_exhibit, masthead: masthead, thumbnail: thumbnail) }
|
295
|
+
let!(:existing_search) { FactoryBot.create(:search, slug: search.slug, exhibit: destination_exhibit) }
|
262
296
|
|
263
297
|
before do
|
264
298
|
source_exhibit.reload
|
299
|
+
destination_exhibit.reload
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'copies the title' do
|
303
|
+
subject
|
304
|
+
existing_search.reload
|
305
|
+
expect(existing_search.title).to eq search.title
|
265
306
|
end
|
266
307
|
|
267
308
|
it 'copies the masthead' do
|
268
|
-
|
269
|
-
|
309
|
+
subject
|
310
|
+
existing_search.reload
|
311
|
+
expect(existing_search.masthead).not_to be_blank
|
312
|
+
expect(existing_search.masthead.image.file.path).not_to eq search.masthead.image.file.path
|
270
313
|
end
|
271
314
|
|
272
315
|
it 'copies the thumbnail' do
|
273
|
-
|
274
|
-
|
316
|
+
subject
|
317
|
+
existing_search.reload
|
318
|
+
expect(existing_search.thumbnail).not_to be_blank
|
319
|
+
expect(existing_search.thumbnail.image.file.path).not_to eq search.thumbnail.image.file.path
|
275
320
|
end
|
276
321
|
|
277
322
|
context 'without an attached image' do
|
@@ -281,8 +326,24 @@ describe Spotlight::ExhibitExportSerializer do
|
|
281
326
|
end
|
282
327
|
|
283
328
|
it 'copies the masthead without an image' do
|
284
|
-
|
285
|
-
|
329
|
+
subject
|
330
|
+
existing_search.reload
|
331
|
+
expect(existing_search.masthead).not_to be_blank
|
332
|
+
expect(existing_search.masthead.image).to be_blank
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
context 'remote thumbnail with existing tilesource' do
|
337
|
+
it do
|
338
|
+
search.thumbnail.iiif_tilesource
|
339
|
+
search.thumbnail.save
|
340
|
+
source_exhibit.reload
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'unsets the iiif_tilesource' do
|
344
|
+
subject
|
345
|
+
existing_search.reload
|
346
|
+
expect(existing_search.thumbnail.iiif_tilesource).not_to eq search.thumbnail.iiif_tilesource
|
286
347
|
end
|
287
348
|
end
|
288
349
|
|
@@ -290,13 +351,44 @@ describe Spotlight::ExhibitExportSerializer do
|
|
290
351
|
before do
|
291
352
|
search.masthead.document_global_id = SolrDocument.new(id: 'xyz').to_global_id
|
292
353
|
search.masthead.source = 'exhibit'
|
354
|
+
search.masthead.iiif_tilesource = 'foo'
|
355
|
+
search.masthead.image = nil # Setting to nil to mimick an exhibit source
|
293
356
|
search.masthead.save
|
294
357
|
|
295
358
|
source_exhibit.reload
|
296
359
|
end
|
297
360
|
|
298
361
|
it 'copies the resource' do
|
299
|
-
|
362
|
+
subject
|
363
|
+
existing_search.reload
|
364
|
+
expect(existing_search.masthead).not_to be_blank
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'does not unset the iiif_tilesource' do
|
368
|
+
subject
|
369
|
+
existing_search.reload
|
370
|
+
expect(existing_search.masthead.iiif_tilesource).to eq search.masthead.iiif_tilesource
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
context 'in a group' do
|
375
|
+
let!(:group) { FactoryBot.create(:group, title: 'blah', exhibit: source_exhibit) }
|
376
|
+
|
377
|
+
before do
|
378
|
+
search.groups << group
|
379
|
+
search.save!
|
380
|
+
end
|
381
|
+
|
382
|
+
it 'copies the group' do
|
383
|
+
subject
|
384
|
+
expect(destination_exhibit.groups.length).to eq 1
|
385
|
+
expect(destination_exhibit.groups.first.as_json).to include(group.as_json.slice('slug', 'title', 'weight', 'published'))
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'copies the group membership' do
|
389
|
+
subject
|
390
|
+
expect(existing_search.reload.groups.length).to eq 1
|
391
|
+
expect(existing_search.groups.pluck(:slug)).to match_array [group.slug]
|
300
392
|
end
|
301
393
|
end
|
302
394
|
end
|
@@ -328,18 +420,71 @@ describe Spotlight::ExhibitExportSerializer do
|
|
328
420
|
end
|
329
421
|
end
|
330
422
|
|
331
|
-
|
332
|
-
FactoryBot.create
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
423
|
+
context 'testing idempotency' do
|
424
|
+
let(:masthead) { FactoryBot.create(:masthead) }
|
425
|
+
let(:thumbnail) { FactoryBot.create(:exhibit_thumbnail) }
|
426
|
+
let!(:search) { FactoryBot.create(:search, exhibit: source_exhibit, masthead: FactoryBot.create(:masthead), thumbnail: FactoryBot.create(:featured_image)) }
|
427
|
+
let!(:feature_page_1) { FactoryBot.create(:feature_page, exhibit: source_exhibit) }
|
428
|
+
let!(:feature_page_2) { FactoryBot.create(:feature_page, exhibit: source_exhibit) }
|
429
|
+
|
430
|
+
before do
|
431
|
+
source_exhibit.masthead = masthead
|
432
|
+
source_exhibit.thumbnail = thumbnail
|
433
|
+
end
|
434
|
+
|
435
|
+
# From Rails 6:
|
436
|
+
def _deep_transform_values_in_object(object, &block)
|
437
|
+
case object
|
438
|
+
when Hash
|
439
|
+
object.transform_values { |value| _deep_transform_values_in_object(value, &block) }
|
440
|
+
when Array
|
441
|
+
object.map { |e| _deep_transform_values_in_object(e, &block) }
|
442
|
+
else
|
443
|
+
yield(object)
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
it 'is re-runnable' do
|
448
|
+
FactoryBot.create :feature_subpage, exhibit: source_exhibit
|
449
|
+
export = described_class.new(source_exhibit).as_json
|
450
|
+
e = FactoryBot.create(:exhibit)
|
451
|
+
e.import(export)
|
452
|
+
e.import(export)
|
453
|
+
end
|
454
|
+
|
455
|
+
it 'is idempotent-ish' do
|
456
|
+
export = described_class.new(source_exhibit).as_json
|
457
|
+
e = FactoryBot.create(:exhibit)
|
458
|
+
e.import(export)
|
459
|
+
new_export = described_class.new(e).as_json
|
460
|
+
|
461
|
+
actual = _deep_transform_values_in_object(new_export) do |v|
|
462
|
+
if DateTime.parse(v.to_s)
|
463
|
+
nil
|
464
|
+
else
|
465
|
+
v
|
466
|
+
end
|
467
|
+
rescue ArgumentError
|
468
|
+
nil
|
469
|
+
end
|
470
|
+
expected = _deep_transform_values_in_object(export) do |v|
|
471
|
+
if DateTime.parse(v.to_s)
|
472
|
+
nil
|
473
|
+
else
|
474
|
+
v
|
475
|
+
end
|
476
|
+
rescue ArgumentError
|
477
|
+
nil
|
478
|
+
end
|
479
|
+
expect(actual).to include expected
|
480
|
+
end
|
337
481
|
end
|
338
482
|
|
339
483
|
describe 'should export saved searches with query parameters that can be re-generated' do
|
340
484
|
subject do
|
341
485
|
e = FactoryBot.create(:exhibit)
|
342
|
-
e.import(export)
|
486
|
+
e.import(export)
|
487
|
+
e
|
343
488
|
end
|
344
489
|
|
345
490
|
before do
|
@@ -418,7 +563,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
418
563
|
end
|
419
564
|
|
420
565
|
it 'includes only the page-related data' do
|
421
|
-
expect(subject.keys).to match_array %w[searches about_pages feature_pages home_page contacts]
|
566
|
+
expect(subject.keys).to match_array %w[searches groups about_pages feature_pages home_page contacts]
|
422
567
|
end
|
423
568
|
end
|
424
569
|
end
|