blacklight-spotlight 3.0.0.alpha.6 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +55 -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/sir-trevor/block_controls.js +21 -12
- data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +3 -2
- data/app/assets/stylesheets/spotlight/_accessibility.scss +8 -0
- data/app/assets/stylesheets/spotlight/_browse.scss +16 -0
- data/app/assets/stylesheets/spotlight/_curation.scss +9 -16
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +7 -4
- 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/_nestable.scss +4 -0
- data/app/assets/stylesheets/spotlight/_pages.scss +3 -1
- data/app/assets/stylesheets/spotlight/_report_a_problem.scss +5 -2
- data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -0
- data/app/assets/stylesheets/spotlight/_translations.scss +1 -0
- data/app/controllers/concerns/spotlight/base.rb +8 -0
- data/app/controllers/spotlight/admin_users_controller.rb +4 -1
- data/app/controllers/spotlight/appearances_controller.rb +1 -0
- data/app/controllers/spotlight/browse_controller.rb +1 -1
- data/app/controllers/spotlight/catalog_controller.rb +2 -2
- data/app/controllers/spotlight/exhibits_controller.rb +4 -3
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +1 -5
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +3 -2
- data/app/controllers/spotlight/sites_controller.rb +8 -2
- data/app/controllers/spotlight/translations_controller.rb +46 -0
- data/app/helpers/spotlight/crop_helper.rb +4 -1
- data/app/helpers/spotlight/title_helper.rb +12 -2
- 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/translatables.rb +17 -1
- data/app/models/spotlight/about_page.rb +3 -1
- data/app/models/spotlight/contact.rb +1 -1
- data/app/models/spotlight/custom_field.rb +3 -3
- data/app/models/spotlight/exhibit.rb +4 -2
- data/app/models/spotlight/feature_page.rb +3 -1
- data/app/models/spotlight/featured_image.rb +29 -12
- 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 +7 -3
- data/app/models/spotlight/page_configurations.rb +1 -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 +2 -0
- data/app/models/spotlight/resources/upload.rb +1 -1
- data/app/models/spotlight/search.rb +5 -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 +454 -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/layouts/spotlight/spotlight.html.erb +1 -1
- data/app/views/shared/_site_sidebar.html.erb +1 -1
- data/app/views/spotlight/about_pages/_contact.html.erb +15 -17
- data/app/views/spotlight/admin_users/index.html.erb +1 -1
- data/app/views/spotlight/appearances/edit.html.erb +1 -23
- data/app/views/spotlight/browse/_search.html.erb +3 -2
- data/app/views/spotlight/browse/_search_title.html.erb +2 -1
- data/app/views/spotlight/exhibits/new.html.erb +1 -1
- data/app/views/spotlight/feature_pages/_sidebar.html.erb +9 -5
- 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/pages/_page.html.erb +19 -35
- data/app/views/spotlight/search_configurations/_facets.html.erb +15 -34
- data/app/views/spotlight/search_configurations/_search_fields.html.erb +4 -19
- data/app/views/spotlight/search_configurations/_sort.html.erb +8 -22
- data/app/views/spotlight/searches/_form.html.erb +1 -0
- data/app/views/spotlight/searches/_search.html.erb +31 -29
- data/app/views/spotlight/shared/_dd3_item.html.erb +56 -0
- 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/_uploaded_items_block.html.erb +7 -1
- data/app/views/spotlight/sites/edit.html.erb +1 -1
- data/app/views/spotlight/sites/edit_exhibits.html.erb +1 -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/_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 +8 -6
- data/app/views/spotlight/translations/show.yaml.yamlbuilder +81 -0
- data/config/i18n-tasks.yml +2 -0
- data/config/locales/spotlight.ar.yml +47 -24
- data/config/locales/spotlight.en.yml +82 -67
- data/config/routes.rb +6 -1
- data/db/migrate/20200403161512_add_subtitle_to_searches.rb +7 -0
- data/lib/generators/spotlight/install_generator.rb +22 -1
- data/lib/generators/spotlight/templates/config/initializers/sir_trevor_rails.rb +10 -0
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +2 -0
- data/lib/spotlight/engine.rb +26 -0
- data/lib/spotlight/upload_field_config.rb +1 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/browse_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
- 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/translations_controller_spec.rb +53 -2
- data/spec/examples.txt +1410 -1389
- data/spec/factories/featured_images.rb +4 -0
- data/spec/features/add_contacts_spec.rb +1 -1
- data/spec/features/browse_category_admin_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +6 -6
- data/spec/features/dashboard_spec.rb +5 -5
- data/spec/features/exhibits/administration_spec.rb +3 -3
- data/spec/features/exhibits/language_create_edit_spec.rb +3 -3
- data/spec/features/exhibits/translation_editing_spec.rb +2 -2
- data/spec/features/home_page_spec.rb +9 -0
- data/spec/features/javascript/block_controls_spec.rb +2 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +4 -1
- data/spec/features/report_a_problem_spec.rb +5 -4
- data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
- data/spec/helpers/spotlight/title_helper_spec.rb +13 -0
- 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/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 +9 -1
- data/spec/models/spotlight/feature_page_spec.rb +0 -5
- data/spec/models/spotlight/featured_image_spec.rb +27 -0
- 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 +2 -2
- data/spec/{serializers/spotlight/exhibit_export_serializer_spec.rb → services/spotlight/exhibit_import_export_service_spec.rb} +120 -22
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
- data/spec/test_app_templates/Gemfile.extra +0 -3
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +1 -0
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +3 -3
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +9 -10
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +24 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +46 -21
- metadata +69 -34
- 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
@@ -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
|
@@ -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'])
|
@@ -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) }
|
@@ -83,29 +83,43 @@ describe Spotlight::ExhibitExportSerializer do
|
|
83
83
|
|
84
84
|
describe 'should round-trip data' do
|
85
85
|
subject do
|
86
|
-
|
87
|
-
|
86
|
+
destination_exhibit.import(export)
|
87
|
+
destination_exhibit
|
88
88
|
end
|
89
89
|
|
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
|
90
|
+
let(:destination_exhibit) { FactoryBot.create(:exhibit) }
|
94
91
|
|
95
92
|
let :export do
|
96
93
|
described_class.new(source_exhibit).as_json
|
97
94
|
end
|
98
95
|
|
96
|
+
before do
|
97
|
+
sidecar = source_exhibit.solr_document_sidecars.create! document: SolrDocument.new(id: 1), public: false
|
98
|
+
source_exhibit.tag(sidecar, with: 'xyz', on: :tags)
|
99
|
+
end
|
100
|
+
|
99
101
|
it 'has exhibit properties' do
|
100
102
|
expect(subject.title).to eq source_exhibit.title
|
101
103
|
end
|
102
104
|
|
105
|
+
context 'with a theme that does not exist in the destination' do
|
106
|
+
it 'ignores the invalid theme' do
|
107
|
+
source_exhibit.theme = 'xyz'
|
108
|
+
expect(subject.theme).to eq nil
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
103
112
|
it 'does not duplicate saved searches' do
|
104
113
|
expect(subject.searches).to have(1).item
|
105
114
|
end
|
106
115
|
|
107
116
|
it 'has blacklight configuration properties' do
|
117
|
+
subject.blacklight_configuration.index_fields_will_change!
|
118
|
+
subject.blacklight_configuration.index_fields['language_ssm'] = { some_value: true }
|
119
|
+
subject.blacklight_configuration.save
|
120
|
+
|
108
121
|
expect(subject.blacklight_configuration).to be_persisted
|
122
|
+
expect(subject.blacklight_configuration.blacklight_config.index_fields['language_ssm'].to_h).to include some_value: true
|
109
123
|
end
|
110
124
|
|
111
125
|
context 'for an exhibit without search fields' do
|
@@ -221,7 +235,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
221
235
|
before do
|
222
236
|
feature_page.content = { data: [{ type: 'text', data: { text: 'xyz' } }] }.to_json
|
223
237
|
feature_page.thumbnail = thumbnail
|
224
|
-
feature_page.save
|
238
|
+
feature_page.save!
|
225
239
|
end
|
226
240
|
|
227
241
|
it 'copies the masthead' do
|
@@ -239,6 +253,21 @@ describe Spotlight::ExhibitExportSerializer do
|
|
239
253
|
expect(subject.feature_pages.first.content.length).to eq 1
|
240
254
|
expect(subject.feature_pages.first.content.first).to be_a_kind_of SirTrevorRails::Blocks::TextBlock
|
241
255
|
end
|
256
|
+
|
257
|
+
context 'with a translation' do
|
258
|
+
before do
|
259
|
+
localized_page = feature_page.clone_for_locale('ar')
|
260
|
+
localized_page.content = { data: [{ type: 'text', data: { text: 'xyz-in-ar' } }] }.to_json
|
261
|
+
localized_page.save!
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'transfers the localized page' do
|
265
|
+
expect(subject.feature_pages.first.translated_pages.length).to eq 1
|
266
|
+
expect(JSON.parse(subject.feature_pages.first.translated_page_for('ar').read_attribute(:content))).to have_key 'data'
|
267
|
+
expect(subject.feature_pages.first.translated_page_for('ar').content.length).to eq 1
|
268
|
+
expect(subject.feature_pages.first.translated_page_for('ar').content.first).to be_a_kind_of SirTrevorRails::Blocks::TextBlock
|
269
|
+
end
|
270
|
+
end
|
242
271
|
end
|
243
272
|
|
244
273
|
it 'assigns STI resources the correct class' do
|
@@ -259,19 +288,31 @@ describe Spotlight::ExhibitExportSerializer do
|
|
259
288
|
let(:masthead) { FactoryBot.create(:masthead) }
|
260
289
|
let(:thumbnail) { FactoryBot.create(:featured_image) }
|
261
290
|
let!(:search) { FactoryBot.create(:search, exhibit: source_exhibit, masthead: masthead, thumbnail: thumbnail) }
|
291
|
+
let!(:existing_search) { FactoryBot.create(:search, slug: search.slug, exhibit: destination_exhibit) }
|
262
292
|
|
263
293
|
before do
|
264
294
|
source_exhibit.reload
|
295
|
+
destination_exhibit.reload
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'copies the title' do
|
299
|
+
subject
|
300
|
+
existing_search.reload
|
301
|
+
expect(existing_search.title).to eq search.title
|
265
302
|
end
|
266
303
|
|
267
304
|
it 'copies the masthead' do
|
268
|
-
|
269
|
-
|
305
|
+
subject
|
306
|
+
existing_search.reload
|
307
|
+
expect(existing_search.masthead).not_to be_blank
|
308
|
+
expect(existing_search.masthead.image.file.path).not_to eq search.masthead.image.file.path
|
270
309
|
end
|
271
310
|
|
272
311
|
it 'copies the thumbnail' do
|
273
|
-
|
274
|
-
|
312
|
+
subject
|
313
|
+
existing_search.reload
|
314
|
+
expect(existing_search.thumbnail).not_to be_blank
|
315
|
+
expect(existing_search.thumbnail.image.file.path).not_to eq search.thumbnail.image.file.path
|
275
316
|
end
|
276
317
|
|
277
318
|
context 'without an attached image' do
|
@@ -281,8 +322,10 @@ describe Spotlight::ExhibitExportSerializer do
|
|
281
322
|
end
|
282
323
|
|
283
324
|
it 'copies the masthead without an image' do
|
284
|
-
|
285
|
-
|
325
|
+
subject
|
326
|
+
existing_search.reload
|
327
|
+
expect(existing_search.masthead).not_to be_blank
|
328
|
+
expect(existing_search.masthead.image).to be_blank
|
286
329
|
end
|
287
330
|
end
|
288
331
|
|
@@ -296,7 +339,9 @@ describe Spotlight::ExhibitExportSerializer do
|
|
296
339
|
end
|
297
340
|
|
298
341
|
it 'copies the resource' do
|
299
|
-
|
342
|
+
subject
|
343
|
+
existing_search.reload
|
344
|
+
expect(existing_search.masthead).not_to be_blank
|
300
345
|
end
|
301
346
|
end
|
302
347
|
end
|
@@ -328,18 +373,71 @@ describe Spotlight::ExhibitExportSerializer do
|
|
328
373
|
end
|
329
374
|
end
|
330
375
|
|
331
|
-
|
332
|
-
FactoryBot.create
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
376
|
+
context 'testing idempotency' do
|
377
|
+
let(:masthead) { FactoryBot.create(:masthead) }
|
378
|
+
let(:thumbnail) { FactoryBot.create(:exhibit_thumbnail) }
|
379
|
+
let!(:search) { FactoryBot.create(:search, exhibit: source_exhibit, masthead: FactoryBot.create(:masthead), thumbnail: FactoryBot.create(:featured_image)) }
|
380
|
+
let!(:feature_page_1) { FactoryBot.create(:feature_page, exhibit: source_exhibit) }
|
381
|
+
let!(:feature_page_2) { FactoryBot.create(:feature_page, exhibit: source_exhibit) }
|
382
|
+
|
383
|
+
before do
|
384
|
+
source_exhibit.masthead = masthead
|
385
|
+
source_exhibit.thumbnail = thumbnail
|
386
|
+
end
|
387
|
+
|
388
|
+
# From Rails 6:
|
389
|
+
def _deep_transform_values_in_object(object, &block)
|
390
|
+
case object
|
391
|
+
when Hash
|
392
|
+
object.transform_values { |value| _deep_transform_values_in_object(value, &block) }
|
393
|
+
when Array
|
394
|
+
object.map { |e| _deep_transform_values_in_object(e, &block) }
|
395
|
+
else
|
396
|
+
yield(object)
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
it 'is re-runnable' do
|
401
|
+
FactoryBot.create :feature_subpage, exhibit: source_exhibit
|
402
|
+
export = described_class.new(source_exhibit).as_json
|
403
|
+
e = FactoryBot.create(:exhibit)
|
404
|
+
e.import(export)
|
405
|
+
e.import(export)
|
406
|
+
end
|
407
|
+
|
408
|
+
it 'is idempotent-ish' do
|
409
|
+
export = described_class.new(source_exhibit).as_json
|
410
|
+
e = FactoryBot.create(:exhibit)
|
411
|
+
e.import(export)
|
412
|
+
new_export = described_class.new(e).as_json
|
413
|
+
|
414
|
+
actual = _deep_transform_values_in_object(new_export) do |v|
|
415
|
+
if DateTime.parse(v.to_s)
|
416
|
+
nil
|
417
|
+
else
|
418
|
+
v
|
419
|
+
end
|
420
|
+
rescue ArgumentError
|
421
|
+
nil
|
422
|
+
end
|
423
|
+
expected = _deep_transform_values_in_object(export) do |v|
|
424
|
+
if DateTime.parse(v.to_s)
|
425
|
+
nil
|
426
|
+
else
|
427
|
+
v
|
428
|
+
end
|
429
|
+
rescue ArgumentError
|
430
|
+
nil
|
431
|
+
end
|
432
|
+
expect(actual).to include expected
|
433
|
+
end
|
337
434
|
end
|
338
435
|
|
339
436
|
describe 'should export saved searches with query parameters that can be re-generated' do
|
340
437
|
subject do
|
341
438
|
e = FactoryBot.create(:exhibit)
|
342
|
-
e.import(export)
|
439
|
+
e.import(export)
|
440
|
+
e
|
343
441
|
end
|
344
442
|
|
345
443
|
before do
|
@@ -68,7 +68,7 @@ describe Spotlight::IiifResourceResolver do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
context 'when the stored
|
71
|
+
context 'when the stored image ID is not present' do
|
72
72
|
it 'raises a ManifestError' do
|
73
73
|
resource.iiif_image_id = 'not-a-real-image-id'
|
74
74
|
|
@@ -34,6 +34,7 @@ describe 'spotlight/feature_pages/_sidebar.html.erb', type: :view do
|
|
34
34
|
assign(:page, child1)
|
35
35
|
render
|
36
36
|
# Checking that they are sorted accoding to weight
|
37
|
+
expect(rendered).to have_selector 'ol.sidenav', count: 1
|
37
38
|
expect(rendered).to have_selector 'li', text: 'Parent Page'
|
38
39
|
expect(rendered).to have_selector 'ol.sidenav li:nth-child(1) a', text: 'Five'
|
39
40
|
expect(rendered).to have_selector 'ol.sidenav li:nth-child(2) a', text: 'Three'
|
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
describe 'spotlight/metadata_configurations/_metadata_field', type: :view do
|
4
4
|
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
+
let(:field) { Blacklight::Configuration::Field.new immutable: OpenStruct.new(another_view_type: false) }
|
6
|
+
let(:builder) { ActionView::Helpers::FormBuilder.new 'z', nil, view, {} }
|
5
7
|
let(:p) { 'spotlight/metadata_configurations/metadata_field.html.erb' }
|
8
|
+
|
6
9
|
before do
|
7
10
|
assign(:exhibit, exhibit)
|
8
11
|
assign(:blacklight_configuration, exhibit.blacklight_configuration)
|
@@ -14,9 +17,6 @@ describe 'spotlight/metadata_configurations/_metadata_field', type: :view do
|
|
14
17
|
)
|
15
18
|
end
|
16
19
|
|
17
|
-
let(:field) { Blacklight::Configuration::Field.new immutable: OpenStruct.new(another_view_type: false) }
|
18
|
-
let(:builder) { ActionView::Helpers::FormBuilder.new 'z', nil, view, {} }
|
19
|
-
|
20
20
|
it 'uses the index_field_label helper to render the label' do
|
21
21
|
allow(view).to receive(:index_field_label).with(anything, 'some_key').and_return 'Some label'
|
22
22
|
render partial: p, locals: { key: 'some_key', config: field, f: builder }
|