blacklight-spotlight 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spotlight/roles_controller.rb +1 -1
- data/lib/spotlight/version.rb +1 -1
- metadata +6 -610
- data/spec/controllers/application_controller_spec.rb +0 -30
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +0 -239
- data/spec/controllers/spotlight/admin_users_controller_spec.rb +0 -53
- data/spec/controllers/spotlight/appearances_controller_spec.rb +0 -88
- data/spec/controllers/spotlight/application_controller_spec.rb +0 -11
- data/spec/controllers/spotlight/attachments_controller_spec.rb +0 -28
- data/spec/controllers/spotlight/browse_controller_spec.rb +0 -133
- data/spec/controllers/spotlight/bulk_actions_controller_spec.rb +0 -124
- data/spec/controllers/spotlight/bulk_updates_controller_spec.rb +0 -77
- data/spec/controllers/spotlight/catalog_controller_spec.rb +0 -552
- data/spec/controllers/spotlight/confirmations_controller_spec.rb +0 -38
- data/spec/controllers/spotlight/contact_email_controller_spec.rb +0 -65
- data/spec/controllers/spotlight/contact_forms_controller_spec.rb +0 -38
- data/spec/controllers/spotlight/contacts_controller_spec.rb +0 -103
- data/spec/controllers/spotlight/custom_fields_controller_spec.rb +0 -62
- data/spec/controllers/spotlight/custom_search_fields_controller_spec.rb +0 -62
- data/spec/controllers/spotlight/dashboards_controller_spec.rb +0 -68
- data/spec/controllers/spotlight/exhibits_controller_spec.rb +0 -216
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +0 -251
- data/spec/controllers/spotlight/featured_images_controller_spec.rb +0 -77
- data/spec/controllers/spotlight/filters_controller_spec.rb +0 -72
- data/spec/controllers/spotlight/groups_controller_spec.rb +0 -103
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +0 -126
- data/spec/controllers/spotlight/job_trackers_controller_spec.rb +0 -37
- data/spec/controllers/spotlight/languages_controller_spec.rb +0 -70
- data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +0 -93
- data/spec/controllers/spotlight/pages_controller_spec.rb +0 -50
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +0 -71
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +0 -55
- data/spec/controllers/spotlight/resources_controller_spec.rb +0 -85
- data/spec/controllers/spotlight/roles_controller_spec.rb +0 -141
- data/spec/controllers/spotlight/search_configurations_controller_spec.rb +0 -141
- data/spec/controllers/spotlight/searches_controller_spec.rb +0 -195
- data/spec/controllers/spotlight/sites_controller_spec.rb +0 -67
- data/spec/controllers/spotlight/solr_controller_spec.rb +0 -116
- data/spec/controllers/spotlight/tags_controller_spec.rb +0 -56
- data/spec/controllers/spotlight/translations_controller_spec.rb +0 -132
- data/spec/controllers/spotlight/versions_controller_spec.rb +0 -56
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +0 -35
- data/spec/examples.txt +0 -1515
- data/spec/factories/bulk_updates.rb +0 -21
- data/spec/factories/contact_emails.rb +0 -8
- data/spec/factories/contact_images.rb +0 -8
- data/spec/factories/contacts.rb +0 -11
- data/spec/factories/custom_fields.rb +0 -9
- data/spec/factories/custom_search_fields.rb +0 -9
- data/spec/factories/exhibit_thumbnails.rb +0 -8
- data/spec/factories/exhibits.rb +0 -17
- data/spec/factories/featured_images.rb +0 -16
- data/spec/factories/group.rb +0 -17
- data/spec/factories/job_trackers.rb +0 -11
- data/spec/factories/language.rb +0 -8
- data/spec/factories/main_navigation.rb +0 -9
- data/spec/factories/pages.rb +0 -34
- data/spec/factories/resources.rb +0 -14
- data/spec/factories/roles.rb +0 -9
- data/spec/factories/searches.rb +0 -33
- data/spec/factories/tags.rb +0 -14
- data/spec/factories/translation.rb +0 -8
- data/spec/factories/users.rb +0 -50
- data/spec/features/about_page_spec.rb +0 -46
- data/spec/features/add_contacts_spec.rb +0 -63
- data/spec/features/add_custom_field_metadata_spec.rb +0 -88
- data/spec/features/add_iiif_manifest_spec.rb +0 -46
- data/spec/features/add_items_spec.rb +0 -135
- data/spec/features/autocomplete_typeahead_spec.rb +0 -89
- data/spec/features/browse_category_admin_spec.rb +0 -163
- data/spec/features/browse_category_navigation_spec.rb +0 -44
- data/spec/features/browse_category_spec.rb +0 -158
- data/spec/features/bulk_actions_spec.rb +0 -72
- data/spec/features/catalog_spec.rb +0 -57
- data/spec/features/confirm_email_spec.rb +0 -21
- data/spec/features/create_exhibit_spec.rb +0 -65
- data/spec/features/create_page_spec.rb +0 -21
- data/spec/features/dashboard_spec.rb +0 -34
- data/spec/features/edit_contact_spec.rb +0 -21
- data/spec/features/edit_search_fields_spec.rb +0 -79
- data/spec/features/exhibit_masthead_spec.rb +0 -112
- data/spec/features/exhibit_themes_spec.rb +0 -30
- data/spec/features/exhibits/add_tags_spec.rb +0 -35
- data/spec/features/exhibits/administration_spec.rb +0 -141
- data/spec/features/exhibits/custom_metadata_fields_spec.rb +0 -97
- data/spec/features/exhibits/custom_search_fields_spec.rb +0 -55
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +0 -49
- data/spec/features/exhibits/language_create_edit_spec.rb +0 -59
- data/spec/features/exhibits/translation_editing_spec.rb +0 -463
- data/spec/features/exhibits_index_spec.rb +0 -55
- data/spec/features/feature_page_spec.rb +0 -155
- data/spec/features/home_page_spec.rb +0 -102
- data/spec/features/import_exhibit_spec.rb +0 -58
- data/spec/features/item_admin_spec.rb +0 -59
- data/spec/features/javascript/about_page_admin_spec.rb +0 -21
- data/spec/features/javascript/block_controls_spec.rb +0 -42
- data/spec/features/javascript/blocks/browse_group_categories_block_spec.rb +0 -64
- data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +0 -46
- data/spec/features/javascript/blocks/featured_pages_block_spec.rb +0 -61
- data/spec/features/javascript/blocks/link_to_search_block_spec.rb +0 -46
- data/spec/features/javascript/blocks/rule_block_spec.rb +0 -23
- data/spec/features/javascript/blocks/search_result_block_spec.rb +0 -47
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +0 -232
- data/spec/features/javascript/blocks/solr_documents_carousel_block_spec.rb +0 -29
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +0 -94
- data/spec/features/javascript/browse_group_admin_spec.rb +0 -45
- data/spec/features/javascript/edit_in_place_spec.rb +0 -93
- data/spec/features/javascript/feature_page_admin_spec.rb +0 -140
- data/spec/features/javascript/home_page_edit_spec.rb +0 -34
- data/spec/features/javascript/locale_selector_spec.rb +0 -66
- data/spec/features/javascript/metadata_admin_spec.rb +0 -41
- data/spec/features/javascript/multi_image_select_spec.rb +0 -50
- data/spec/features/javascript/reindex_monitor_spec.rb +0 -23
- data/spec/features/javascript/roles_admin_spec.rb +0 -38
- data/spec/features/javascript/search_config_admin_spec.rb +0 -140
- data/spec/features/javascript/search_context_spec.rb +0 -88
- data/spec/features/main_navigation_spec.rb +0 -96
- data/spec/features/metadata_admin_spec.rb +0 -18
- data/spec/features/report_a_problem_spec.rb +0 -62
- data/spec/features/site_masthead_spec.rb +0 -91
- data/spec/features/site_users_management_spec.rb +0 -74
- data/spec/features/slideshow_spec.rb +0 -21
- data/spec/features/translation_scope_spec.rb +0 -27
- data/spec/fixtures/800x600.png +0 -0
- data/spec/fixtures/avatar.png +0 -0
- data/spec/fixtures/bulk-update-template.csv +0 -57
- data/spec/fixtures/csv-upload-fixture.csv +0 -4
- data/spec/fixtures/gk446cj2442-manifest.json +0 -58
- data/spec/fixtures/iiif_responses.rb +0 -312
- data/spec/fixtures/json-upload-fixture.json +0 -3
- data/spec/fixtures/sample_solr_documents.yml +0 -9385
- data/spec/fixtures/updated-bulk-update-template-no-cols.csv +0 -4
- data/spec/fixtures/updated-bulk-update-template-w-tags.csv +0 -4
- data/spec/fixtures/updated-bulk-update-template.csv +0 -4
- data/spec/helpers/spotlight/application_helper_spec.rb +0 -196
- data/spec/helpers/spotlight/browse_helper_spec.rb +0 -13
- data/spec/helpers/spotlight/crop_helper_spec.rb +0 -11
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +0 -163
- data/spec/helpers/spotlight/languages_helper_spec.rb +0 -79
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +0 -101
- data/spec/helpers/spotlight/masthead_helper_spec.rb +0 -51
- data/spec/helpers/spotlight/meta_helper_spec.rb +0 -33
- data/spec/helpers/spotlight/navbar_helper_spec.rb +0 -24
- data/spec/helpers/spotlight/pages_helper_spec.rb +0 -123
- data/spec/helpers/spotlight/roles_helper_spec.rb +0 -7
- data/spec/helpers/spotlight/search_configurations_helper_spec.rb +0 -23
- data/spec/helpers/spotlight/title_helper_spec.rb +0 -64
- data/spec/helpers/spotlight/translations_helper_spec.rb +0 -16
- data/spec/i18n_spec.rb +0 -27
- data/spec/jobs/spotlight/add_tags_job_spec.rb +0 -34
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +0 -58
- data/spec/jobs/spotlight/change_visibility_job_spec.rb +0 -30
- data/spec/jobs/spotlight/default_thumbnail_job_spec.rb +0 -14
- data/spec/jobs/spotlight/process_bulk_updates_csv_job_spec.rb +0 -86
- data/spec/jobs/spotlight/reindex_exhibit_job_spec.rb +0 -43
- data/spec/jobs/spotlight/reindex_job_spec.rb +0 -79
- data/spec/jobs/spotlight/remove_tags_job_spec.rb +0 -39
- data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +0 -33
- data/spec/lib/migration/iiif_spec.rb +0 -91
- data/spec/lib/migration/page_language_spec.rb +0 -25
- data/spec/lib/spotlight/catalog_spec.rb +0 -0
- data/spec/lib/spotlight/controller_spec.rb +0 -102
- data/spec/lib/spotlight/upload_field_config_spec.rb +0 -40
- data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +0 -42
- data/spec/models/sir_trevor_rails/block_spec.rb +0 -72
- data/spec/models/sir_trevor_rails/blocks/browse_block_spec.rb +0 -42
- data/spec/models/sir_trevor_rails/blocks/browse_group_categories_block_spec.rb +0 -41
- data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +0 -50
- data/spec/models/sir_trevor_rails/blocks/search_results_block_spec.rb +0 -23
- data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +0 -59
- data/spec/models/sir_trevor_rails/blocks/textable_spec.rb +0 -42
- data/spec/models/solr_document_spec.rb +0 -214
- data/spec/models/spotlight/ability_spec.rb +0 -118
- data/spec/models/spotlight/about_page_spec.rb +0 -19
- data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +0 -82
- data/spec/models/spotlight/analytics/ga_spec.rb +0 -22
- data/spec/models/spotlight/background_job_progress_spec.rb +0 -137
- data/spec/models/spotlight/blacklight_configuration_spec.rb +0 -649
- data/spec/models/spotlight/browse_category_search_builder_spec.rb +0 -51
- data/spec/models/spotlight/contact_email_spec.rb +0 -48
- data/spec/models/spotlight/contact_form_spec.rb +0 -94
- data/spec/models/spotlight/contact_image_spec.rb +0 -11
- data/spec/models/spotlight/contact_spec.rb +0 -38
- data/spec/models/spotlight/custom_field_spec.rb +0 -204
- data/spec/models/spotlight/custom_search_field_spec.rb +0 -56
- data/spec/models/spotlight/custom_translation_extension_spec.rb +0 -24
- data/spec/models/spotlight/exhibit_spec.rb +0 -383
- data/spec/models/spotlight/exhibit_thumbnail_spec.rb +0 -10
- data/spec/models/spotlight/feature_page_spec.rb +0 -87
- data/spec/models/spotlight/featured_image_spec.rb +0 -110
- data/spec/models/spotlight/field_metadata_spec.rb +0 -58
- data/spec/models/spotlight/filter_spec.rb +0 -19
- data/spec/models/spotlight/group_spec.rb +0 -19
- data/spec/models/spotlight/home_page_spec.rb +0 -38
- data/spec/models/spotlight/language_spec.rb +0 -42
- data/spec/models/spotlight/main_navigation_spec.rb +0 -19
- data/spec/models/spotlight/masthead_spec.rb +0 -45
- data/spec/models/spotlight/page_configurations_spec.rb +0 -45
- data/spec/models/spotlight/page_spec.rb +0 -293
- data/spec/models/spotlight/resource_spec.rb +0 -137
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +0 -52
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +0 -178
- data/spec/models/spotlight/resources/iiif_service_spec.rb +0 -57
- data/spec/models/spotlight/resources/upload_spec.rb +0 -71
- data/spec/models/spotlight/resources/web_spec.rb +0 -25
- data/spec/models/spotlight/role_spec.rb +0 -51
- data/spec/models/spotlight/search_spec.rb +0 -125
- data/spec/models/spotlight/site_spec.rb +0 -9
- data/spec/models/spotlight/sitemap_spec.rb +0 -113
- data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +0 -56
- data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +0 -38
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +0 -48
- data/spec/models/spotlight/user_spec.rb +0 -26
- data/spec/models/translation_spec.rb +0 -26
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +0 -132
- data/spec/routing/spotlight/exhibit_catalog_spec.rb +0 -34
- data/spec/routing/spotlight/featured_images_spec.rb +0 -23
- data/spec/routing/spotlight/pages_routing_spec.rb +0 -42
- data/spec/services/spotlight/bulk_updates_csv_template_service_spec.rb +0 -26
- data/spec/services/spotlight/carrierwave_file_resolver_spec.rb +0 -16
- data/spec/services/spotlight/clone_translated_page_from_locale_spec.rb +0 -30
- data/spec/services/spotlight/etl/context_spec.rb +0 -66
- data/spec/services/spotlight/etl/executor_spec.rb +0 -149
- data/spec/services/spotlight/etl/pipeline_spec.rb +0 -22
- data/spec/services/spotlight/etl/solr_loader_spec.rb +0 -76
- data/spec/services/spotlight/etl/step_spec.rb +0 -70
- data/spec/services/spotlight/exhibit_import_export_service_spec.rb +0 -569
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +0 -94
- data/spec/services/spotlight/invite_users_service_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -146
- data/spec/support/controllers/engine_helpers.rb +0 -9
- data/spec/support/disable_friendly_id_deprecation_warnings.rb +0 -11
- data/spec/support/features/capybara_default_max_wait_metadata_helper.rb +0 -20
- data/spec/support/features/test_features_helpers.rb +0 -92
- data/spec/support/helpers/controller_level_helpers.rb +0 -25
- data/spec/support/stub_iiif_response.rb +0 -26
- data/spec/support/views/test_view_helpers.rb +0 -21
- data/spec/test_app_templates/Gemfile.extra +0 -2
- data/spec/test_app_templates/carrierwave.rb +0 -8
- data/spec/test_app_templates/catalog_controller.rb +0 -108
- data/spec/test_app_templates/fixture.css +0 -0
- data/spec/test_app_templates/fixture.png +0 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -71
- data/spec/test_app_templates/spotlight_test.rake +0 -14
- data/spec/uploaders/spotlight/attachment_uploader_spec.rb +0 -27
- data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +0 -33
- data/spec/views/shared/_analytics.html.erb_spec.rb +0 -17
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +0 -127
- data/spec/views/shared/_header_navbar.html.erb_spec.rb +0 -12
- data/spec/views/shared/_masthead.html.erb_spec.rb +0 -91
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +0 -102
- data/spec/views/spotlight/about_pages/_empty.html.erb_spec.rb +0 -28
- data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +0 -24
- data/spec/views/spotlight/about_pages/index.html.erb_spec.rb +0 -69
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +0 -22
- data/spec/views/spotlight/browse/show.html.erb_spec.rb +0 -65
- data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +0 -63
- data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +0 -39
- data/spec/views/spotlight/catalog/edit.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +0 -43
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +0 -45
- data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +0 -94
- data/spec/views/spotlight/dashboards/analytics.html.erb_spec.rb +0 -33
- data/spec/views/spotlight/exhibits/_exhibit_card.html.erb_spec.rb +0 -46
- data/spec/views/spotlight/exhibits/_form.html.erb_spec.rb +0 -38
- data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +0 -29
- data/spec/views/spotlight/exhibits/index.html.erb_spec.rb +0 -140
- data/spec/views/spotlight/feature_pages/_empty.html.erb_spec.rb +0 -28
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +0 -45
- data/spec/views/spotlight/featured_images/_form.html.erb_spec.rb +0 -32
- data/spec/views/spotlight/featured_images/_upload_form.html.erb_spec.rb +0 -32
- data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +0 -28
- data/spec/views/spotlight/home_pages/_sidebar.html.erb_spec.rb +0 -12
- data/spec/views/spotlight/job_trackers/show.html.erb_spec.rb +0 -65
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +0 -23
- data/spec/views/spotlight/pages/_form.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/pages/edit.html.erb_spec.rb +0 -68
- data/spec/views/spotlight/pages/index.html.erb_spec.rb +0 -42
- data/spec/views/spotlight/pages/new.html.erb_spec.rb +0 -21
- data/spec/views/spotlight/pages/show.html.erb_spec.rb +0 -84
- data/spec/views/spotlight/resources/_external_resources_form.html.erb_spec.rb +0 -36
- data/spec/views/spotlight/resources/new.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/roles/index.html.erb_spec.rb +0 -30
- data/spec/views/spotlight/search_configurations/_facet_metadata.html.erb_spec.rb +0 -58
- data/spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb +0 -54
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +0 -54
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +0 -40
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +0 -37
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +0 -40
- data/spec/views/spotlight/searches/index.html.erb_spec.rb +0 -33
- data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb_spec.rb +0 -20
- data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +0 -10
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +0 -43
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +0 -34
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +0 -53
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +0 -54
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +0 -42
- data/spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb +0 -25
- data/spec/views/spotlight/tags/index.html.erb_spec.rb +0 -27
- data/spec/views/spotlight/translations/_import.html.erb_spec.rb +0 -24
- data/spec/views/spotlight/translations/_page.html.erb_spec.rb +0 -76
@@ -1,383 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Exhibit, type: :model do
|
4
|
-
subject(:exhibit) { FactoryBot.build(:exhibit, title: 'Sample') }
|
5
|
-
|
6
|
-
it 'has a title' do
|
7
|
-
subject.title = 'Test title'
|
8
|
-
expect(subject.title).to eq 'Test title'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'has a subtitle' do
|
12
|
-
subject.subtitle = 'Test subtitle'
|
13
|
-
expect(subject.subtitle).to eq 'Test subtitle'
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has a description that strips html tags' do
|
17
|
-
subject.description = 'Test <b>description</b>'
|
18
|
-
subject.save!
|
19
|
-
expect(subject.description).to eq 'Test description'
|
20
|
-
end
|
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
|
-
|
30
|
-
describe 'validations' do
|
31
|
-
it 'validates the presence of the title' do
|
32
|
-
exhibit.title = ''
|
33
|
-
expect do
|
34
|
-
exhibit.save
|
35
|
-
end.to change { exhibit.errors[:title].count }.by(1)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'does not validate the presence of the title under a non-default locale' do
|
39
|
-
allow(I18n).to receive(:locale).and_return(:fr)
|
40
|
-
exhibit.title = ''
|
41
|
-
expect do
|
42
|
-
exhibit.save
|
43
|
-
end.not_to(change { exhibit.errors[:title].count })
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'contact_emails' do
|
48
|
-
before do
|
49
|
-
subject.contact_emails_attributes = [{ 'email' => 'chris@example.com' }, { 'email' => 'jesse@stanford.edu' }]
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'accepts nested contact_emails' do
|
53
|
-
expect(subject.contact_emails.size).to eq 2
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'has a #to_s' do
|
58
|
-
expect(subject.to_s).to eq 'Sample'
|
59
|
-
subject.title = 'New Title'
|
60
|
-
expect(subject.to_s).to eq 'New Title'
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'that is saved' do
|
64
|
-
before { subject.save! }
|
65
|
-
|
66
|
-
it 'has a configuration' do
|
67
|
-
expect(subject.blacklight_configuration).to be_kind_of Spotlight::BlacklightConfiguration
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'has an unpublished search' do
|
71
|
-
expect(subject.searches).to have(1).search
|
72
|
-
expect(subject.searches.published).to be_empty
|
73
|
-
expect(subject.searches.first.query_params).to be_empty
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#main_navigations' do
|
78
|
-
subject { FactoryBot.create(:exhibit, title: 'Sample') }
|
79
|
-
|
80
|
-
it 'has main navigations' do
|
81
|
-
expect(subject.main_navigations).to have(3).main_navigations
|
82
|
-
expect(subject.main_navigations.map(&:label).compact).to be_blank
|
83
|
-
expect(subject.main_navigations.map(&:weight)).to eq [0, 1, 2]
|
84
|
-
end
|
85
|
-
|
86
|
-
it "uses the engine's configuration for default navigations" do
|
87
|
-
expect(Spotlight::Engine.config).to receive(:exhibit_main_navigation).and_return(%i[a b])
|
88
|
-
expect(subject.main_navigations).to have(2).main_navigations
|
89
|
-
expect(subject.main_navigations.map(&:nav_type).compact).to match_array %w[a b]
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe 'contacts' do
|
94
|
-
before do
|
95
|
-
subject.contacts_attributes = [
|
96
|
-
{ 'show_in_sidebar' => '0', 'name' => 'Justin Coyne', 'contact_info' => { 'email' => 'jcoyne@justincoyne.com', 'title' => '', 'location' => 'US' } },
|
97
|
-
{ 'show_in_sidebar' => '0', 'name' => '', 'contact_info' => { 'email' => '', 'title' => 'Librarian', 'location' => '' } }
|
98
|
-
]
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'accepts nested contacts' do
|
102
|
-
expect(subject.contacts.size).to eq 2
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe '#main_about_page' do
|
107
|
-
let!(:about_page) { FactoryBot.create(:about_page, exhibit: exhibit, published: false) }
|
108
|
-
let!(:about_page2) { FactoryBot.create(:about_page, exhibit: exhibit, published: true) }
|
109
|
-
let(:about_page2_es) { about_page2.clone_for_locale('es') }
|
110
|
-
|
111
|
-
it 'is the first published about page' do
|
112
|
-
expect(exhibit.main_about_page).to eq about_page2
|
113
|
-
end
|
114
|
-
|
115
|
-
describe 'when under a non-default locale' do
|
116
|
-
before { I18n.locale = 'es' }
|
117
|
-
|
118
|
-
after { I18n.locale = 'en' }
|
119
|
-
|
120
|
-
it 'loads the first published about page for that locale' do
|
121
|
-
about_page2_es.published = true
|
122
|
-
about_page2_es.save
|
123
|
-
expect(exhibit.main_about_page).to eq about_page2_es
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'is nil when there is no locale specific page published' do
|
127
|
-
about_page2_es.published = false
|
128
|
-
about_page2_es.save
|
129
|
-
expect(exhibit.main_about_page).to be_nil
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe '#themes' do
|
135
|
-
context 'when no themes_selector proc is set' do
|
136
|
-
it 'is the configured themes' do
|
137
|
-
expect(subject.themes).to eq Spotlight::Engine.config.exhibit_themes
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'when a themes_selector proc is set' do
|
142
|
-
before do
|
143
|
-
allow(described_class).to receive(:themes_selector).and_return(
|
144
|
-
->(*) { %w[default coolCustomTheme] }
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'is the array of themes returned by the proc' do
|
149
|
-
expect(subject.themes).to eq(%w[default coolCustomTheme])
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe 'import' do
|
155
|
-
it 'removes the default browse category' do
|
156
|
-
subject.save
|
157
|
-
expect { subject.import({}) }.to change { subject.searches.count }.by(0)
|
158
|
-
expect { subject.import('searches' => [{ 'title' => 'All exhibit items', 'slug' => 'all-exhibit-items' }]) }.to change { subject.searches.count }.by(0)
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'imports nested attributes from the hash' do
|
162
|
-
subject.save
|
163
|
-
subject.import 'title' => 'xyz'
|
164
|
-
expect(subject.title).to eq 'xyz'
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe '#blacklight_config' do
|
169
|
-
subject { FactoryBot.create(:exhibit) }
|
170
|
-
|
171
|
-
before do
|
172
|
-
subject.blacklight_configuration.index = { timestamp_field: 'timestamp_field' }
|
173
|
-
subject.save!
|
174
|
-
subject.reload
|
175
|
-
end
|
176
|
-
|
177
|
-
it 'creates a blacklight_configuration from the database' do
|
178
|
-
expect(subject.blacklight_config.index.timestamp_field).to eq 'timestamp_field'
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe '#solr_data' do
|
183
|
-
subject { exhibit.solr_data }
|
184
|
-
|
185
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
186
|
-
|
187
|
-
context 'when not filtering by exhibit' do
|
188
|
-
before do
|
189
|
-
allow(Spotlight::Engine.config).to receive(:filter_resources_by_exhibit).and_return(false)
|
190
|
-
end
|
191
|
-
|
192
|
-
it 'is blank' do
|
193
|
-
expect(subject).to be_blank
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
context 'when no filters have been defined' do
|
198
|
-
before do
|
199
|
-
allow(Spotlight::Engine.config).to receive(:filter_resources_by_exhibit).and_return(true)
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'provides a solr field with the exhibit slug' do
|
203
|
-
expect(subject).to include("spotlight_exhibit_slug_#{exhibit.slug}_bsi" => true)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
context 'with a filter' do
|
208
|
-
before do
|
209
|
-
exhibit.filters.create(field: 'orcid_ssim', value: '123')
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'uses the provided filter' do
|
213
|
-
expect(subject).to include('orcid_ssim' => '123')
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe '#analytics' do
|
219
|
-
subject { FactoryBot.create(:exhibit) }
|
220
|
-
|
221
|
-
let(:ga_data) { OpenStruct.new(pageviews: 123) }
|
222
|
-
let(:mock_analytics) { double(Spotlight::Analytics::Ga) }
|
223
|
-
|
224
|
-
before do
|
225
|
-
allow(Spotlight::Analytics::Ga).to receive(:new).and_return(mock_analytics)
|
226
|
-
allow(mock_analytics).to receive(:enabled?).and_return(true)
|
227
|
-
allow(mock_analytics).to receive(:exhibit_data).with(subject, hash_including(:start_date)).and_return(ga_data)
|
228
|
-
end
|
229
|
-
|
230
|
-
it 'requests analytics data' do
|
231
|
-
expect(subject.analytics.pageviews).to eq 123
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
describe '#page_analytics' do
|
236
|
-
subject { FactoryBot.create(:exhibit) }
|
237
|
-
|
238
|
-
let(:ga_data) { [OpenStruct.new(pageviews: 123)] }
|
239
|
-
let(:mock_analytics) { double(Spotlight::Analytics::Ga) }
|
240
|
-
|
241
|
-
before do
|
242
|
-
allow(Spotlight::Analytics::Ga).to receive(:new).and_return(mock_analytics)
|
243
|
-
allow(mock_analytics).to receive(:enabled?).and_return(true)
|
244
|
-
allow(mock_analytics).to receive(:page_data).with(subject, hash_including(:start_date)).and_return(ga_data)
|
245
|
-
end
|
246
|
-
|
247
|
-
it 'requests analytics data' do
|
248
|
-
expect(subject.page_analytics.length).to eq 1
|
249
|
-
expect(subject.page_analytics.first.pageviews).to eq 123
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
describe '#reindex_later' do
|
254
|
-
subject { FactoryBot.create(:exhibit) }
|
255
|
-
|
256
|
-
it 'queues a reindex job for the exhibit' do
|
257
|
-
expect(Spotlight::ReindexExhibitJob).to receive(:perform_later).with(subject, user: nil)
|
258
|
-
subject.reindex_later
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
describe '#solr_documents' do
|
263
|
-
let(:blacklight_config) { Blacklight::Configuration.new }
|
264
|
-
let(:slug) { 'some_slug' }
|
265
|
-
let(:filter) do
|
266
|
-
Spotlight::Filter.new(field: subject.send(:default_filter_field),
|
267
|
-
value: subject.send(:default_filter_value))
|
268
|
-
end
|
269
|
-
|
270
|
-
before do
|
271
|
-
allow(subject).to receive(:blacklight_config).and_return(blacklight_config)
|
272
|
-
allow(subject).to receive(:slug).and_return(slug)
|
273
|
-
allow(subject).to receive(:filters).and_return([filter])
|
274
|
-
end
|
275
|
-
|
276
|
-
it 'enumerates the documents in the exhibit' do
|
277
|
-
expect(subject.solr_documents).to be_a Enumerable
|
278
|
-
end
|
279
|
-
|
280
|
-
it 'pages through the index' do
|
281
|
-
allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).and_return(double(documents: [1, 2, 3]))
|
282
|
-
allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 3)).and_return(double(documents: [4, 5, 6]))
|
283
|
-
allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 6)).and_return(double(documents: []))
|
284
|
-
|
285
|
-
expect(subject.solr_documents.to_a).to match_array [1, 2, 3, 4, 5, 6]
|
286
|
-
end
|
287
|
-
|
288
|
-
context 'with filter_resources_by_exhibit enabled' do
|
289
|
-
before do
|
290
|
-
allow(Spotlight::Engine.config).to receive(:filter_resources_by_exhibit).and_return(true)
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'filters the solr results using the exhibit filter' do
|
294
|
-
expected_query_params = { fq: ["{!term f=spotlight_exhibit_slug_#{subject.slug}_bsi}true"] }
|
295
|
-
allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(expected_query_params)).and_return(double(documents: []))
|
296
|
-
expect(subject.solr_documents.to_a).to be_blank
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
context 'with filter_resources_by_exhibit disabled' do
|
301
|
-
before do
|
302
|
-
allow(Spotlight::Engine.config).to receive(:filter_resources_by_exhibit).and_return(false)
|
303
|
-
end
|
304
|
-
|
305
|
-
it 'does not filters the solr results' do
|
306
|
-
allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_excluding(fq: [subject.solr_data])).and_return(double(documents: []))
|
307
|
-
expect(subject.solr_documents.to_a).to be_blank
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
describe '#requested_by' do
|
313
|
-
context 'with multiple exhibit users' do
|
314
|
-
let!(:exhibit_admin) { FactoryBot.create(:exhibit_admin, exhibit: subject) }
|
315
|
-
let!(:another_exhibit_admin) { FactoryBot.create(:exhibit_admin, exhibit: subject) }
|
316
|
-
|
317
|
-
it 'is the first listed user' do
|
318
|
-
expect(subject.requested_by).to eq exhibit_admin
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
context 'if no user has roles on the exhibit' do
|
323
|
-
it 'is nil' do
|
324
|
-
expect(subject.requested_by).to be_nil
|
325
|
-
end
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
describe '#reindex_progress' do
|
330
|
-
it 'returns the latest log entry that is not unstarted' do
|
331
|
-
reindex_progress = subject.reindex_progress
|
332
|
-
expect(reindex_progress).to be_a Spotlight::BackgroundJobProgress
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'is expected to be versioned' do
|
337
|
-
expect(subject).to be_versioned
|
338
|
-
end
|
339
|
-
|
340
|
-
describe 'translatable fields' do
|
341
|
-
let(:persisted_exhibit) { FactoryBot.create(:exhibit, title: 'Sample', subtitle: 'SubSample', description: 'Description') }
|
342
|
-
|
343
|
-
before do
|
344
|
-
FactoryBot.create(:translation, locale: 'fr', exhibit: persisted_exhibit, key: "#{persisted_exhibit.slug}.title", value: 'Titre français')
|
345
|
-
FactoryBot.create(:translation, locale: 'fr', exhibit: persisted_exhibit, key: "#{persisted_exhibit.slug}.subtitle", value: 'Sous-titre français')
|
346
|
-
FactoryBot.create(:translation, locale: 'fr', exhibit: persisted_exhibit, key: "#{persisted_exhibit.slug}.description", value: 'Description français')
|
347
|
-
Translation.current_exhibit = persisted_exhibit
|
348
|
-
end
|
349
|
-
|
350
|
-
after do
|
351
|
-
I18n.locale = 'en'
|
352
|
-
end
|
353
|
-
|
354
|
-
it 'has a translatable title' do
|
355
|
-
expect(persisted_exhibit.title).to eq 'Sample'
|
356
|
-
I18n.locale = 'fr'
|
357
|
-
persisted_exhibit.reload
|
358
|
-
expect(persisted_exhibit.title).to eq 'Titre français'
|
359
|
-
expect(persisted_exhibit.translated_title).to eq 'Titre français'
|
360
|
-
end
|
361
|
-
|
362
|
-
it 'has a translatable subtitle' do
|
363
|
-
expect(persisted_exhibit.subtitle).to eq 'SubSample'
|
364
|
-
I18n.locale = 'fr'
|
365
|
-
persisted_exhibit.reload
|
366
|
-
expect(persisted_exhibit.subtitle).to eq 'Sous-titre français'
|
367
|
-
end
|
368
|
-
|
369
|
-
it 'has a translatable description' do
|
370
|
-
expect(persisted_exhibit.description).to eq 'Description'
|
371
|
-
I18n.locale = 'fr'
|
372
|
-
persisted_exhibit.reload
|
373
|
-
expect(persisted_exhibit.description).to eq 'Description français'
|
374
|
-
end
|
375
|
-
|
376
|
-
it 'is nil if no translation has been prrovided' do
|
377
|
-
expect(persisted_exhibit.title).to eq 'Sample'
|
378
|
-
I18n.locale = 'es'
|
379
|
-
persisted_exhibit.reload
|
380
|
-
expect(persisted_exhibit.translated_title(default: '')).to eq nil
|
381
|
-
end
|
382
|
-
end
|
383
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::ExhibitThumbnail do
|
4
|
-
subject(:exhibit_thumbnail) { described_class.new }
|
5
|
-
|
6
|
-
it 'includes the appropriate size in the iiif_url' do
|
7
|
-
exhibit_thumbnail.iiif_tilesource = 'http://example.com/iiif/abc123/info.json'
|
8
|
-
expect(exhibit_thumbnail.iiif_url).to match(%r{/full/400,400/})
|
9
|
-
end
|
10
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::FeaturePage, type: :model do
|
4
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
|
-
|
6
|
-
describe 'default_scope' do
|
7
|
-
let!(:page1) { FactoryBot.create(:feature_page, weight: 5, exhibit: exhibit) }
|
8
|
-
let!(:page2) { FactoryBot.create(:feature_page, weight: 1, exhibit: exhibit) }
|
9
|
-
let!(:page3) { FactoryBot.create(:feature_page, weight: 10, exhibit: exhibit) }
|
10
|
-
|
11
|
-
it 'orders by weight' do
|
12
|
-
expect(described_class.all.map(&:weight)).to eq [1, 5, 10]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'display_sidebar?' do
|
17
|
-
let(:parent) { FactoryBot.create(:feature_page, exhibit: exhibit) }
|
18
|
-
let!(:child) { FactoryBot.create(:feature_page, parent_page: parent, exhibit: exhibit) }
|
19
|
-
let!(:unpublished_parent) { FactoryBot.create(:feature_page, published: false, exhibit: exhibit) }
|
20
|
-
let!(:unpublished_child) { FactoryBot.create(:feature_page, parent_page: unpublished_parent, published: false, exhibit: exhibit) }
|
21
|
-
|
22
|
-
before { unpublished_parent.display_sidebar = false }
|
23
|
-
|
24
|
-
it 'is set to true if the page has a published child' do
|
25
|
-
expect(parent).to be_display_sidebar
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'is set to true on the parent of published child pages' do
|
29
|
-
parent.display_sidebar = false
|
30
|
-
expect(parent).to be_display_sidebar
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'is set to true when publishing a child page' do
|
34
|
-
expect(unpublished_parent).not_to be_display_sidebar
|
35
|
-
unpublished_parent.published = true
|
36
|
-
unpublished_child.published = true
|
37
|
-
unpublished_child.save
|
38
|
-
expect(unpublished_parent).to be_display_sidebar
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe 'weight' do
|
43
|
-
let(:good_weight) { FactoryBot.build(:feature_page, weight: 10, exhibit: exhibit) }
|
44
|
-
let(:low_weight) { FactoryBot.build(:feature_page, weight: -1, exhibit: exhibit) }
|
45
|
-
let(:high_weight) { FactoryBot.build(:feature_page, weight: 1200, exhibit: exhibit) }
|
46
|
-
|
47
|
-
it 'defaults to 1000' do
|
48
|
-
expect(described_class.new.weight).to eq 1000
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'validates when in the 0 to 50 range' do
|
52
|
-
expect(good_weight).to be_valid
|
53
|
-
expect(good_weight.weight).to eq 10
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'raises an error when outside of the 0 to 50 range' do
|
57
|
-
expect(low_weight).not_to be_valid
|
58
|
-
expect(high_weight).not_to be_valid
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
it { is_expected.to be_feature_page }
|
63
|
-
it { is_expected.not_to be_about_page }
|
64
|
-
|
65
|
-
describe 'relationships' do
|
66
|
-
let(:parent) { FactoryBot.create(:feature_page, exhibit: exhibit) }
|
67
|
-
let!(:child1) { FactoryBot.create(:feature_page, parent_page: parent, exhibit: exhibit) }
|
68
|
-
let!(:child2) { FactoryBot.create(:feature_page, parent_page: parent, exhibit: exhibit) }
|
69
|
-
|
70
|
-
it 'child pages should have a parent_page' do
|
71
|
-
[child1, child2].each do |child|
|
72
|
-
expect(child.parent_page).to eq parent
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'parent pages should have child_pages' do
|
77
|
-
expect(parent.child_pages.length).to eq 2
|
78
|
-
expect(parent.child_pages.map(&:id)).to eq [child1.id, child2.id]
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'defines top_level_page? properly' do
|
82
|
-
expect(parent).to be_top_level_page
|
83
|
-
expect(child1).not_to be_top_level_page
|
84
|
-
expect(child2).not_to be_top_level_page
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::FeaturedImage do
|
4
|
-
subject(:featured_image) { described_class.new }
|
5
|
-
|
6
|
-
let(:temp_image) { FactoryBot.create(:temporary_image) }
|
7
|
-
|
8
|
-
describe '#bust_containing_resource_caches' do
|
9
|
-
let!(:feature_page) { FactoryBot.create(:feature_page, thumbnail: temp_image) }
|
10
|
-
let!(:feature_page2) { FactoryBot.create(:feature_page, thumbnail: temp_image) }
|
11
|
-
|
12
|
-
it 'changes the updated_at for all resources that might be using this image' do
|
13
|
-
temp_image.save
|
14
|
-
|
15
|
-
expect(feature_page.updated_at).to be < feature_page.reload.updated_at
|
16
|
-
expect(feature_page2.updated_at).to be < feature_page2.reload.updated_at
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with an uploaded image' do
|
21
|
-
it 'copies the temporary uploaded image to this model' do
|
22
|
-
featured_image.source = 'remote'
|
23
|
-
featured_image.upload_id = temp_image.id
|
24
|
-
|
25
|
-
featured_image.save
|
26
|
-
|
27
|
-
expect(featured_image.image.filename).to eq temp_image.image.filename
|
28
|
-
expect(featured_image.image.read).to eq temp_image.image.read
|
29
|
-
|
30
|
-
expect { temp_image.reload }.to raise_exception ActiveRecord::RecordNotFound
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#iiif_url' do
|
35
|
-
let(:iiif_tilesource) { 'http://example.com/iiif/abc123/info.json' }
|
36
|
-
let(:iiif_region) { '0,0,400,300' }
|
37
|
-
|
38
|
-
describe 'tilesource' do
|
39
|
-
it 'is nil when not present' do
|
40
|
-
expect(subject.iiif_url).to be_nil
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'is included when present (without "/info.json")' do
|
44
|
-
subject.iiif_tilesource = iiif_tilesource
|
45
|
-
expect(subject.iiif_url).to match(%r{^http://example.com/iiif/abc123/})
|
46
|
-
expect(subject.iiif_url).not_to include('info.json')
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'with an uploaded image' do
|
50
|
-
before do
|
51
|
-
featured_image.image = temp_image.image
|
52
|
-
featured_image.save!
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'points at the RIIIF endpoint' do
|
56
|
-
expect(subject.iiif_url).to match(%r{^/images/\d+-.+/})
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'region' do
|
62
|
-
before { subject.iiif_tilesource = iiif_tilesource }
|
63
|
-
|
64
|
-
it 'is included when present' do
|
65
|
-
subject.iiif_region = iiif_region
|
66
|
-
expect(subject.iiif_url).to match(%r{/abc123/#{iiif_region}/})
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'is "full" when not present' do
|
70
|
-
expect(subject.iiif_url).to match(%r{/abc123/full/})
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe '#document' do
|
76
|
-
before { subject.source = 'exhibit' }
|
77
|
-
|
78
|
-
it 'fetches the document given the stored GlobalID' do
|
79
|
-
subject.document_global_id = 'gid://internal/SolrDocument/yn959jw9550'
|
80
|
-
|
81
|
-
expect(subject.document).to be_a SolrDocument
|
82
|
-
expect(subject.document[:id]).to eq 'yn959jw9550'
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'busts memoization if the GlobalID is updated' do
|
86
|
-
subject.document_global_id = 'gid://internal/SolrDocument/yn959jw9550'
|
87
|
-
expect(subject.document[:id]).to eq 'yn959jw9550'
|
88
|
-
|
89
|
-
subject.document_global_id = 'gid://internal/SolrDocument/gk446cj2442'
|
90
|
-
expect(subject.document[:id]).to eq 'gk446cj2442'
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'returns nil if the document cannot be found via GlobalID' do
|
94
|
-
subject.document_global_id = 'gid://internal/SolrDocument/NotARealDoc'
|
95
|
-
|
96
|
-
expect(subject.document).to be_nil
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#file_present?' do
|
101
|
-
it 'is false when the image file is not present' do
|
102
|
-
expect(subject.file_present?).to be false
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'is true when the image file is present' do
|
106
|
-
expect(subject).to receive(:image).and_return(double('CarrierWaveUpload', file: 'uploaded file content'))
|
107
|
-
expect(subject.file_present?).to be true
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::FieldMetadata do
|
4
|
-
subject { described_class.new(exhibit, repository, blacklight_config) }
|
5
|
-
|
6
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
|
-
let(:repository) { double }
|
8
|
-
let(:blacklight_config) do
|
9
|
-
Blacklight::Configuration.new do |config|
|
10
|
-
config.add_facet_field 'a'
|
11
|
-
config.add_facet_field 'b'
|
12
|
-
config.add_facet_field 'some_key', field: 'c'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:facet_response) do
|
17
|
-
{
|
18
|
-
facet_counts: {
|
19
|
-
facet_fields: {
|
20
|
-
a: { 'a' => 1, 'b' => 2, 'c' => 3 },
|
21
|
-
b: { 'b' => 1 },
|
22
|
-
c: { 7 => 1, 8 => 2, 9 => 3 }
|
23
|
-
},
|
24
|
-
|
25
|
-
facet_queries: {
|
26
|
-
'a:[* TO *]' => 5,
|
27
|
-
'b:[* TO *]' => 10,
|
28
|
-
'c:[* TO *]' => 15
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}.with_indifferent_access
|
32
|
-
end
|
33
|
-
|
34
|
-
before do
|
35
|
-
allow(repository).to receive(:search).with(an_instance_of(SearchBuilder)).and_return(Blacklight::Solr::Response.new(facet_response, {}))
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#field' do
|
39
|
-
it 'has a document count' do
|
40
|
-
expect(subject.field('a')[:document_count]).to eq 5
|
41
|
-
expect(subject.field('b')[:document_count]).to eq 10
|
42
|
-
expect(subject.field('some_key')[:document_count]).to eq 15
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'has a value count' do
|
46
|
-
expect(subject.field('a')[:value_count]).to eq 3
|
47
|
-
expect(subject.field('b')[:value_count]).to eq 1
|
48
|
-
expect(subject.field('some_key')[:value_count]).to eq 3
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'for a missing field' do
|
52
|
-
it 'has reasonable default values' do
|
53
|
-
expect(subject.field('d')[:document_count]).to eq 0
|
54
|
-
expect(subject.field('d')[:value_count]).to eq 0
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Filter do
|
4
|
-
context 'with a simple string field' do
|
5
|
-
subject { described_class.new(field: 'x', value: 'y') }
|
6
|
-
|
7
|
-
it 'passes the value through' do
|
8
|
-
expect(subject.to_hash).to eq 'x' => 'y'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'with a boolean field' do
|
13
|
-
subject { described_class.new(field: 'x_bsi', value: 'true') }
|
14
|
-
|
15
|
-
it 'casts the value to a boolean' do
|
16
|
-
expect(subject.to_hash).to eq 'x_bsi' => true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,19 +0,0 @@
|
|
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
|