blacklight-spotlight 3.0.0.alpha.9 → 3.0.0.alpha.10
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 +5 -0
- data/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +3 -2
- data/app/assets/stylesheets/spotlight/_accessibility.scss +1 -1
- data/app/assets/stylesheets/spotlight/_browse.scss +16 -0
- data/app/assets/stylesheets/spotlight/_curation.scss +6 -0
- data/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +3 -0
- data/app/assets/stylesheets/spotlight/_header.scss +1 -1
- data/app/assets/stylesheets/spotlight/_translations.scss +1 -0
- data/app/controllers/spotlight/appearances_controller.rb +1 -0
- data/app/controllers/spotlight/browse_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/pages_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +3 -2
- data/app/controllers/spotlight/translations_controller.rb +46 -0
- data/app/helpers/spotlight/crop_helper.rb +4 -1
- data/app/models/concerns/spotlight/translatables.rb +17 -1
- data/app/models/spotlight/about_page.rb +3 -1
- 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 +5 -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/views/catalog/_save_search.html.erb +1 -1
- 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/pages/_form.html.erb +1 -1
- data/app/views/spotlight/searches/_form.html.erb +1 -0
- data/app/views/spotlight/searches/_search.html.erb +1 -0
- 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/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/locales/spotlight.ar.yml +43 -24
- data/config/locales/spotlight.en.yml +65 -53
- data/config/routes.rb +6 -1
- data/db/migrate/20200403161512_add_subtitle_to_searches.rb +7 -0
- data/lib/spotlight/engine.rb +20 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/translations_controller_spec.rb +53 -2
- data/spec/factories/featured_images.rb +4 -0
- data/spec/features/exhibits/translation_editing_spec.rb +2 -2
- data/spec/features/home_page_spec.rb +9 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +4 -1
- data/spec/i18n_spec.rb +0 -2
- data/spec/models/spotlight/exhibit_spec.rb +9 -1
- data/spec/models/spotlight/featured_image_spec.rb +28 -0
- data/spec/models/spotlight/page_spec.rb +6 -1
- data/spec/models/spotlight/resources/upload_spec.rb +43 -79
- data/spec/{serializers/spotlight/exhibit_export_serializer_spec.rb → services/spotlight/exhibit_import_export_service_spec.rb} +108 -22
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +24 -0
- metadata +14 -11
- 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
@@ -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,18 @@ 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.source = 'remote'
|
40
|
+
featured_image.image = temp_image.image
|
41
|
+
featured_image.save!
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'points at the RIIIF endpoint' do
|
45
|
+
expect(subject.iiif_url).to match(%r{^/images/\d+/})
|
46
|
+
end
|
47
|
+
end
|
20
48
|
end
|
21
49
|
|
22
50
|
describe 'region' 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.slug => 'Custom Field Data'
|
18
|
-
}
|
19
|
-
end
|
20
|
-
let(:featured_image) { FactoryBot.create(:featured_image, image: File.open(File.join(FIXTURES_PATH, '800x600.png'))) }
|
21
|
-
|
22
|
-
before do
|
23
|
-
Rails.cache.clear # wipes out any cached image info.
|
24
|
-
allow(resource).to receive(:configured_fields).and_return configured_fields
|
25
|
-
allow(described_class).to receive(:fields).and_return configured_fields
|
26
|
-
|
27
|
-
allow(resource.send(:blacklight_solr)).to receive(:update)
|
28
|
-
allow(Spotlight::Engine.config).to receive(:upload_title_field).and_return(title_field)
|
29
|
-
resource.data = upload_data
|
30
|
-
resource.upload = featured_image
|
31
|
-
resource.save
|
32
|
-
end
|
6
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
33
7
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
8
|
+
describe '.fields' do
|
9
|
+
it "includes the exhibit's uploaded resource fields" do
|
10
|
+
expect(described_class.fields(exhibit)).to include(*exhibit.uploaded_resource_fields)
|
11
|
+
end
|
38
12
|
|
39
|
-
|
40
|
-
it '
|
41
|
-
|
13
|
+
context 'title field' do
|
14
|
+
it 'is an UploadFieldConfig object for the configured index title_field' do
|
15
|
+
upload_config = described_class.fields(exhibit).first
|
16
|
+
expect(upload_config).to be_a Spotlight::UploadFieldConfig
|
17
|
+
expect(upload_config.field_name).to eq exhibit.blacklight_config.index.title_field
|
42
18
|
end
|
43
19
|
end
|
44
20
|
end
|
45
21
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Spotlight::UploadFieldConfig.new(field_name: 'some_field', solr_fields: %w[a b])
|
50
|
-
]
|
51
|
-
end
|
52
|
-
|
53
|
-
let :upload_data do
|
54
|
-
{ 'some_field' => 'value' }
|
22
|
+
describe '#compound_id' do
|
23
|
+
it 'appends the object ID w/ the exhibit ID' do
|
24
|
+
expect(upload.compound_id).to eq "#{exhibit.id}-42"
|
55
25
|
end
|
26
|
+
end
|
56
27
|
|
57
|
-
|
58
|
-
|
28
|
+
describe '#sidecar' do
|
29
|
+
it 'is a SolrDocumentSidecar with the correct relationships' do
|
30
|
+
sidecar = upload.sidecar
|
59
31
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
expect(subject['b']).to eq 'value'
|
64
|
-
end
|
32
|
+
expect(sidecar).to be_a Spotlight::SolrDocumentSidecar
|
33
|
+
expect(sidecar.exhibit_id).to eq exhibit.id
|
34
|
+
expect(sidecar.document_id).to eq "#{exhibit.id}-42"
|
65
35
|
end
|
66
36
|
end
|
67
37
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
it 'has the exhibit id and the upload id as the solr id' do
|
72
|
-
expect(subject[:id]).to eq "#{resource.exhibit.id}-#{resource.id}"
|
38
|
+
context 'when creating' do
|
39
|
+
before do
|
40
|
+
allow(upload).to receive(:write?).and_return(false)
|
73
41
|
end
|
74
42
|
|
75
|
-
it '
|
76
|
-
expect(
|
77
|
-
|
43
|
+
it 'the sidecar is updated with the apporpriate data from configured fields' do
|
44
|
+
expect(upload.sidecar).to receive(:update).with(
|
45
|
+
data: {
|
46
|
+
'configured_fields' => {
|
47
|
+
'full_title_tesim' => 'My Upload Title',
|
48
|
+
'spotlight_upload_date_tesim' => 'My Upload Date'
|
49
|
+
}
|
50
|
+
}
|
51
|
+
)
|
78
52
|
|
79
|
-
|
80
|
-
expect(subject[:spotlight_upload_description_tesim]).to eq 'Description Data'
|
81
|
-
expect(subject[:spotlight_upload_attribution_tesim]).to eq 'Attribution Data'
|
82
|
-
expect(subject[:spotlight_upload_date_tesim]).to eq 'Date Data'
|
83
|
-
end
|
53
|
+
upload.data = { 'full_title_tesim' => 'My Upload Title', 'spotlight_upload_date_tesim' => 'My Upload Date' }
|
84
54
|
|
85
|
-
|
86
|
-
expect(subject[:spotlight_resource_type_ssim]).to eq 'spotlight/resources/uploads'
|
55
|
+
upload.save
|
87
56
|
end
|
88
57
|
|
89
|
-
it '
|
90
|
-
|
91
|
-
|
58
|
+
it 'the sidecar is updated with the appropriate data from custom fields' do
|
59
|
+
FactoryBot.create(:custom_field, exhibit: exhibit, slug: 'custom_field_1')
|
60
|
+
FactoryBot.create(:custom_field, exhibit: exhibit, slug: 'custom_field_2')
|
92
61
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
62
|
+
expect(upload.sidecar).to receive(:update).with(
|
63
|
+
data: hash_including('custom_field_1' => 'Custom Field 1 Data', 'custom_field_2' => 'Custom Field 2 Data')
|
64
|
+
)
|
97
65
|
|
98
|
-
|
99
|
-
expect(subject[custom_field.solr_field]).to eq 'Custom Field Data'
|
100
|
-
end
|
66
|
+
upload.data = { 'custom_field_1' => 'Custom Field 1 Data', 'custom_field_2' => 'Custom Field 2 Data' }
|
101
67
|
|
102
|
-
|
103
|
-
manifest_path = Spotlight::Engine.routes.url_helpers.manifest_exhibit_solr_document_path(exhibit, resource.compound_id)
|
104
|
-
expect(subject[Spotlight::Engine.config.iiif_manifest_field]).to eq(manifest_path)
|
68
|
+
upload.save
|
105
69
|
end
|
106
70
|
end
|
107
71
|
end
|
@@ -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,59 @@ 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
|
+
v.is_a?(Time) ? nil : v
|
416
|
+
end
|
417
|
+
expected = _deep_transform_values_in_object(export) do |v|
|
418
|
+
v.is_a?(Time) ? nil : v
|
419
|
+
end
|
420
|
+
expect(actual).to include expected
|
421
|
+
end
|
337
422
|
end
|
338
423
|
|
339
424
|
describe 'should export saved searches with query parameters that can be re-generated' do
|
340
425
|
subject do
|
341
426
|
e = FactoryBot.create(:exhibit)
|
342
|
-
e.import(export)
|
427
|
+
e.import(export)
|
428
|
+
e
|
343
429
|
end
|
344
430
|
|
345
431
|
before do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'spotlight/translations/_import.html.erb', type: :view do
|
4
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
+
|
6
|
+
before do
|
7
|
+
allow(view).to receive(:can?).and_return(true)
|
8
|
+
allow(view).to receive(:current_exhibit).and_return(exhibit)
|
9
|
+
assign(:language, :es)
|
10
|
+
I18n.default_locale = 'en'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has a link to export the translation data' do
|
14
|
+
render
|
15
|
+
expect(rendered).to have_link 'Export English', href: spotlight.exhibit_translations_path(exhibit_id: exhibit, format: 'yaml', locale: 'en')
|
16
|
+
expect(rendered).to have_link 'Export Spanish', href: spotlight.exhibit_translations_path(exhibit_id: exhibit, format: 'yaml', locale: 'es')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has a form to import the translation data' do
|
20
|
+
render
|
21
|
+
expect(rendered).to have_selector "form[action='#{spotlight.import_exhibit_translations_path(exhibit_id: exhibit)}']"
|
22
|
+
expect(rendered).to have_selector 'input[name="file"]'
|
23
|
+
end
|
24
|
+
end
|