blacklight-spotlight 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/assets/images/spotlight/default_browse_thumbnail.jpg +0 -0
- data/app/assets/javascripts/spotlight/application.js +6 -1
- data/app/assets/javascripts/spotlight/blocks/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/blocks/resources_block.js +7 -4
- data/app/assets/javascripts/spotlight/blocks/solr_documents_base_block.js +108 -0
- data/app/assets/javascripts/spotlight/blocks/solr_documents_block.js +12 -56
- data/app/assets/javascripts/spotlight/blocks/solr_documents_carousel_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_embed_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_features_block.js +3 -3
- data/app/assets/javascripts/spotlight/blocks/solr_documents_grid_block.js +3 -3
- data/app/assets/javascripts/spotlight/crop.es6 +205 -0
- data/app/assets/javascripts/spotlight/croppable.js +7 -104
- data/app/assets/javascripts/spotlight/iiif.es6 +54 -0
- data/app/assets/javascripts/spotlight/multi_image_selector.js +34 -16
- data/app/assets/javascripts/spotlight/pages.js.erb +1 -1
- data/app/assets/javascripts/spotlight/reindex_monitor.js +5 -1
- data/app/assets/javascripts/spotlight/search_typeahead.js +33 -47
- data/app/assets/javascripts/spotlight/sir-trevor/locales.js +5 -2
- data/app/assets/javascripts/spotlight/zpr_links.js.erb +30 -0
- data/app/assets/stylesheets/spotlight/_croppable.scss +8 -13
- data/app/assets/stylesheets/spotlight/_multi_image_selector.scss +1 -1
- data/app/assets/stylesheets/spotlight/_pages.scss +5 -0
- data/app/assets/stylesheets/spotlight/typeahead.css +0 -1
- data/app/controllers/concerns/spotlight/base.rb +3 -5
- data/app/controllers/spotlight/appearances_controller.rb +6 -4
- data/app/controllers/spotlight/catalog_controller.rb +10 -0
- data/app/controllers/spotlight/contacts_controller.rb +2 -6
- data/app/controllers/spotlight/featured_images_controller.rb +26 -0
- data/app/controllers/spotlight/pages_controller.rb +3 -2
- data/app/controllers/spotlight/resources/iiif_harvester_controller.rb +10 -0
- data/app/controllers/spotlight/resources/upload_controller.rb +4 -3
- data/app/controllers/spotlight/searches_controller.rb +20 -6
- data/app/controllers/spotlight/sites_controller.rb +2 -5
- data/app/helpers/spotlight/application_helper.rb +14 -1
- data/app/helpers/spotlight/crop_helper.rb +37 -0
- data/app/helpers/spotlight/main_app_helpers.rb +13 -0
- data/app/helpers/spotlight/meta_helper.rb +10 -20
- data/app/models/concerns/spotlight/solr_document.rb +1 -2
- data/app/models/concerns/spotlight/solr_document/uploaded_resource.rb +1 -23
- data/app/models/sir_trevor_rails/blocks/browse_block.rb +10 -0
- data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +10 -0
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +5 -0
- data/app/models/spotlight/analytics/ga.rb +1 -1
- data/app/models/spotlight/blacklight_configuration.rb +16 -8
- data/app/models/spotlight/contact.rb +2 -13
- data/app/models/spotlight/contact_image.rb +11 -0
- data/app/models/spotlight/exhibit.rb +11 -8
- data/app/models/spotlight/exhibit_thumbnail.rb +12 -0
- data/app/models/spotlight/feature_page.rb +3 -5
- data/app/models/spotlight/featured_image.rb +28 -9
- data/app/models/spotlight/home_page.rb +2 -0
- data/app/models/spotlight/masthead.rb +5 -11
- data/app/models/spotlight/page.rb +5 -0
- data/app/models/spotlight/reindex_progress.rb +10 -18
- data/app/models/spotlight/reindexing_log_entry.rb +1 -0
- data/app/models/spotlight/resources/iiif_harvester.rb +33 -0
- data/app/models/spotlight/resources/iiif_manifest.rb +211 -0
- data/app/models/spotlight/resources/iiif_service.rb +93 -0
- data/app/models/spotlight/resources/upload.rb +1 -2
- data/app/models/spotlight/search.rb +5 -34
- data/app/presenters/spotlight/iiif_manifest_presenter.rb +79 -0
- data/app/serializers/spotlight/exhibit_export_serializer.rb +9 -41
- data/app/services/spotlight/carrierwave_file_resolver.rb +3 -1
- data/app/services/spotlight/iiif_resource_resolver.rb +73 -0
- data/app/services/spotlight/resources/iiif_builder.rb +17 -0
- data/app/services/spotlight/upload_solr_document_builder.rb +23 -23
- data/app/uploaders/spotlight/attachment_uploader.rb +0 -48
- data/app/uploaders/spotlight/featured_image_uploader.rb +2 -16
- data/app/views/_user_util_links.html.erb +8 -5
- data/app/views/catalog/_save_search.html.erb +4 -2
- data/app/views/layouts/spotlight/spotlight.html.erb +5 -1
- data/app/views/shared/_masthead.html.erb +1 -1
- data/app/views/spotlight/about_pages/_contact_properties.html.erb +1 -1
- data/app/views/spotlight/appearances/edit.html.erb +26 -6
- data/app/views/spotlight/browse/_search.html.erb +1 -1
- data/app/views/spotlight/contacts/_form.html.erb +12 -7
- data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +1 -1
- data/app/views/spotlight/exhibits/_exhibit_card_front.html.erb +2 -2
- data/app/views/spotlight/featured_images/_form.html.erb +12 -15
- data/app/views/spotlight/featured_images/_upload_form.html.erb +6 -12
- data/app/views/spotlight/metadata_configurations/_metadata_field.html.erb +3 -3
- data/app/views/spotlight/pages/_form.html.erb +3 -3
- data/app/views/spotlight/pages/edit.html.erb +4 -2
- data/app/views/spotlight/resources/iiif/_form.html.erb +9 -0
- data/app/views/spotlight/searches/_form.html.erb +3 -3
- data/app/views/spotlight/searches/_search.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +7 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +4 -2
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +4 -2
- data/app/views/spotlight/sites/edit.html.erb +1 -1
- data/config/locales/spotlight.en.yml +31 -6
- data/config/routes.rb +9 -0
- data/db/migrate/20160714144125_add_iiif_urls_to_featured_image.rb +9 -0
- data/db/migrate/20160718194010_add_iiif_url_to_contact.rb +6 -0
- data/db/migrate/20160805143841_add_upload_id_to_resources.rb +6 -0
- data/db/migrate/20170204091234_add_theme_to_spotlight_exhibits.rb +5 -0
- data/lib/generators/spotlight/install_generator.rb +5 -2
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +0 -1
- data/lib/generators/spotlight/templates/spotlight.scss +3 -2
- data/lib/migration/iiif.rb +82 -0
- data/lib/spotlight/engine.rb +22 -10
- data/lib/spotlight/version.rb +1 -1
- data/lib/tasks/spotlight_tasks.rake +10 -0
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/appearances_controller_spec.rb +31 -18
- data/spec/controllers/spotlight/catalog_controller_spec.rb +40 -0
- data/spec/controllers/spotlight/contacts_controller_spec.rb +20 -1
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +2 -6
- data/spec/controllers/spotlight/featured_images_controller_spec.rb +74 -0
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/searches_controller_spec.rb +3 -1
- data/spec/controllers/spotlight/sites_controller_spec.rb +6 -1
- data/spec/examples.txt +1118 -1059
- data/spec/factories/contact_images.rb +6 -0
- data/spec/factories/contacts.rb +4 -1
- data/spec/factories/exhibit_thumbnails.rb +6 -0
- data/spec/factories/exhibits.rb +4 -0
- data/spec/factories/featured_images.rb +1 -0
- data/spec/factories/resources.rb +2 -1
- data/spec/features/add_contacts_spec.rb +5 -5
- data/spec/features/add_iiif_manifest_spec.rb +41 -0
- data/spec/features/add_items_spec.rb +2 -2
- data/spec/features/autocomplete_typeahead_spec.rb +86 -0
- data/spec/features/browse_category_admin_spec.rb +27 -6
- data/spec/features/browse_category_spec.rb +2 -2
- data/spec/features/create_exhibit_spec.rb +3 -3
- data/spec/features/exhibit_masthead_spec.rb +20 -9
- data/spec/features/exhibit_themes_spec.rb +25 -0
- data/spec/features/home_page_spec.rb +1 -1
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +42 -0
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +5 -3
- data/spec/features/javascript/feature_page_admin_spec.rb +1 -1
- data/spec/features/javascript/multi_image_select_spec.rb +5 -6
- data/spec/features/javascript/search_config_admin_spec.rb +1 -1
- data/spec/features/site_masthead_spec.rb +14 -4
- data/spec/fixtures/gk446cj2442-manifest.json +58 -0
- data/spec/fixtures/iiif_responses.rb +274 -0
- data/spec/fixtures/sample_solr_documents.yml +106 -0
- data/spec/helpers/spotlight/crop_helper_spec.rb +9 -0
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +45 -0
- data/spec/helpers/spotlight/meta_helper_spec.rb +2 -15
- data/spec/lib/migration/iiif_spec.rb +70 -0
- data/spec/models/spotlight/blacklight_configuration_spec.rb +17 -5
- data/spec/models/spotlight/contact_image_spec.rb +9 -0
- data/spec/models/spotlight/exhibit_spec.rb +17 -20
- data/spec/models/spotlight/exhibit_thumbnail_spec.rb +8 -0
- data/spec/models/spotlight/featured_image_spec.rb +59 -10
- data/spec/models/spotlight/masthead_spec.rb +33 -17
- data/spec/models/spotlight/page_spec.rb +14 -0
- data/spec/models/spotlight/reindex_progress_spec.rb +22 -73
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +30 -0
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +107 -0
- data/spec/models/spotlight/resources/iiif_service_spec.rb +52 -0
- data/spec/models/spotlight/resources/upload_spec.rb +7 -3
- data/spec/models/spotlight/search_spec.rb +0 -45
- data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +11 -29
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +123 -0
- data/spec/routing/spotlight/exhibit_catalog_spec.rb +4 -0
- data/spec/routing/spotlight/featured_images_spec.rb +21 -0
- data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +15 -18
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +90 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/features/test_features_helpers.rb +3 -2
- data/spec/support/stub_iiif_response.rb +24 -0
- data/spec/support/views/test_view_helpers.rb +1 -0
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/uploaders/spotlight/attachment_uploader_spec.rb +24 -0
- data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +30 -0
- data/spec/views/_user_util_links.html.erb_spec.rb +9 -5
- data/spec/views/shared/_masthead.html.erb_spec.rb +5 -2
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +4 -7
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +7 -2
- data/spec/views/spotlight/pages/edit.html.erb_spec.rb +3 -1
- data/spec/views/spotlight/pages/new.html.erb_spec.rb +3 -1
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +3 -2
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +3 -2
- data/vendor/assets/javascripts/leaflet-areaselect.js +184 -0
- data/vendor/assets/javascripts/leaflet-iiif.js +230 -0
- data/vendor/assets/javascripts/leaflet.js +9 -0
- data/vendor/assets/javascripts/polyfill.min.js +4 -0
- data/vendor/assets/stylesheets/leaflet-areaselect.css +15 -0
- data/vendor/assets/stylesheets/leaflet.css +624 -0
- metadata +136 -62
- data/app/assets/javascripts/spotlight/jcrop.js +0 -1696
- data/app/helpers/spotlight/jcrop_helper.rb +0 -37
- data/app/models/concerns/spotlight/default_thumbnailable.rb +0 -25
- data/app/models/concerns/spotlight/image_derivatives.rb +0 -58
- data/app/models/concerns/spotlight/solr_document/spotlight_images.rb +0 -55
- data/app/uploaders/spotlight/avatar_uploader.rb +0 -24
- data/app/uploaders/spotlight/item_uploader.rb +0 -25
- data/app/uploaders/spotlight/masthead_uploader.rb +0 -22
- data/spec/helpers/spotlight/jcrop_helper_spec.rb +0 -33
- data/spec/models/spotlight/default_thumbnailable_concern_spec.rb +0 -16
- data/spec/models/spotlight/image_derivatives_spec.rb +0 -15
- data/spec/models/spotlight/solr_document/spotlight_images_spec.rb +0 -42
- data/spec/uploaders/spotlight/item_uploader_spec.rb +0 -67
@@ -1,32 +1,20 @@
|
|
1
1
|
describe Spotlight::ReindexProgress, type: :model do
|
2
|
-
let(:
|
3
|
-
|
4
|
-
# failed is the later of the two, and thus the return value for current_log_entry
|
5
|
-
FactoryGirl.create(:reindexing_log_entry, items_reindexed_estimate: 11),
|
6
|
-
FactoryGirl.create(:failed_reindexing_log_entry, items_reindexed_estimate: 12)
|
7
|
-
]
|
2
|
+
let(:reindexing_log_entry) do
|
3
|
+
FactoryGirl.create(:failed_reindexing_log_entry, items_reindexed_estimate: 12)
|
8
4
|
end
|
9
|
-
let(:exhibit) { FactoryGirl.create(:exhibit, reindexing_log_entries: reindexing_log_entries) }
|
10
5
|
|
11
|
-
let(:subject) { described_class.new(
|
6
|
+
let(:subject) { described_class.new(reindexing_log_entry) }
|
12
7
|
|
13
8
|
describe '#started_at' do
|
14
9
|
it 'returns start_time for current_log_entry' do
|
15
|
-
expect(subject.started_at).to eq
|
10
|
+
expect(subject.started_at).to eq reindexing_log_entry.start_time
|
16
11
|
end
|
17
12
|
end
|
18
13
|
|
19
14
|
describe '#updated_at' do
|
20
|
-
# disable SkipsModelValidations cop for this test, because it complains about #touch, which is convenient here
|
21
|
-
# rubocop:disable Rails/SkipsModelValidations
|
22
15
|
it 'returns the time of last update for current_log_entry' do
|
23
|
-
|
24
|
-
subject.send(:current_log_entry).touch
|
25
|
-
upper_bound = Time.zone.now
|
26
|
-
|
27
|
-
expect(subject.updated_at).to be_between(lower_bound, upper_bound)
|
16
|
+
expect(subject.updated_at).to eq reindexing_log_entry.updated_at
|
28
17
|
end
|
29
|
-
# rubocop:enable Rails/SkipsModelValidations
|
30
18
|
end
|
31
19
|
|
32
20
|
describe '#finished?' do
|
@@ -37,7 +25,7 @@ describe Spotlight::ReindexProgress, type: :model do
|
|
37
25
|
|
38
26
|
describe '#finished_at' do
|
39
27
|
it 'returns end_time for current_log_entry' do
|
40
|
-
expect(subject.finished_at).to eq(
|
28
|
+
expect(subject.finished_at).to eq(reindexing_log_entry.end_time)
|
41
29
|
end
|
42
30
|
end
|
43
31
|
|
@@ -55,7 +43,7 @@ describe Spotlight::ReindexProgress, type: :model do
|
|
55
43
|
|
56
44
|
describe '#errored?' do
|
57
45
|
it 'returns true for log entries marked as failed' do
|
58
|
-
expect(subject
|
46
|
+
expect(subject).to be_errored
|
59
47
|
end
|
60
48
|
end
|
61
49
|
|
@@ -63,88 +51,48 @@ describe Spotlight::ReindexProgress, type: :model do
|
|
63
51
|
it 'returns a hash with values for current_log_entry via the various helper methods' do
|
64
52
|
expect(subject.as_json).to eq(
|
65
53
|
recently_in_progress: subject.recently_in_progress?,
|
66
|
-
started_at:
|
67
|
-
finished_at:
|
68
|
-
updated_at:
|
54
|
+
started_at: I18n.l(reindexing_log_entry.start_time, format: :short),
|
55
|
+
finished_at: I18n.l(reindexing_log_entry.end_time, format: :short),
|
56
|
+
updated_at: I18n.l(reindexing_log_entry.updated_at, format: :short),
|
69
57
|
total: subject.total,
|
70
58
|
completed: subject.completed,
|
71
|
-
errored: subject.errored
|
59
|
+
errored: subject.errored?,
|
60
|
+
finished: subject.finished?
|
72
61
|
)
|
73
62
|
end
|
74
63
|
end
|
75
64
|
|
76
65
|
describe '#recently_in_progress?' do
|
77
66
|
context 'there is no end_time for current_log_entry' do
|
78
|
-
let(:
|
79
|
-
let(:exhibit) { FactoryGirl.create(:exhibit, reindexing_log_entries: [current_log_entry]) }
|
67
|
+
let(:reindexing_log_entry) { FactoryGirl.create(:in_progress_reindexing_log_entry) }
|
80
68
|
|
81
69
|
it 'returns true' do
|
82
|
-
expect(subject
|
70
|
+
expect(subject).to be_recently_in_progress
|
83
71
|
end
|
84
72
|
end
|
85
73
|
|
86
74
|
context 'current_log_entry has an end_time less than Spotlight::Engine.config.reindex_progress_window.minutes.ago' do
|
87
|
-
let(:
|
88
|
-
let(:exhibit) { FactoryGirl.create(:exhibit, reindexing_log_entries: [current_log_entry]) }
|
75
|
+
let(:reindexing_log_entry) { FactoryGirl.create(:recent_reindexing_log_entry, end_time: Time.zone.now) }
|
89
76
|
|
90
77
|
it 'returns true' do
|
91
|
-
expect(subject
|
78
|
+
expect(subject).to be_recently_in_progress
|
92
79
|
end
|
93
80
|
end
|
94
81
|
|
95
82
|
context 'current_log_entry is unstarted ' do
|
96
|
-
let(:
|
97
|
-
let(:exhibit) { FactoryGirl.create(:exhibit, reindexing_log_entries: [current_log_entry]) }
|
83
|
+
let(:reindexing_log_entry) { FactoryGirl.create(:unstarted_reindexing_log_entry) }
|
98
84
|
|
99
85
|
it 'returns false' do
|
100
|
-
expect(subject
|
86
|
+
expect(subject).not_to be_recently_in_progress
|
101
87
|
end
|
102
88
|
end
|
103
89
|
end
|
104
90
|
|
105
|
-
|
106
|
-
|
107
|
-
let(:reindexing_log_entries) do
|
108
|
-
[
|
109
|
-
FactoryGirl.create(:unstarted_reindexing_log_entry),
|
110
|
-
FactoryGirl.create(:reindexing_log_entry),
|
111
|
-
FactoryGirl.create(:in_progress_reindexing_log_entry),
|
112
|
-
FactoryGirl.create(:failed_reindexing_log_entry),
|
113
|
-
FactoryGirl.create(:unstarted_reindexing_log_entry)
|
114
|
-
]
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'returns the latest log entry that is not unstarted' do
|
118
|
-
expect(subject.send(:current_log_entry)).to eq(reindexing_log_entries[2])
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe '#localized_start_time' do
|
123
|
-
it 'returns the short formatted start time' do
|
124
|
-
expect(subject.send(:localized_start_time)).to eq I18n.l(subject.started_at, format: :short)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe '#localized_finish_time' do
|
129
|
-
it 'returns the short formatted end time' do
|
130
|
-
expect(subject.send(:localized_finish_time)).to eq I18n.l(subject.finished_at, format: :short)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe '#localized_updated_time' do
|
135
|
-
it 'returns the short formatted last updated time' do
|
136
|
-
expect(subject.send(:localized_updated_time)).to eq I18n.l(subject.updated_at, format: :short)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'current_log_entry is nil' do
|
142
|
-
let(:reindexing_log_entries) { [] }
|
91
|
+
context 'current_log_entry is blan' do
|
92
|
+
let(:reindexing_log_entry) { Spotlight::ReindexingLogEntry.new }
|
143
93
|
|
144
94
|
# rubocop:disable RSpec/MultipleExpectations
|
145
95
|
it 'methods return gracefully' do
|
146
|
-
expect(subject.send(:current_log_entry)).to be nil
|
147
|
-
|
148
96
|
expect(subject.recently_in_progress?).to be false
|
149
97
|
expect(subject.started_at).to be nil
|
150
98
|
expect(subject.updated_at).to be nil
|
@@ -163,7 +111,8 @@ describe Spotlight::ReindexProgress, type: :model do
|
|
163
111
|
updated_at: nil,
|
164
112
|
total: nil,
|
165
113
|
completed: nil,
|
166
|
-
errored: false
|
114
|
+
errored: false,
|
115
|
+
finished: false
|
167
116
|
)
|
168
117
|
end
|
169
118
|
# rubocop:enable RSpec/MultipleExpectations
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spotlight::Resources::IiifHarvester do
|
4
|
+
let(:exhibit) { FactoryGirl.create(:exhibit) }
|
5
|
+
let(:harvester) { described_class.create(exhibit_id: exhibit.id, url: url) }
|
6
|
+
|
7
|
+
describe 'Validation' do
|
8
|
+
subject { harvester }
|
9
|
+
context 'when given an invalid URL' do
|
10
|
+
let(:url) { 'http://example.com' }
|
11
|
+
|
12
|
+
it 'errors when the URL is not a IIIF URL' do
|
13
|
+
expect(subject).to_not be_valid
|
14
|
+
expect(subject.errors).to be_present
|
15
|
+
expect(subject.errors[:url]).to eq ['Invalid IIIF URL']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#documents_to_index' do
|
21
|
+
let(:url) { 'uri://for-top-level-collection' }
|
22
|
+
before { stub_default_collection }
|
23
|
+
subject { harvester.document_builder }
|
24
|
+
|
25
|
+
it 'returns an Enumerator of all the solr documents' do
|
26
|
+
expect(subject.documents_to_index).to be_a(Enumerator)
|
27
|
+
expect(subject.documents_to_index.count).to eq 8
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestMetadataClass
|
4
|
+
def initialize(*); end
|
5
|
+
|
6
|
+
def to_solr
|
7
|
+
{ 'test_field' => 'metadata-to-solr' }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Spotlight::Resources::IiifManifest do
|
12
|
+
let(:url) { 'uri://to-manifest' }
|
13
|
+
subject { described_class.new(url: url, manifest: manifest, collection: collection) }
|
14
|
+
let(:collection) { double(compound_id: '1') }
|
15
|
+
before do
|
16
|
+
stub_iiif_response_for_url(url, test_manifest1)
|
17
|
+
subject.with_exhibit(exhibit)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#to_solr' do
|
21
|
+
let(:manifest) { Spotlight::Resources::IiifService.new(url).send(:object) }
|
22
|
+
let(:exhibit) { FactoryGirl.create(:exhibit) }
|
23
|
+
describe 'id' do
|
24
|
+
it 'is an MD5 hexdigest of the exhibit id and the and the url' do
|
25
|
+
expected = Digest::MD5.hexdigest("#{exhibit.id}-#{url}")
|
26
|
+
expect(subject.to_solr[:id]).to eq expected
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'label' do
|
31
|
+
it 'is inlcuded in the solr document when present' do
|
32
|
+
expect(subject.to_solr['full_title_tesim']).to eq 'Test Manifest 1'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'collection id' do
|
37
|
+
it 'is included when a collection is given' do
|
38
|
+
expect(subject.to_solr[:collection_id_ssim]).to eq ['1']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'manifest url' do
|
43
|
+
it 'is inlcuded in the solr document when present' do
|
44
|
+
expect(subject.to_solr[:iiif_manifest_url_ssi]).to eq url
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'thumbnail url' do
|
49
|
+
it 'is inlcuded in the solr document when present' do
|
50
|
+
expect(subject.to_solr[:thumbnail_url_ssm]).to eq 'uri://to-thumbnail'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'full size image url' do
|
55
|
+
it 'is included in the solr document' do
|
56
|
+
expect(subject.to_solr[:full_image_url_ssm]).to eq 'uri://full-image'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'image urls' do
|
61
|
+
it 'is included in the solr document when present' do
|
62
|
+
expect(subject.to_solr[:content_metadata_image_iiif_info_ssm]).to eq ['uri://to-image-service/info.json']
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'metadata' do
|
67
|
+
it 'includes the top-level attribution' do
|
68
|
+
expect(subject.to_solr['readonly_attribution_tesim']).to eq ['Attribution Data']
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'includes the top-level description' do
|
72
|
+
expect(subject.to_solr['readonly_description_tesim']).to eq ['A test IIIF manifest']
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'includes the top-level license' do
|
76
|
+
expect(subject.to_solr['readonly_license_tesim']).to eq ['http://www.example.org/license.html']
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'includes fields for each label/value pair in the metadata section' do
|
80
|
+
expect(subject.to_solr['readonly_author_tesim']).to include 'John Doe'
|
81
|
+
expect(subject.to_solr['readonly_another-field_tesim']).to eq ['Some data']
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'collects items with the same label into an array' do
|
85
|
+
expect(subject.to_solr['readonly_author_tesim']).to eq ['John Doe', 'Jane Doe']
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'exhibit custom fields are created for the necessary fields' do
|
89
|
+
expect { subject.to_solr }.to change(Spotlight::CustomField, :count).by(5)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'creates read-only custom fields' do
|
93
|
+
expect { subject.to_solr }.to change(Spotlight::CustomField.where(readonly_field: true), :count).by(5)
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'custom class' do
|
97
|
+
before do
|
98
|
+
Spotlight::Engine.config.iiif_metadata_class = -> { TestMetadataClass }
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'merges the solr hash from the configured custom metadata class' do
|
102
|
+
expect(subject.to_solr['readonly_test_field_tesim']).to eq 'metadata-to-solr'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spotlight::Resources::IiifService do
|
4
|
+
let(:url) { 'uri://for-top-level-collection' }
|
5
|
+
subject { described_class.new(url) }
|
6
|
+
before { stub_default_collection }
|
7
|
+
|
8
|
+
describe '#collections' do
|
9
|
+
it 'returns service objects for each top-level collection' do
|
10
|
+
expect(subject.collections.length).to eq 2
|
11
|
+
expect(subject.collections).to be_all { |s| s.is_a?(described_class) }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns service objects for nested collections' do
|
15
|
+
expect(subject.collections.first.collections.length).to eq 1
|
16
|
+
expect(subject.collections.last.collections).to be_blank
|
17
|
+
expect(subject.collections.first.collections.first).to be_a(described_class)
|
18
|
+
expect(
|
19
|
+
subject.collections.first.collections.first.collections
|
20
|
+
).to be_blank
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#manifests' do
|
25
|
+
it 'returns manifests for the current service level' do
|
26
|
+
expect(subject.manifests.length).to eq 2
|
27
|
+
expect(subject.manifests.first).to be_a Spotlight::Resources::IiifManifest
|
28
|
+
expect(subject.collections.first.manifests.length).to eq 2
|
29
|
+
expect(
|
30
|
+
subject.collections.first.manifests.first
|
31
|
+
).to be_a Spotlight::Resources::IiifManifest
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#parse' do
|
36
|
+
let(:manifests) { described_class.parse(url) }
|
37
|
+
|
38
|
+
it 'recursively traverses all all the collections and returns manifests' do
|
39
|
+
expect(manifests).to be_all do |manifest|
|
40
|
+
manifest.is_a?(Spotlight::Resources::IiifManifest)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns manifests representing collection documents' do
|
45
|
+
expect(manifests.count).to eq 8
|
46
|
+
end
|
47
|
+
it 'keeps track of the parent collection' do
|
48
|
+
arr = manifests.to_a
|
49
|
+
expect(arr[1].collection).to eq arr[0]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -16,15 +16,17 @@ describe Spotlight::Resources::Upload, type: :model do
|
|
16
16
|
custom_field.field => 'Custom Field Data'
|
17
17
|
}
|
18
18
|
end
|
19
|
+
let(:featured_image) { FactoryGirl.create(:featured_image, image: File.open(File.join(FIXTURES_PATH, '800x600.png'))) }
|
19
20
|
|
20
21
|
before do
|
22
|
+
Rails.cache.clear # wipes out any cached image info.
|
21
23
|
allow(resource).to receive(:configured_fields).and_return configured_fields
|
22
24
|
allow(described_class).to receive(:fields).and_return configured_fields
|
23
25
|
|
24
26
|
allow(resource.send(:blacklight_solr)).to receive(:update)
|
25
27
|
allow(Spotlight::Engine.config).to receive(:upload_title_field).and_return(title_field)
|
26
28
|
resource.data = upload_data
|
27
|
-
resource.
|
29
|
+
resource.upload = featured_image
|
28
30
|
resource.save
|
29
31
|
end
|
30
32
|
|
@@ -81,9 +83,7 @@ describe Spotlight::Resources::Upload, type: :model do
|
|
81
83
|
expect(subject[:spotlight_resource_type_ssim]).to eq 'spotlight/resources/uploads'
|
82
84
|
end
|
83
85
|
it 'has the various image fields' do
|
84
|
-
expect(subject).to have_key Spotlight::Engine.config.full_image_field
|
85
86
|
expect(subject).to have_key Spotlight::Engine.config.thumbnail_field
|
86
|
-
expect(subject).to have_key Spotlight::Engine.config.square_image_field
|
87
87
|
end
|
88
88
|
it 'has the full image dimensions fields' do
|
89
89
|
expect(subject[:spotlight_full_image_height_ssm]).to eq 600
|
@@ -92,5 +92,9 @@ describe Spotlight::Resources::Upload, type: :model do
|
|
92
92
|
it 'has fields representing exhibit specific custom fields' do
|
93
93
|
expect(subject[custom_field.solr_field]).to eq 'Custom Field Data'
|
94
94
|
end
|
95
|
+
it 'has a field for the iiif manifest url' do
|
96
|
+
manifest_path = Spotlight::Engine.routes.url_helpers.manifest_exhibit_solr_document_path(exhibit, resource.compound_id)
|
97
|
+
expect(subject[Spotlight::Engine.config.iiif_manifest_field]).to eq(manifest_path)
|
98
|
+
end
|
95
99
|
end
|
96
100
|
end
|
@@ -7,60 +7,15 @@ describe Spotlight::Search, type: :model do
|
|
7
7
|
let(:blacklight_config) { ::CatalogController.blacklight_config }
|
8
8
|
let(:document) do
|
9
9
|
SolrDocument.new(id: 'dq287tq6352',
|
10
|
-
blacklight_config.index.title_field => 'title',
|
11
|
-
Spotlight::Engine.config.full_image_field => 'https://stacks.stanford.edu/image/iiif/dq287tq6352%2Fdq287tq6352_05_0001/full/!400,400/0/default.jpg')
|
12
|
-
end
|
13
|
-
let(:document_without_an_image) do
|
14
|
-
SolrDocument.new(id: 'ab123fd9876',
|
15
10
|
blacklight_config.index.title_field => 'title')
|
16
11
|
end
|
17
12
|
|
18
|
-
context 'thumbnail' do
|
19
|
-
it 'calls DefaultThumbnailJob to fetch a default feature image' do
|
20
|
-
expect(Spotlight::DefaultThumbnailJob).to receive(:perform_later).with(subject)
|
21
|
-
subject.save!
|
22
|
-
end
|
23
|
-
|
24
|
-
context '#set_default_thumbnail' do
|
25
|
-
it 'has a default feature image' do
|
26
|
-
allow(subject).to receive_messages(documents: [document])
|
27
|
-
subject.set_default_thumbnail
|
28
|
-
expect(subject.thumbnail).not_to be_nil
|
29
|
-
expect(subject.thumbnail.image.path).to end_with 'default.jpg'
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'uses a document with an image for the default feature image' do
|
33
|
-
allow(subject).to receive_messages(documents: [document_without_an_image, document])
|
34
|
-
subject.set_default_thumbnail
|
35
|
-
expect(subject.thumbnail).not_to be_nil
|
36
|
-
expect(subject.thumbnail.image.path).to end_with 'default.jpg'
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when full_image_field is nil' do
|
40
|
-
before do
|
41
|
-
allow(Spotlight::Engine.config).to receive_messages(full_image_field: nil)
|
42
|
-
end
|
43
|
-
it "doesn't query solr" do
|
44
|
-
expect(subject).not_to receive(:documents)
|
45
|
-
subject.set_default_thumbnail
|
46
|
-
expect(subject.thumbnail).to be_nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
13
|
describe 'for a search matching all items' do
|
53
14
|
let(:query_params) { {} }
|
54
15
|
|
55
16
|
it 'has items' do
|
56
17
|
expect(subject.documents.size).to eq 55
|
57
18
|
end
|
58
|
-
|
59
|
-
it 'has images' do
|
60
|
-
expect(subject.images.size).to eq(55)
|
61
|
-
expect(subject.images.map(&:last)).to include 'https://stacks.stanford.edu/image/dq287tq6352/dq287tq6352_05_0001_thumb',
|
62
|
-
'https://stacks.stanford.edu/image/jp266yb7109/jp266yb7109_05_0001_thumb'
|
63
|
-
end
|
64
19
|
end
|
65
20
|
|
66
21
|
describe 'default_scope' do
|