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
@@ -6,6 +6,10 @@ FactoryBot.define do
|
|
6
6
|
iiif_tilesource { 'https://exhibits-stage.stanford.edu/images/78' }
|
7
7
|
end
|
8
8
|
|
9
|
+
factory :temporary_image, class: 'Spotlight::TemporaryImage' do
|
10
|
+
image { Rack::Test::UploadedFile.new(File.expand_path(File.join('..', 'fixtures', 'avatar.png'), __dir__)) }
|
11
|
+
end
|
12
|
+
|
9
13
|
factory :masthead, class: 'Spotlight::Masthead' do
|
10
14
|
image { Rack::Test::UploadedFile.new(File.expand_path(File.join('..', 'fixtures', 'avatar.png'), __dir__)) }
|
11
15
|
end
|
@@ -17,7 +17,7 @@ describe 'Add a contact to an exhibit', type: :feature do
|
|
17
17
|
fill_in 'Location', with: 'Rome'
|
18
18
|
fill_in 'Telephone', with: '(555) 555-5555 ext. 12345 (mobile)'
|
19
19
|
|
20
|
-
|
20
|
+
find('input[name="commit"]').click
|
21
21
|
end
|
22
22
|
expect(page).to have_content 'The contact was created.'
|
23
23
|
|
@@ -21,7 +21,7 @@ describe 'Browse Category Administration', type: :feature do
|
|
21
21
|
expect(page).to have_css('#save-modal')
|
22
22
|
fill_in 'search_title', with: 'Some search'
|
23
23
|
expect do
|
24
|
-
|
24
|
+
find('input[name="commit"]').click
|
25
25
|
exhibit.searches.reload
|
26
26
|
end.to change { exhibit.searches.count }.by 1
|
27
27
|
expect(exhibit.searches.last.query_params).to eq 'q' => 'xyz'
|
@@ -32,7 +32,7 @@ describe 'Browse Category Administration', type: :feature do
|
|
32
32
|
click_button 'Save this search'
|
33
33
|
expect(page).to have_css('#save-modal')
|
34
34
|
select search.title, from: 'id'
|
35
|
-
|
35
|
+
find('input[name="commit"]').click
|
36
36
|
expect(search.reload.query_params).to eq 'q' => 'xyz'
|
37
37
|
end
|
38
38
|
end
|
@@ -13,8 +13,7 @@ describe 'Create a new exhibit', type: :feature do
|
|
13
13
|
within '.dropdown-menu' do
|
14
14
|
click_link 'Create new exhibit'
|
15
15
|
end
|
16
|
-
expect(page).to have_selector 'h1', text: '
|
17
|
-
expect(page).to have_selector 'h1 small', text: 'Create a new exhibit'
|
16
|
+
expect(page).to have_selector 'h1', text: 'Create a new exhibit'
|
18
17
|
end
|
19
18
|
|
20
19
|
it 'allows admins to create a new exhibit' do
|
@@ -25,7 +24,7 @@ describe 'Create a new exhibit', type: :feature do
|
|
25
24
|
|
26
25
|
fill_in 'Title', with: 'My exhibit title'
|
27
26
|
|
28
|
-
|
27
|
+
find('input[name="commit"]').click
|
29
28
|
|
30
29
|
expect(page).to have_content 'The exhibit was created.'
|
31
30
|
expect(Spotlight::Exhibit.last.slug).to eq 'my-exhibit-title'
|
@@ -40,7 +39,7 @@ describe 'Create a new exhibit', type: :feature do
|
|
40
39
|
fill_in 'Title', with: 'My exhibit title'
|
41
40
|
fill_in 'URL slug', with: 'custom-slug'
|
42
41
|
|
43
|
-
|
42
|
+
find('input[name="commit"]').click
|
44
43
|
|
45
44
|
expect(page).to have_content 'The exhibit was created.'
|
46
45
|
expect(Spotlight::Exhibit.last.slug).to eq 'custom-slug'
|
@@ -52,14 +51,15 @@ describe 'Create a new exhibit', type: :feature do
|
|
52
51
|
fill_in 'Title', with: 'My exhibit title'
|
53
52
|
fill_in 'URL slug', with: 'custom-slug'
|
54
53
|
|
55
|
-
|
54
|
+
find('input[name="commit"]').click
|
56
55
|
|
57
56
|
visit spotlight.new_exhibit_path
|
58
57
|
|
59
58
|
fill_in 'Title', with: 'My exhibit title'
|
60
59
|
fill_in 'URL slug', with: 'custom-slug'
|
61
60
|
|
62
|
-
|
61
|
+
find('input[name="commit"]').click
|
62
|
+
|
63
63
|
expect(page).to have_content 'has already been taken'
|
64
64
|
end
|
65
65
|
end
|
@@ -2,11 +2,6 @@
|
|
2
2
|
|
3
3
|
describe 'Dashboard', type: :feature do
|
4
4
|
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
-
let(:admin) { FactoryBot.create(:exhibit_admin, exhibit: exhibit) }
|
6
|
-
before do
|
7
|
-
login_as(admin)
|
8
|
-
end
|
9
|
-
|
10
5
|
let!(:parent_feature_page) do
|
11
6
|
FactoryBot.create(:feature_page, title: 'Parent Page', exhibit: exhibit)
|
12
7
|
end
|
@@ -18,6 +13,11 @@ describe 'Dashboard', type: :feature do
|
|
18
13
|
exhibit: exhibit
|
19
14
|
)
|
20
15
|
end
|
16
|
+
let(:admin) { FactoryBot.create(:exhibit_admin, exhibit: exhibit) }
|
17
|
+
|
18
|
+
before do
|
19
|
+
login_as(admin)
|
20
|
+
end
|
21
21
|
|
22
22
|
it 'includes a list of recently edited feature pages' do
|
23
23
|
visit spotlight.exhibit_dashboard_path(exhibit)
|
@@ -63,9 +63,9 @@ describe 'Exhibit Administration', type: :feature do
|
|
63
63
|
it 'updates the aria-labels properly', js: true do
|
64
64
|
visit spotlight.edit_exhibit_path(exhibit)
|
65
65
|
|
66
|
-
expect(find_field(email_id_0)['aria-label']).to eq '
|
66
|
+
expect(find_field(email_id_0)['aria-label']).to eq 'Recipient email 1'
|
67
67
|
find('#another-email').click
|
68
|
-
expect(find_field(email_id_1)['aria-label']).to eq '
|
68
|
+
expect(find_field(email_id_1)['aria-label']).to eq 'Recipient email 2'
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'allows deletion of contact email addresses', js: true do
|
@@ -135,7 +135,7 @@ describe 'Exhibit Administration', type: :feature do
|
|
135
135
|
find_all('.contact-email-delete').first.click
|
136
136
|
end
|
137
137
|
|
138
|
-
expect(page).to have_css("##{hidden_input_id_0}~div span.contact-email-delete-error", text: 'Problem deleting
|
138
|
+
expect(page).to have_css("##{hidden_input_id_0}~div span.contact-email-delete-error", text: 'Problem deleting recipient: Not Found')
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -13,7 +13,7 @@ describe 'Language', type: :feature do
|
|
13
13
|
it 'successfully adds languages' do
|
14
14
|
within '#language' do
|
15
15
|
select 'Albanian'
|
16
|
-
|
16
|
+
find('input[name="commit"]').click
|
17
17
|
end
|
18
18
|
expect(page).to have_css '.flash_messages', text: 'The language was created.'
|
19
19
|
within '#language' do
|
@@ -27,7 +27,7 @@ describe 'Language', type: :feature do
|
|
27
27
|
it 'successfully updates the language' do
|
28
28
|
within '#language' do
|
29
29
|
select 'Albanian'
|
30
|
-
|
30
|
+
find('input[name="commit"]').click
|
31
31
|
end
|
32
32
|
expect(page).to have_css '.flash_messages', text: 'The language was created.'
|
33
33
|
within '#language' do
|
@@ -43,7 +43,7 @@ describe 'Language', type: :feature do
|
|
43
43
|
it 'successfully updates the language' do
|
44
44
|
within '#language' do
|
45
45
|
select 'Albanian'
|
46
|
-
|
46
|
+
find('input[name="commit"]').click
|
47
47
|
end
|
48
48
|
expect(page).to have_css '.flash_messages', text: 'The language was created.'
|
49
49
|
within '#language' do
|
@@ -330,7 +330,7 @@ describe 'Translation editing', type: :feature do
|
|
330
330
|
|
331
331
|
it 'has a title and description for every browse category' do
|
332
332
|
within '#browse' do
|
333
|
-
expect(page).to have_css('input[type="text"]', count:
|
333
|
+
expect(page).to have_css('input[type="text"]', count: 4)
|
334
334
|
expect(page).to have_css('textarea', count: 2)
|
335
335
|
|
336
336
|
expect(page).to have_field 'All Exhibit Items'
|
@@ -407,7 +407,7 @@ describe 'Translation editing', type: :feature do
|
|
407
407
|
visit spotlight.edit_exhibit_translations_path(exhibit, language: 'fr')
|
408
408
|
expect(page).to have_link('General 1/8')
|
409
409
|
expect(page).to have_link('Search field labels 0/16')
|
410
|
-
expect(page).to have_link('Browse categories 0/
|
410
|
+
expect(page).to have_link('Browse categories 0/3')
|
411
411
|
expect(page).to have_link('Metadata field labels 0/17')
|
412
412
|
end
|
413
413
|
end
|
@@ -31,6 +31,15 @@ describe 'Home page', type: :feature, versioning: true do
|
|
31
31
|
expect(page).to have_selector '.card-title a', text: 'New Home Page Title'
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'redirects back to the correct home page URL after updating (no format param to interfere w/ faceting)' do
|
35
|
+
visit spotlight.exhibit_home_page_path(exhibit.home_page)
|
36
|
+
|
37
|
+
click_link 'Edit'
|
38
|
+
click_button 'Save changes'
|
39
|
+
|
40
|
+
expect(page.current_url).to eq spotlight.exhibit_home_page_url(exhibit)
|
41
|
+
end
|
42
|
+
|
34
43
|
it 'has working facet links' do
|
35
44
|
visit spotlight.exhibit_home_page_path(exhibit.home_page)
|
36
45
|
click_button 'Genre'
|
@@ -27,10 +27,12 @@ describe 'Block controls' do
|
|
27
27
|
|
28
28
|
within('.spotlight-block-controls') do
|
29
29
|
expect(page).to have_css('.st-controls-group', count: 2)
|
30
|
+
|
30
31
|
within(first('.st-controls-group')) do
|
31
32
|
expect(page).to have_content 'Standard widgets'
|
32
33
|
expect(page).to have_css('.st-block-controls__button')
|
33
34
|
end
|
35
|
+
|
34
36
|
within(all('.st-controls-group').last) do
|
35
37
|
expect(page).to have_content 'Exhibit item widgets'
|
36
38
|
expect(page).to have_css('.st-block-controls__button')
|
@@ -26,6 +26,7 @@ describe 'Uploaded Items Block', feature: true, js: true, versioning: true do
|
|
26
26
|
within('.dd-list') do
|
27
27
|
expect(page).to have_css('.card-title', text: '800x600.png')
|
28
28
|
fill_in 'Caption', with: 'Some caption text'
|
29
|
+
fill_in 'Link URL', with: 'https://example.com/'
|
29
30
|
end
|
30
31
|
|
31
32
|
attach_file('uploaded_item_url', fixture_file2)
|
@@ -41,8 +42,10 @@ describe 'Uploaded Items Block', feature: true, js: true, versioning: true do
|
|
41
42
|
expect(page).to have_css('p', text: text)
|
42
43
|
|
43
44
|
within('.uploaded-items-block') do
|
44
|
-
expect(page).to have_css('img[alt=""]', count:
|
45
|
+
expect(page).to have_css('img[alt=""]', count: 1)
|
46
|
+
expect(page).to have_css('img[alt="Some caption text"]', count: 1)
|
45
47
|
expect(page).to have_css '.caption', text: 'Some caption text'
|
48
|
+
expect(page).to have_link 'Some caption text', href: 'https://example.com/'
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
@@ -33,9 +33,10 @@ describe 'Report a Problem', type: :feature do
|
|
33
33
|
it 'accepts a problem report', js: true do
|
34
34
|
visit spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
|
35
35
|
click_on 'Feedback'
|
36
|
+
expect(page).to have_css('.alert-primary', text: '/dq287tq6352')
|
36
37
|
expect(find('#contact_form_current_url', visible: false).value).to end_with spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
|
37
|
-
fill_in '
|
38
|
-
fill_in '
|
38
|
+
fill_in 'Your name', with: 'Some Body'
|
39
|
+
fill_in 'Your email', with: 'test@example.com'
|
39
40
|
fill_in 'Message', with: 'This is my problem report'
|
40
41
|
|
41
42
|
expect do
|
@@ -47,8 +48,8 @@ describe 'Report a Problem', type: :feature do
|
|
47
48
|
visit spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
|
48
49
|
click_on 'Feedback'
|
49
50
|
expect(find('#contact_form_current_url', visible: false).value).to end_with spotlight.exhibit_solr_document_path(exhibit, id: 'dq287tq6352')
|
50
|
-
fill_in '
|
51
|
-
fill_in '
|
51
|
+
fill_in 'Your name', with: 'Some Body'
|
52
|
+
fill_in 'Your email', with: 'test@example.com'
|
52
53
|
page.evaluate_script("$('#contact_form_#{honeypot_field_name}').val('possible_spam@spam.com')")
|
53
54
|
fill_in 'Message', with: 'This is my problem report'
|
54
55
|
|
@@ -109,13 +109,13 @@ describe Spotlight::PagesHelper, type: :helper do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
describe '#content_editor_class' do
|
112
|
-
context '
|
112
|
+
context 'a sir-trevor backed page with a custom class' do
|
113
113
|
it 'has a custom class' do
|
114
114
|
expect(helper.content_editor_class(Spotlight::Page.new)).to eq 'js-st-instance'
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
context '
|
118
|
+
context 'a sir-trevor backed page with a derived class' do
|
119
119
|
it 'derives a css class name from the editor type' do
|
120
120
|
expect(helper.content_editor_class(Spotlight::Page.new(content_type: 'Something::Custom'))).to eq 'js-something-custom-instance'
|
121
121
|
end
|
@@ -17,6 +17,19 @@ describe Spotlight::TitleHelper, type: :helper do
|
|
17
17
|
expect(title).to have_selector 'h1', text: 'Section'
|
18
18
|
expect(title).to have_selector 'h1 small', text: 'Title'
|
19
19
|
end
|
20
|
+
|
21
|
+
it 'renders just the section title if that was all that was provided' do
|
22
|
+
allow(helper).to receive(:t).and_call_original
|
23
|
+
allow(helper).to receive(:t).with(:'.header', default: '').and_return('')
|
24
|
+
|
25
|
+
title = helper.page_title('Section')
|
26
|
+
|
27
|
+
expect(title).to have_selector 'h1', text: 'Section'
|
28
|
+
expect(title).not_to have_selector 'h1 small'
|
29
|
+
|
30
|
+
title = helper.instance_variable_get(:@page_title)
|
31
|
+
expect(title).to eq 'Section | Application'
|
32
|
+
end
|
20
33
|
end
|
21
34
|
|
22
35
|
describe '#set_html_page_title' do
|
data/spec/i18n_spec.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'i18n/tasks'
|
4
4
|
|
5
|
-
# rubocop:disable RSpec/DescribeClass
|
6
5
|
RSpec.describe 'I18n' do
|
7
6
|
let(:i18n) { I18n::Tasks::BaseTask.new }
|
8
7
|
let(:missing_keys) { i18n.missing_keys }
|
@@ -26,4 +25,3 @@ RSpec.describe 'I18n' do
|
|
26
25
|
expect(non_normalized).to be_empty, error_message
|
27
26
|
end
|
28
27
|
end
|
29
|
-
# rubocop:enable RSpec/DescribeClass
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
describe Spotlight::
|
3
|
+
describe Spotlight::AddUploadsFromCsv do
|
4
4
|
subject(:job) { described_class.new(data, exhibit, user) }
|
5
5
|
|
6
6
|
let(:exhibit) { FactoryBot.create(:exhibit) }
|
@@ -40,4 +40,16 @@ describe Spotlight::AddUploadsFromCSV do
|
|
40
40
|
|
41
41
|
job.perform_now
|
42
42
|
end
|
43
|
+
|
44
|
+
context 'with errors' do
|
45
|
+
it 'collects errors uploaded resources for each row of data' do
|
46
|
+
allow(Spotlight::IndexingCompleteMailer).to receive(:documents_indexed).and_return(double(deliver_now: true))
|
47
|
+
job.perform_now
|
48
|
+
expect(Spotlight::IndexingCompleteMailer).to have_received(:documents_indexed).with(
|
49
|
+
data, exhibit, user,
|
50
|
+
indexed_count: 1,
|
51
|
+
errors: { 1 => array_including(match(/relative URI: x/)), 2 => array_including(match(/Upload is invalid/)) }
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
43
55
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe Spotlight::IndexingCompleteMailer do
|
4
|
-
subject { described_class.documents_indexed [1, 2, 3], exhibit, user }
|
4
|
+
subject { described_class.documents_indexed [1, 2, 3], exhibit, user, indexed_count: 3 }
|
5
5
|
|
6
6
|
let(:user) { double(email: 'test@example.com') }
|
7
7
|
let(:exhibit) { double(title: 'Exhibit title') }
|
@@ -29,4 +29,14 @@ describe Spotlight::IndexingCompleteMailer do
|
|
29
29
|
it 'includes the exhibit title' do
|
30
30
|
expect(subject.body.encoded).to match exhibit.title
|
31
31
|
end
|
32
|
+
|
33
|
+
context 'with errors' do
|
34
|
+
subject { described_class.documents_indexed [], exhibit, user, indexed_count: 0, errors: { 1 => ['missing title'], 20 => ['whatever'] } }
|
35
|
+
|
36
|
+
it 'includes some errors' do
|
37
|
+
expect(subject.body.encoded).to match 'Errors'
|
38
|
+
expect(subject.body.encoded).to match 'Row 1: missing title'
|
39
|
+
expect(subject.body.encoded).to match 'Row 20: whatever'
|
40
|
+
end
|
41
|
+
end
|
32
42
|
end
|
@@ -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
|
|
@@ -28,7 +28,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'does not validate the presence of the title under a non-default locale' do
|
31
|
-
|
31
|
+
allow(I18n).to receive(:locale).and_return(:fr)
|
32
32
|
exhibit.title = ''
|
33
33
|
expect do
|
34
34
|
exhibit.save
|
@@ -402,6 +402,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
402
402
|
I18n.locale = 'fr'
|
403
403
|
persisted_exhibit.reload
|
404
404
|
expect(persisted_exhibit.title).to eq 'Titre français'
|
405
|
+
expect(persisted_exhibit.translated_title).to eq 'Titre français'
|
405
406
|
end
|
406
407
|
|
407
408
|
it 'has a translatable subtitle' do
|
@@ -417,5 +418,12 @@ describe Spotlight::Exhibit, type: :model do
|
|
417
418
|
persisted_exhibit.reload
|
418
419
|
expect(persisted_exhibit.description).to eq 'Description français'
|
419
420
|
end
|
421
|
+
|
422
|
+
it 'is nil if no translation has been prrovided' do
|
423
|
+
expect(persisted_exhibit.title).to eq 'Sample'
|
424
|
+
I18n.locale = 'es'
|
425
|
+
persisted_exhibit.reload
|
426
|
+
expect(persisted_exhibit.translated_title(default: '')).to eq nil
|
427
|
+
end
|
420
428
|
end
|
421
429
|
end
|
@@ -57,11 +57,6 @@ describe Spotlight::FeaturePage, type: :model do
|
|
57
57
|
expect(low_weight).not_to be_valid
|
58
58
|
expect(high_weight).not_to be_valid
|
59
59
|
end
|
60
|
-
|
61
|
-
it 'settable valid maximum' do
|
62
|
-
stub_const('Spotlight::Page::MAX_PAGES', 2000)
|
63
|
-
expect(high_weight).to be_valid
|
64
|
-
end
|
65
60
|
end
|
66
61
|
|
67
62
|
it { is_expected.to be_feature_page }
|
@@ -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
|