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,178 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
class TestMetadataClass
|
6
|
-
def initialize(*); end
|
7
|
-
|
8
|
-
def to_solr
|
9
|
-
{ 'test_field' => 'metadata-to-solr' }
|
10
|
-
end
|
11
|
-
|
12
|
-
def label; end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe Spotlight::Resources::IiifManifest do
|
16
|
-
subject { described_class.new(url: url, manifest: manifest, collection: collection) }
|
17
|
-
|
18
|
-
let(:url) { 'uri://to-manifest' }
|
19
|
-
|
20
|
-
let(:collection) { double(compound_id: '1') }
|
21
|
-
let(:manifest_fixture) { test_manifest1 }
|
22
|
-
|
23
|
-
before do
|
24
|
-
stub_iiif_response_for_url(url, manifest_fixture)
|
25
|
-
subject.with_exhibit(exhibit)
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#to_solr' do
|
29
|
-
let(:manifest) { Spotlight::Resources::IiifService.new(url).send(:object) }
|
30
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
31
|
-
|
32
|
-
describe 'id' do
|
33
|
-
it 'is an MD5 hexdigest of the exhibit id and the and the url' do
|
34
|
-
expected = Digest::MD5.hexdigest("#{exhibit.id}-#{url}")
|
35
|
-
expect(subject.to_solr[:id]).to eq expected
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'label' do
|
40
|
-
it 'is included in the solr document when present' do
|
41
|
-
expect(subject.to_solr['full_title_tesim']).to eq 'Test Manifest 1'
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'indexes to multiple fields when configured' do
|
45
|
-
allow(Spotlight::Engine.config).to receive(:iiif_title_fields).at_least(:once).and_return(%w[title_field1 title_field2])
|
46
|
-
|
47
|
-
expect(subject.to_solr['title_field1']).to eq 'Test Manifest 1'
|
48
|
-
expect(subject.to_solr['title_field2']).to eq 'Test Manifest 1'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'JSON-LD style labels' do
|
53
|
-
context 'when it is an array' do
|
54
|
-
let(:manifest_fixture) { test_manifest3 }
|
55
|
-
|
56
|
-
it 'uses the configured language to find a value' do
|
57
|
-
expect(subject.to_solr['full_title_tesim']).to eq 'Test Manifest 3'
|
58
|
-
|
59
|
-
allow(Spotlight::Engine.config).to receive(:default_json_ld_language).and_return('fr')
|
60
|
-
expect(subject.to_solr['full_title_tesim']).to eq "Manifeste d'essai 3"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when it is a hash' do
|
65
|
-
let(:manifest_fixture) { test_manifest2 }
|
66
|
-
|
67
|
-
it 'is parsed correctly' do
|
68
|
-
expect(subject.to_solr['full_title_tesim']).to eq 'Test Manifest 2'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'collection id' do
|
74
|
-
it 'is included when a collection is given' do
|
75
|
-
expect(subject.to_solr[:collection_id_ssim]).to eq ['1']
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'manifest url' do
|
80
|
-
it 'is inlcuded in the solr document when present' do
|
81
|
-
expect(subject.to_solr[:iiif_manifest_url_ssi]).to eq url
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe 'thumbnail url' do
|
86
|
-
it 'is inlcuded in the solr document when present' do
|
87
|
-
expect(subject.to_solr[:thumbnail_url_ssm]).to eq 'uri://to-thumbnail'
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe 'full size image url' do
|
92
|
-
it 'is included in the solr document' do
|
93
|
-
expect(subject.to_solr[:full_image_url_ssm]).to eq 'uri://full-image'
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe 'image urls' do
|
98
|
-
it 'is included in the solr document when present' do
|
99
|
-
expect(subject.to_solr[:content_metadata_image_iiif_info_ssm]).to eq ['uri://to-image-service/info.json']
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe 'metadata' do
|
104
|
-
it 'includes the top-level attribution' do
|
105
|
-
expect(subject.to_solr['readonly_attribution_tesim']).to eq ['Attribution Data']
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'includes the top-level description' do
|
109
|
-
expect(subject.to_solr['readonly_description_tesim']).to eq ['A test IIIF manifest']
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'includes the top-level license' do
|
113
|
-
expect(subject.to_solr['readonly_license_tesim']).to eq ['http://www.example.org/license.html']
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'includes fields for each label/value pair in the metadata section' do
|
117
|
-
expect(subject.to_solr['readonly_author_tesim']).to include 'John Doe'
|
118
|
-
expect(subject.to_solr['readonly_another-field_tesim']).to eq ['Some data']
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'collects items with the same label into an array' do
|
122
|
-
expect(subject.to_solr['readonly_author_tesim']).to eq ['John Doe', 'Jane Doe']
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'exhibit custom fields are created for the necessary fields' do
|
126
|
-
expect { subject.to_solr }.to change(Spotlight::CustomField, :count).by(5)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'creates read-only custom fields' do
|
130
|
-
expect { subject.to_solr }.to change(Spotlight::CustomField.where(readonly_field: true), :count).by(5)
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'custom class' do
|
134
|
-
before do
|
135
|
-
allow(Spotlight::Engine.config).to receive(:iiif_metadata_class).and_return(-> { TestMetadataClass })
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'merges the solr hash from the configured custom metadata class' do
|
139
|
-
expect(subject.to_solr['readonly_test_field_tesim']).to eq 'metadata-to-solr'
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'with a multilingual manifest' do
|
146
|
-
let(:manifest_fixture) { test_multilingual_manifest_like_bsb }
|
147
|
-
|
148
|
-
describe '#to_solr' do
|
149
|
-
let(:manifest) { Spotlight::Resources::IiifService.new(url).send(:object) }
|
150
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
151
|
-
|
152
|
-
describe 'label' do
|
153
|
-
it 'is included in the solr document when present' do
|
154
|
-
expect(subject.to_solr['full_title_tesim']).to eq 'Murasaki Shikibu: Genji monogatari - BSB Cod.jap. 18(53'
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe 'metadata' do
|
159
|
-
it 'extracts labels and values out of multivalued data and removes HTML markup' do
|
160
|
-
expect(subject.to_solr).to include 'readonly_author_tesim' => ['Murasaki Shikibu -- (GND: 118985655)'],
|
161
|
-
'readonly_language_tesim' => ['Japanese']
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'extracts data using the configured default language' do
|
165
|
-
allow(Spotlight::Engine.config).to receive(:default_json_ld_language).and_return('de')
|
166
|
-
expect(subject.to_solr).to include 'readonly_verfasser_tesim' => ['Murasaki Shikibu -- (GND: 118985655)'],
|
167
|
-
'readonly_sprache_tesim' => ['Japanisch']
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'falls back to a language from the manifest using the IIIF rules' do
|
171
|
-
allow(Spotlight::Engine.config).to receive(:default_json_ld_language).and_return('fr')
|
172
|
-
expect(subject.to_solr).to include 'readonly_verfasser_tesim' => ['Murasaki Shikibu -- (GND: 118985655)'],
|
173
|
-
'readonly_sprache_tesim' => ['Japanisch']
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spotlight::Resources::IiifService do
|
6
|
-
subject { described_class.new(url) }
|
7
|
-
|
8
|
-
let(:url) { 'uri://for-top-level-collection' }
|
9
|
-
|
10
|
-
before { stub_default_collection }
|
11
|
-
|
12
|
-
describe '#collections' do
|
13
|
-
it 'returns service objects for each top-level collection' do
|
14
|
-
expect(subject.collections.length).to eq 2
|
15
|
-
expect(subject.collections).to be_all { |s| s.is_a?(described_class) }
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'returns service objects for nested collections' do
|
19
|
-
expect(subject.collections.first.collections.length).to eq 1
|
20
|
-
expect(subject.collections.last.collections).to be_blank
|
21
|
-
expect(subject.collections.first.collections.first).to be_a(described_class)
|
22
|
-
expect(
|
23
|
-
subject.collections.first.collections.first.collections
|
24
|
-
).to be_blank
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#manifests' do
|
29
|
-
it 'returns manifests for the current service level' do
|
30
|
-
expect(subject.manifests.length).to eq 2
|
31
|
-
expect(subject.manifests.first).to be_a Spotlight::Resources::IiifManifest
|
32
|
-
expect(subject.collections.first.manifests.length).to eq 2
|
33
|
-
expect(
|
34
|
-
subject.collections.first.manifests.first
|
35
|
-
).to be_a Spotlight::Resources::IiifManifest
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#parse' do
|
40
|
-
let(:manifests) { described_class.parse(url) }
|
41
|
-
|
42
|
-
it 'recursively traverses all all the collections and returns manifests' do
|
43
|
-
expect(manifests).to be_all do |manifest|
|
44
|
-
manifest.is_a?(Spotlight::Resources::IiifManifest)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'returns manifests representing collection documents' do
|
49
|
-
expect(manifests.count).to eq 8
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'keeps track of the parent collection' do
|
53
|
-
arr = manifests.to_a
|
54
|
-
expect(arr[1].collection).to eq arr[0]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Resources::Upload, type: :model do
|
4
|
-
subject(:upload) { described_class.new(id: 42, exhibit: exhibit) }
|
5
|
-
|
6
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
|
-
|
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
|
12
|
-
|
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
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
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"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#sidecar' do
|
29
|
-
it 'is a SolrDocumentSidecar with the correct relationships' do
|
30
|
-
sidecar = upload.sidecar
|
31
|
-
|
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"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when creating' do
|
39
|
-
before do
|
40
|
-
allow(upload).to receive(:write?).and_return(false)
|
41
|
-
end
|
42
|
-
|
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
|
-
)
|
52
|
-
|
53
|
-
upload.data = { 'full_title_tesim' => 'My Upload Title', 'spotlight_upload_date_tesim' => 'My Upload Date' }
|
54
|
-
|
55
|
-
upload.save
|
56
|
-
end
|
57
|
-
|
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')
|
61
|
-
|
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
|
-
)
|
65
|
-
|
66
|
-
upload.data = { 'custom_field_1' => 'Custom Field 1 Data', 'custom_field_2' => 'Custom Field 2 Data' }
|
67
|
-
|
68
|
-
upload.save
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Resources::Web, type: :model do
|
4
|
-
class TestResource < Spotlight::Resource
|
5
|
-
include Spotlight::Resources::Web
|
6
|
-
end
|
7
|
-
|
8
|
-
subject { TestResource.new }
|
9
|
-
|
10
|
-
describe '#harvest!' do
|
11
|
-
it 'caches the body and headers in the data' do
|
12
|
-
allow(described_class).to receive_messages(fetch: double(body: 'xyz', headers: { a: 1 }))
|
13
|
-
subject.harvest!
|
14
|
-
expect(subject.data[:body]).to eq 'xyz'
|
15
|
-
expect(subject.data[:headers]).to eq a: 1
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#body' do
|
20
|
-
it 'returns the body DOM' do
|
21
|
-
allow(described_class).to receive_messages(fetch: double(body: '<html />', headers: { a: 1 }))
|
22
|
-
expect(subject.body).to be_a_kind_of(Nokogiri::HTML::Document)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Role, type: :model do
|
4
|
-
describe 'validations' do
|
5
|
-
subject { described_class.new(args) }
|
6
|
-
|
7
|
-
describe 'with nothing' do
|
8
|
-
let(:args) { { user_key: '' } }
|
9
|
-
|
10
|
-
it 'does not be valid' do
|
11
|
-
expect(subject).not_to be_valid
|
12
|
-
expect(subject.errors.messages.transform_values(&:to_a)).to include(role: ['is not included in the list'], 'user.email': ["can't be blank"])
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'with user_key' do
|
17
|
-
describe "that doesn't point at a user" do
|
18
|
-
let(:user) { FactoryBot.build(:user) }
|
19
|
-
let(:args) { { role: 'curator', user_key: user.email } }
|
20
|
-
|
21
|
-
it 'does not be valid' do
|
22
|
-
expect(subject).to be_valid
|
23
|
-
subject.save!
|
24
|
-
expect(subject.user).to be_invite_pending
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'that points at a user' do
|
29
|
-
let(:user) { FactoryBot.create(:user) }
|
30
|
-
let(:args) { { role: 'curator', user_key: user.email } }
|
31
|
-
|
32
|
-
it 'is valid' do
|
33
|
-
expect(subject).to be_valid
|
34
|
-
expect(subject.errors.messages).to be_empty
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'that points at a user with an existing role' do
|
39
|
-
let(:user) { FactoryBot.create(:user) }
|
40
|
-
let(:args) { { role: 'curator', user_key: user.email } }
|
41
|
-
|
42
|
-
before { described_class.create!(role: 'curator', user: user) }
|
43
|
-
|
44
|
-
it 'is valid' do
|
45
|
-
expect(subject).not_to be_valid
|
46
|
-
expect(subject.errors.messages).to eq(user_key: ['already a member of this exhibit'])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::Search, type: :model do
|
4
|
-
subject { exhibit.searches.build(title: 'Search', query_params: query_params) }
|
5
|
-
|
6
|
-
let(:exhibit) { FactoryBot.create(:exhibit) }
|
7
|
-
|
8
|
-
let(:query_params) { { 'f' => { 'genre_ssim' => ['map'] } } }
|
9
|
-
|
10
|
-
let(:blacklight_config) { ::CatalogController.blacklight_config }
|
11
|
-
let(:document) do
|
12
|
-
SolrDocument.new(id: 'dq287tq6352',
|
13
|
-
blacklight_config.index.title_field => 'title')
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'for a search matching all items' do
|
17
|
-
let(:query_params) { {} }
|
18
|
-
|
19
|
-
it 'has items' do
|
20
|
-
# Add some fuzziness to this. Running locally it should be 55 but in some
|
21
|
-
# CI environments, spec/features/add_items_spec.rb will end up adding new
|
22
|
-
# records and cannot ensure deletion of them.
|
23
|
-
expect(subject.documents.size).to be_within(1).of(55)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'default_scope' do
|
28
|
-
let!(:page1) { FactoryBot.create(:search, weight: 5, published: true) }
|
29
|
-
let!(:page2) { FactoryBot.create(:search, weight: 1, published: true) }
|
30
|
-
let!(:page3) { FactoryBot.create(:search, weight: 10, published: true) }
|
31
|
-
|
32
|
-
it 'orders by weight' do
|
33
|
-
expect(described_class.published.map(&:weight)).to eq [1, 5, 10]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '.unpublished' do
|
38
|
-
let!(:search1) { FactoryBot.create(:search, published: true) }
|
39
|
-
let!(:search2) { FactoryBot.create(:search, published: false) }
|
40
|
-
let!(:search3) { FactoryBot.create(:search, published: nil) }
|
41
|
-
|
42
|
-
it 'accounts for nil and false values' do
|
43
|
-
expect(described_class.unpublished.count).to eq 5
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#slug' do
|
48
|
-
let(:search) { FactoryBot.create(:search) }
|
49
|
-
|
50
|
-
it 'gets a default slug' do
|
51
|
-
expect(search.slug).not_to be_blank
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'is updated when the title changes' do
|
55
|
-
search.update(title: 'abc')
|
56
|
-
expect(search.slug).to eq 'abc'
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with a custom slug' do
|
60
|
-
let(:search) { FactoryBot.create(:search, slug: 'xyz') }
|
61
|
-
|
62
|
-
it 'gets a default slug' do
|
63
|
-
expect(search.slug).to eq 'xyz'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#search_params' do
|
69
|
-
it 'maps the search to the appropriate facet values' do
|
70
|
-
expect(subject.search_params.to_hash).to include 'fq' => array_including('{!term f=genre_ssim}map')
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'with filter_resources_by_exhibit configured' do
|
74
|
-
before do
|
75
|
-
allow(Spotlight::Engine.config).to receive(:filter_resources_by_exhibit).and_return(true)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'includes the exhibit context' do
|
79
|
-
expect(subject.search_params.to_hash).to include 'fq' => array_including("{!term f=spotlight_exhibit_slug_#{exhibit.slug}_bsi}true")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#repository' do
|
85
|
-
let(:search) { FactoryBot.create(:search) }
|
86
|
-
|
87
|
-
before do
|
88
|
-
allow(search).to receive(:blacklight_config).and_return blacklight_config
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'returns an exhibit specific config' do
|
92
|
-
expect(search.send(:repository).blacklight_config).to eql blacklight_config
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#merge_params_for_search' do
|
97
|
-
it 'merges user-supplied parameters into the search query' do
|
98
|
-
user_params = { view: 'x' }
|
99
|
-
search_params = subject.merge_params_for_search(user_params, blacklight_config)
|
100
|
-
expect(search_params).to include query_params
|
101
|
-
expect(search_params).to include user_params
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'preserves user pagination' do
|
105
|
-
user_params = { page: 5, per_page: 7 }
|
106
|
-
search_params = subject.merge_params_for_search(user_params, blacklight_config)
|
107
|
-
expect(search_params).to include query_params
|
108
|
-
expect(search_params).to include user_params
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '#groups' do
|
113
|
-
let(:search) { FactoryBot.create(:search_with_groups, groups_count: 3) }
|
114
|
-
|
115
|
-
it do
|
116
|
-
expect(search.groups.count).to eq 3
|
117
|
-
end
|
118
|
-
|
119
|
-
it do
|
120
|
-
search.groups.all do |group|
|
121
|
-
expect(group).to be_an Spotlight::Group
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'sitemap_generator'
|
4
|
-
|
5
|
-
describe Spotlight::Sitemap do
|
6
|
-
subject { described_class.new(sitemap, exhibit) }
|
7
|
-
|
8
|
-
let(:sitemap) { SitemapGenerator::Interpreter.new }
|
9
|
-
let(:exhibit) { FactoryBot.create(:exhibit, published: true) }
|
10
|
-
let(:blacklight_config) { Blacklight::Configuration.new }
|
11
|
-
let(:sitemap_content) { sitemap.sitemap.sitemap.instance_variable_get(:@xml_content) }
|
12
|
-
let(:url_helpers) { Spotlight::Engine.routes.url_helpers }
|
13
|
-
|
14
|
-
before do
|
15
|
-
allow(exhibit).to receive(:blacklight_config).and_return(blacklight_config)
|
16
|
-
|
17
|
-
SitemapGenerator::Sitemap.default_host = 'http://localhost/'
|
18
|
-
SitemapGenerator::Interpreter.send :include, Rails.application.routes.url_helpers
|
19
|
-
SitemapGenerator::Interpreter.send :include, Spotlight::Engine.routes.url_helpers
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '.add_all_exhibits' do
|
23
|
-
let!(:second_exhibit) { FactoryBot.create(:exhibit, published: true) }
|
24
|
-
let!(:unpublished_exhibit) { FactoryBot.create(:exhibit, published: false) }
|
25
|
-
|
26
|
-
it 'builds a sitemap for all published exhibits' do
|
27
|
-
sitemaps = []
|
28
|
-
|
29
|
-
allow_any_instance_of(described_class).to receive(:add_resources!) do |s|
|
30
|
-
sitemaps << s
|
31
|
-
end
|
32
|
-
|
33
|
-
described_class.add_all_exhibits(sitemap)
|
34
|
-
|
35
|
-
expect(sitemaps.map(&:exhibit)).to include exhibit, second_exhibit
|
36
|
-
expect(sitemaps.map(&:exhibit)).not_to include unpublished_exhibit
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '.add_exhibit' do
|
41
|
-
it 'builds a sitemap for the exhibit' do
|
42
|
-
expect_any_instance_of(described_class).to receive(:add_resources!)
|
43
|
-
|
44
|
-
described_class.add_exhibit(sitemap, exhibit)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#add_resources!' do
|
49
|
-
it 'builds a sitemap for all exhibit resources' do
|
50
|
-
expect(subject).to receive(:add_exhibit_root)
|
51
|
-
expect(subject).to receive(:add_pages)
|
52
|
-
expect(subject).to receive(:add_resources)
|
53
|
-
expect(subject).to receive(:add_browse_categories)
|
54
|
-
|
55
|
-
subject.add_resources!
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'does not publish sitemaps for unpublished exhibits' do
|
59
|
-
exhibit.published = false
|
60
|
-
|
61
|
-
expect(subject).not_to receive(:add_exhibit_root)
|
62
|
-
expect(subject).not_to receive(:add_pages)
|
63
|
-
expect(subject).not_to receive(:add_resources)
|
64
|
-
expect(subject).not_to receive(:add_browse_categories)
|
65
|
-
|
66
|
-
subject.add_resources!
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#add_exhibit_root' do
|
71
|
-
it 'adds the home page' do
|
72
|
-
subject.add_exhibit_root
|
73
|
-
expect(sitemap_content).to include url_helpers.exhibit_root_path(exhibit)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#add_pages' do
|
78
|
-
let!(:feature_page) { FactoryBot.create(:feature_page, exhibit: exhibit, published: true) }
|
79
|
-
let!(:about_page) { FactoryBot.create(:about_page, exhibit: exhibit, published: true) }
|
80
|
-
|
81
|
-
it 'adds feature pages' do
|
82
|
-
subject.add_pages
|
83
|
-
expect(sitemap_content).to include url_helpers.exhibit_feature_page_path(exhibit, feature_page)
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'adds about pages' do
|
87
|
-
subject.add_pages
|
88
|
-
expect(sitemap_content).to include url_helpers.exhibit_about_page_path(exhibit, about_page)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe '#add_resources' do
|
93
|
-
let(:document) { blacklight_config.document_model.new(id: 'a') }
|
94
|
-
|
95
|
-
before do
|
96
|
-
allow(exhibit).to receive(:solr_documents).and_return([document])
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'adds document resources' do
|
100
|
-
subject.add_resources
|
101
|
-
expect(sitemap_content).to include url_helpers.exhibit_solr_document_path(exhibit, document)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe '#add_browse_categories' do
|
106
|
-
let!(:search) { FactoryBot.create(:published_search, exhibit: exhibit) }
|
107
|
-
|
108
|
-
it 'adds browse categories to the sitemap' do
|
109
|
-
subject.add_browse_categories
|
110
|
-
expect(sitemap_content).to include url_helpers.exhibit_browse_path(exhibit, search)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe Spotlight::SolrDocument::AtomicUpdates, type: :model do
|
4
|
-
subject do
|
5
|
-
SolrDocument.new.extend(described_class)
|
6
|
-
end
|
7
|
-
|
8
|
-
let(:blacklight_solr) { double }
|
9
|
-
|
10
|
-
before do
|
11
|
-
allow(subject).to receive_messages(blacklight_solr: blacklight_solr)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#reindex' do
|
15
|
-
before do
|
16
|
-
allow(subject).to receive_messages(to_solr: { id: 'doc_id', a: 1, b: 2 })
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'when the index is not writable' do
|
20
|
-
before do
|
21
|
-
allow(Spotlight::Engine.config).to receive_messages(writable_index: false)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "doesn't write" do
|
25
|
-
expect(blacklight_solr).not_to receive(:update)
|
26
|
-
subject.reindex
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'sends an atomic update request' do
|
31
|
-
expected = {
|
32
|
-
params: { commitWithin: 500 },
|
33
|
-
data: [{ id: 'doc_id', a: { set: 1 }, b: { set: 2 }, timestamp: { set: nil } }].to_json,
|
34
|
-
headers: { 'Content-Type' => 'application/json' }
|
35
|
-
}
|
36
|
-
expect(blacklight_solr).to receive(:update).with(expected)
|
37
|
-
subject.reindex
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'update parameters can be specified to modify commitWithin' do
|
41
|
-
expected = {
|
42
|
-
params: { commitWithin: 5001 },
|
43
|
-
data: [{ id: 'doc_id', a: { set: 1 }, b: { set: 2 }, timestamp: { set: nil } }].to_json,
|
44
|
-
headers: { 'Content-Type' => 'application/json' }
|
45
|
-
}
|
46
|
-
expect(blacklight_solr).to receive(:update).with(expected)
|
47
|
-
subject.reindex(update_params: { commitWithin: 5001 })
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'cowardlies refuse to index a document if the only value is an id' do
|
51
|
-
allow(subject).to receive_messages(to_solr: { id: 'doc_id' }, timestamp: { set: nil })
|
52
|
-
expect(blacklight_solr).not_to receive(:update)
|
53
|
-
subject.reindex
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|