blacklight-spotlight 3.0.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spotlight/admin/blocks/block.js +4 -0
  3. data/app/controllers/spotlight/pages_controller.rb +1 -5
  4. data/app/helpers/spotlight/job_trackers_helper.rb +1 -1
  5. data/app/jobs/spotlight/process_bulk_updates_csv_job.rb +1 -1
  6. data/app/jobs/spotlight/reindex_exhibit_job.rb +9 -1
  7. data/app/models/sir_trevor_rails/blocks/browse_block.rb +1 -1
  8. data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +3 -3
  9. data/app/models/spotlight/page.rb +8 -0
  10. data/app/models/spotlight/search.rb +3 -1
  11. data/app/views/layouts/spotlight/base.html.erb +5 -2
  12. data/app/views/shared/_body_preamble.html.erb +0 -0
  13. data/app/views/shared/_footer.html.erb +0 -1
  14. data/app/views/shared/_masthead.html.erb +1 -1
  15. data/app/views/shared/_user_util_links.html.erb +8 -2
  16. data/app/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb +1 -1
  17. data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -0
  18. data/config/locales/spotlight.en.yml +1 -1
  19. data/lib/generators/spotlight/install_generator.rb +16 -7
  20. data/lib/spotlight/version.rb +1 -1
  21. data/lib/tasks/spotlight_tasks.rake +4 -1
  22. data/spec/examples.txt +1497 -1493
  23. data/spec/factories/bulk_updates.rb +6 -0
  24. data/spec/features/javascript/blocks/search_result_block_spec.rb +1 -1
  25. data/spec/features/report_a_problem_spec.rb +1 -0
  26. data/spec/fixtures/iiif_responses.rb +81 -81
  27. data/spec/fixtures/updated-bulk-update-template-no-cols.csv +4 -0
  28. data/spec/jobs/spotlight/process_bulk_updates_csv_job_spec.rb +8 -0
  29. data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +19 -1
  30. data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -2
  31. data/spec/models/spotlight/page_configurations_spec.rb +2 -2
  32. data/spec/test_app_templates/catalog_controller.rb +0 -1
  33. data/spec/views/spotlight/pages/show.html.erb_spec.rb +17 -6
  34. metadata +5 -4
  35. data/spec/views/shared/_footer.html.erb_spec.rb +0 -15
@@ -7,6 +7,12 @@ FactoryBot.define do
7
7
  exhibit
8
8
  end
9
9
 
10
+ factory :bulk_update_no_cols, class: 'Spotlight::BulkUpdate' do
11
+ file { Rack::Test::UploadedFile.new(File.expand_path(File.join('..', 'fixtures', 'updated-bulk-update-template-no-cols.csv'), __dir__)) }
12
+
13
+ exhibit
14
+ end
15
+
10
16
  factory :tagged_bulk_update, class: 'Spotlight::BulkUpdate' do
11
17
  file { Rack::Test::UploadedFile.new(File.expand_path(File.join('..', 'fixtures', 'updated-bulk-update-template-w-tags.csv'), __dir__)) }
12
18
 
@@ -42,6 +42,6 @@ describe 'Search Result Block', type: :feature, js: true do
42
42
  end
43
43
 
44
44
  # Documents should exist
45
- expect(page).to have_css('.documents .document')
45
+ expect(page).to have_css('.documents-gallery .document')
46
46
  end
47
47
  end
@@ -28,6 +28,7 @@ describe 'Report a Problem', type: :feature do
28
28
  click_on 'Feedback'
29
29
 
30
30
  expect(page).to have_css('h2', text: 'Contact us', visible: true)
31
+ expect(page).to have_css('#contact_form_name', count: 1)
31
32
  end
32
33
 
33
34
  it 'accepts a problem report', js: true do
@@ -5,24 +5,24 @@ module IiifResponses
5
5
  {
6
6
  "@id": 'uri://for-top-level-collection',
7
7
  "@type": 'sc:Collection',
8
- "label": 'Complex Collection',
9
- "collections": [
8
+ label: 'Complex Collection',
9
+ collections: [
10
10
  {
11
11
  "@id": 'uri://for-child-collection1',
12
12
  "@type": 'sc:Collection',
13
- "label": 'Child Collection 1'
13
+ label: 'Child Collection 1'
14
14
  },
15
15
  {
16
16
  "@id": 'uri://for-child-collection2',
17
17
  "@type": 'sc:Collection',
18
- "label": 'Child Collection 2'
18
+ label: 'Child Collection 2'
19
19
  }
20
20
  ],
21
- "manifests": [
21
+ manifests: [
22
22
  {
23
23
  "@id": 'uri://for-manifest1',
24
24
  "@type": 'sc:Manifest',
25
- "label": 'Test Manifest 1'
25
+ label: 'Test Manifest 1'
26
26
  }
27
27
  ]
28
28
  }.to_json
@@ -32,19 +32,19 @@ module IiifResponses
32
32
  {
33
33
  "@id": 'uri://for-child-collection1',
34
34
  "@type": 'sc:Collection',
35
- "label": 'Child Collection 1',
36
- "collections": [
35
+ label: 'Child Collection 1',
36
+ collections: [
37
37
  {
38
38
  "@id": 'uri://for-child-collection3',
39
39
  "@type": 'sc:Collection',
40
- "label": 'Child Collection 3'
40
+ label: 'Child Collection 3'
41
41
  }
42
42
  ],
43
- "manifests": [
43
+ manifests: [
44
44
  {
45
45
  "@id": 'uri://for-manifest2',
46
46
  "@type": 'sc:Manifest',
47
- "label": 'Test Manifest 2'
47
+ label: 'Test Manifest 2'
48
48
  }
49
49
  ]
50
50
  }.to_json
@@ -54,12 +54,12 @@ module IiifResponses
54
54
  {
55
55
  "@id": 'uri://for-child-collection2',
56
56
  "@type": 'sc:Collection',
57
- "label": 'Child Collection 2',
58
- "manifests": [
57
+ label: 'Child Collection 2',
58
+ manifests: [
59
59
  {
60
60
  "@id": 'uri://for-manifest4',
61
61
  "@type": 'sc:Manifest',
62
- "label": 'Test Manifest 4'
62
+ label: 'Test Manifest 4'
63
63
  }
64
64
  ]
65
65
  }.to_json
@@ -69,12 +69,12 @@ module IiifResponses
69
69
  {
70
70
  "@id": 'uri://for-child-collection3',
71
71
  "@type": 'sc:Collection',
72
- "label": 'Child Collection 3',
73
- "manifests": [
72
+ label: 'Child Collection 3',
73
+ manifests: [
74
74
  {
75
75
  "@id": 'uri://for-manifest3',
76
76
  "@type": 'sc:Manifest',
77
- "label": 'Test Manifest 3'
77
+ label: 'Test Manifest 3'
78
78
  }
79
79
  ]
80
80
  }.to_json
@@ -84,40 +84,40 @@ module IiifResponses
84
84
  {
85
85
  "@id": 'uri://for-manifest1',
86
86
  "@type": 'sc:Manifest',
87
- "label": 'Test Manifest 1',
88
- "attribution": 'Attribution Data',
89
- "description": 'A test IIIF manifest',
90
- "license": 'http://www.example.org/license.html',
91
- "metadata": [
87
+ label: 'Test Manifest 1',
88
+ attribution: 'Attribution Data',
89
+ description: 'A test IIIF manifest',
90
+ license: 'http://www.example.org/license.html',
91
+ metadata: [
92
92
  {
93
- "label": 'Author',
94
- "value": 'John Doe'
93
+ label: 'Author',
94
+ value: 'John Doe'
95
95
  },
96
96
  {
97
- "label": 'Author',
98
- "value": 'Jane Doe'
97
+ label: 'Author',
98
+ value: 'Jane Doe'
99
99
  },
100
100
  {
101
- "label": 'Another Field',
102
- "value": 'Some data'
101
+ label: 'Another Field',
102
+ value: 'Some data'
103
103
  }
104
104
  ],
105
- "thumbnail": {
105
+ thumbnail: {
106
106
  "@id": 'uri://to-thumbnail'
107
107
  },
108
- "sequences": [
108
+ sequences: [
109
109
  {
110
110
  "@type": 'sc:Sequence',
111
- "canvases": [
111
+ canvases: [
112
112
  {
113
113
  "@type": 'sc:Canvas',
114
- "images": [
114
+ images: [
115
115
  {
116
116
  "@type": 'oa:Annotation',
117
- "resource": {
117
+ resource: {
118
118
  "@type": 'dcterms:Image',
119
119
  "@id": 'uri://full-image',
120
- "service": {
120
+ service: {
121
121
  "@id": 'uri://to-image-service'
122
122
  }
123
123
  }
@@ -134,47 +134,47 @@ module IiifResponses
134
134
  {
135
135
  "@id": 'uri://for-manifest2',
136
136
  "@type": 'sc:Manifest',
137
- "label": {
137
+ label: {
138
138
  "@value": 'Test Manifest 2',
139
139
  "@language": 'en'
140
140
  },
141
- "attribution": 'Attribution Data',
142
- "description": 'A test IIIF manifest',
143
- "license": 'http://www.example.org/license.html',
144
- "metadata": [
141
+ attribution: 'Attribution Data',
142
+ description: 'A test IIIF manifest',
143
+ license: 'http://www.example.org/license.html',
144
+ metadata: [
145
145
  {
146
- "label": 'Contributor',
147
- "value": 'John Doe'
146
+ label: 'Contributor',
147
+ value: 'John Doe'
148
148
  },
149
149
  {
150
- "label": 'Yet Another Field',
151
- "value": 'Some data'
150
+ label: 'Yet Another Field',
151
+ value: 'Some data'
152
152
  }
153
153
  ],
154
- "thumbnail": {
154
+ thumbnail: {
155
155
  "@id": 'uri://to-thumbnail'
156
156
  },
157
- "sequences": [
157
+ sequences: [
158
158
  {
159
159
  "@type": 'sc:Sequence',
160
- "canvases": [
160
+ canvases: [
161
161
  {
162
162
  "@type": 'sc:Canvas',
163
- "images": [
163
+ images: [
164
164
  {
165
165
  "@type": 'oa:Annotation',
166
- "resource": {
166
+ resource: {
167
167
  "@type": 'dcterms:Image',
168
- "service": {
168
+ service: {
169
169
  "@id": 'uri://to-image-service'
170
170
  }
171
171
  }
172
172
  },
173
173
  {
174
174
  "@type": 'oa:Annotation',
175
- "resource": {
175
+ resource: {
176
176
  "@type": 'dcterms:Image',
177
- "service": {
177
+ service: {
178
178
  "@id": 'uri://to-image-service2'
179
179
  }
180
180
  }
@@ -191,7 +191,7 @@ module IiifResponses
191
191
  {
192
192
  "@id": 'uri://for-manifest3',
193
193
  "@type": 'sc:Manifest',
194
- "label": [
194
+ label: [
195
195
  {
196
196
  "@value": 'Test Manifest 3',
197
197
  "@language": 'en'
@@ -201,34 +201,34 @@ module IiifResponses
201
201
  "@language": 'fr'
202
202
  }
203
203
  ],
204
- "attribution": 'Attribution Data',
205
- "description": 'A test IIIF manifest',
206
- "license": 'http://www.example.org/license.html',
207
- "metadata": [
204
+ attribution: 'Attribution Data',
205
+ description: 'A test IIIF manifest',
206
+ license: 'http://www.example.org/license.html',
207
+ metadata: [
208
208
  {
209
- "label": 'Author',
210
- "value": 'Jane Doe'
209
+ label: 'Author',
210
+ value: 'Jane Doe'
211
211
  },
212
212
  {
213
- "label": 'Collection',
214
- "value": 'Some Collection'
213
+ label: 'Collection',
214
+ value: 'Some Collection'
215
215
  }
216
216
  ],
217
- "thumbnail": {
217
+ thumbnail: {
218
218
  "@id": 'uri://to-thumbnail'
219
219
  },
220
- "sequences": [
220
+ sequences: [
221
221
  {
222
222
  "@type": 'sc:Sequence',
223
- "canvases": [
223
+ canvases: [
224
224
  {
225
225
  "@type": 'sc:Canvas',
226
- "images": [
226
+ images: [
227
227
  {
228
228
  "@type": 'oa:Annotation',
229
- "resource": {
229
+ resource: {
230
230
  "@type": 'dcterms:Image',
231
- "service": {
231
+ service: {
232
232
  "@id": 'uri://to-image-service'
233
233
  }
234
234
  }
@@ -245,35 +245,35 @@ module IiifResponses
245
245
  {
246
246
  "@id": 'uri://for-manifest4',
247
247
  "@type": 'sc:Manifest',
248
- "label": 'Test Manifest 4',
249
- "attribution": 'Attribution Data',
250
- "description": 'A test IIIF manifest',
251
- "license": 'http://www.example.org/license.html',
252
- "metadata": [
248
+ label: 'Test Manifest 4',
249
+ attribution: 'Attribution Data',
250
+ description: 'A test IIIF manifest',
251
+ license: 'http://www.example.org/license.html',
252
+ metadata: [
253
253
  {
254
- "label": 'Contributor',
255
- "value": 'Jane Doe'
254
+ label: 'Contributor',
255
+ value: 'Jane Doe'
256
256
  },
257
257
  {
258
- "label": 'Location',
259
- "value": 'Some location'
258
+ label: 'Location',
259
+ value: 'Some location'
260
260
  }
261
261
  ],
262
- "thumbnail": {
262
+ thumbnail: {
263
263
  "@id": 'uri://to-thumbnail'
264
264
  },
265
- "sequences": [
265
+ sequences: [
266
266
  {
267
267
  "@type": 'sc:Sequence',
268
- "canvases": [
268
+ canvases: [
269
269
  {
270
270
  "@type": 'sc:Canvas',
271
- "images": [
271
+ images: [
272
272
  {
273
273
  "@type": 'oa:Annotation',
274
- "resource": {
274
+ resource: {
275
275
  "@type": 'dcterms:Image',
276
- "service": {
276
+ service: {
277
277
  "@id": 'uri://to-image-service'
278
278
  }
279
279
  }
@@ -0,0 +1,4 @@
1
+ Item ID,Item Title
2
+ bm387cy2596,L'AMERIQVE
3
+ cz507zk0531,NEW MEXICO
4
+ dq287tq6352,L'AMERIQUE
@@ -36,6 +36,14 @@ describe Spotlight::ProcessBulkUpdatesCsvJob do
36
36
  expect(SolrDocument.index.connection).not_to have_received(:update)
37
37
  end
38
38
  end
39
+
40
+ context 'without a visibility column' do
41
+ let(:bulk_update) { FactoryBot.create(:bulk_update_no_cols, exhibit: exhibit) }
42
+
43
+ it 'does nothing with the data' do
44
+ expect { subject.perform_now }.not_to(change { exhibit.reload.solr_document_sidecars.where(public: false).count })
45
+ end
46
+ end
39
47
  end
40
48
 
41
49
  describe 'tags' do
@@ -3,7 +3,8 @@
3
3
  describe SirTrevorRails::Blocks::FeaturedPagesBlock do
4
4
  subject { described_class.new({ type: '', data: block_data }, page) }
5
5
 
6
- let(:page) { FactoryBot.create(:feature_page) }
6
+ let(:page) { FactoryBot.create(:feature_page, exhibit: exhibit) }
7
+ let(:exhibit) { FactoryBot.create(:exhibit) }
7
8
  let(:block_data) { {} }
8
9
 
9
10
  describe '#items' do
@@ -21,6 +22,23 @@ describe SirTrevorRails::Blocks::FeaturedPagesBlock do
21
22
  end
22
23
  end
23
24
 
25
+ describe '#pages' do
26
+ let!(:page_a) { FactoryBot.create(:feature_page, slug: 'a', exhibit: exhibit) }
27
+ let!(:translated_page_a) { page_a.clone_for_locale('a').tap { |x| x.update(published: true) && x.save } }
28
+ let!(:page_b) { FactoryBot.create(:feature_page, slug: 'b', exhibit: exhibit) }
29
+
30
+ before do
31
+ block_data[:item] = {
32
+ '0': { id: 'a', display: 'true' },
33
+ '1': { id: 'b', display: 'true' }
34
+ }
35
+ end
36
+
37
+ it 'retrieves the pages from the default locale' do
38
+ expect(subject.pages.length).to eq 2
39
+ end
40
+ end
41
+
24
42
  describe '#as_json' do
25
43
  context 'when no items are present' do
26
44
  it 'returns an empty items value' do
@@ -42,8 +42,7 @@ describe Spotlight::AccessControlsEnforcementSearchBuilder do
42
42
  it 'does not filter resources to just those created by the exhibit' do
43
43
  allow(current_ability).to receive(:can?).and_return(true)
44
44
  subject.apply_permissive_visibility_filter(solr_request)
45
- expect(solr_request).to include :fq
46
- expect(solr_request[:fq]).not_to include "{!term f=spotlight_exhibit_slug_#{exhibit.slug}_bsi}true"
45
+ expect(solr_request[:fq]).to be_blank
47
46
  end
48
47
  end
49
48
 
@@ -28,9 +28,9 @@ describe Spotlight::PageConfigurations, type: :model do
28
28
 
29
29
  describe 'downstream configured_params' do
30
30
  it 'merges the supplied hash into the configs' do
31
- expect(page_config).to receive_messages(configured_params: { 'hello': 'goodbye' })
31
+ expect(page_config).to receive_messages(configured_params: { hello: 'goodbye' })
32
32
 
33
- expect(page_config.as_json).to include('hello': 'goodbye')
33
+ expect(page_config.as_json).to include(hello: 'goodbye')
34
34
  end
35
35
 
36
36
  it 'sends the #call method to the value if it can respond (e.g. a lamda)' do
@@ -36,7 +36,6 @@ class CatalogController < ApplicationController
36
36
  config.index.thumbnail_field = Spotlight::Engine.config.thumbnail_field
37
37
 
38
38
  config.show.tile_source_field = :content_metadata_image_iiif_info_ssm
39
- config.show.partials.insert(1, :openseadragon)
40
39
 
41
40
  config.add_results_collection_tool(:sort_widget)
42
41
  config.add_results_collection_tool(:per_page_widget)
@@ -33,12 +33,23 @@ describe 'spotlight/pages/show', type: :view do
33
33
  render
34
34
  end
35
35
 
36
- it 'does not double-escape HTML entities in the HTML title' do
37
- allow(page).to receive_messages(title: 'Abbott & Costello')
38
- stub_template 'shared/_user_util_links.html.erb' => ''
39
- stub_template 'shared/_masthead.html.erb' => ''
40
- render template: 'spotlight/pages/show', layout: 'layouts/spotlight/spotlight'
41
- expect(rendered).to have_content('Abbott & Costello | Blacklight')
36
+ context 'when rendering with layout' do
37
+ before do
38
+ allow(page).to receive_messages(title: 'Abbott & Costello')
39
+ allow_any_instance_of(Spotlight::Exhibit).to receive(:searchable?).and_return(true)
40
+ stub_template 'shared/_analytics.html.erb' => 'analytics'
41
+ stub_template 'shared/_user_util_links.html.erb' => ''
42
+ stub_template 'shared/_masthead.html.erb' => ''
43
+ render template: 'spotlight/pages/show', layout: 'layouts/spotlight/spotlight'
44
+ end
45
+
46
+ it 'does not double-escape HTML entities in the HTML title' do
47
+ expect(rendered).to have_content('Abbott & Costello | Blacklight')
48
+ end
49
+
50
+ it 'includes analytics reporting' do
51
+ expect(rendered).to have_content 'analytics'
52
+ end
42
53
  end
43
54
 
44
55
  it 'does not include the page title' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-05-11 00:00:00.000000000 Z
14
+ date: 2021-10-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activejob-status
@@ -1191,6 +1191,7 @@ files:
1191
1191
  - app/views/layouts/spotlight/spotlight.html.erb
1192
1192
  - app/views/shared/_about_navbar.html.erb
1193
1193
  - app/views/shared/_analytics.html.erb
1194
+ - app/views/shared/_body_preamble.html.erb
1194
1195
  - app/views/shared/_breadcrumbs.html.erb
1195
1196
  - app/views/shared/_browse_navbar.html.erb
1196
1197
  - app/views/shared/_curated_features_navbar.html.erb
@@ -1609,6 +1610,7 @@ files:
1609
1610
  - spec/fixtures/iiif_responses.rb
1610
1611
  - spec/fixtures/json-upload-fixture.json
1611
1612
  - spec/fixtures/sample_solr_documents.yml
1613
+ - spec/fixtures/updated-bulk-update-template-no-cols.csv
1612
1614
  - spec/fixtures/updated-bulk-update-template-w-tags.csv
1613
1615
  - spec/fixtures/updated-bulk-update-template.csv
1614
1616
  - spec/helpers/spotlight/application_helper_spec.rb
@@ -1724,7 +1726,6 @@ files:
1724
1726
  - spec/uploaders/spotlight/featured_image_uploader_spec.rb
1725
1727
  - spec/views/shared/_analytics.html.erb_spec.rb
1726
1728
  - spec/views/shared/_exhibit_navbar.html.erb_spec.rb
1727
- - spec/views/shared/_footer.html.erb_spec.rb
1728
1729
  - spec/views/shared/_header_navbar.html.erb_spec.rb
1729
1730
  - spec/views/shared/_masthead.html.erb_spec.rb
1730
1731
  - spec/views/shared/_user_util_links.html.erb_spec.rb
@@ -1968,6 +1969,7 @@ test_files:
1968
1969
  - spec/fixtures/iiif_responses.rb
1969
1970
  - spec/fixtures/json-upload-fixture.json
1970
1971
  - spec/fixtures/sample_solr_documents.yml
1972
+ - spec/fixtures/updated-bulk-update-template-no-cols.csv
1971
1973
  - spec/fixtures/updated-bulk-update-template-w-tags.csv
1972
1974
  - spec/fixtures/updated-bulk-update-template.csv
1973
1975
  - spec/helpers/spotlight/application_helper_spec.rb
@@ -2083,7 +2085,6 @@ test_files:
2083
2085
  - spec/uploaders/spotlight/featured_image_uploader_spec.rb
2084
2086
  - spec/views/shared/_analytics.html.erb_spec.rb
2085
2087
  - spec/views/shared/_exhibit_navbar.html.erb_spec.rb
2086
- - spec/views/shared/_footer.html.erb_spec.rb
2087
2088
  - spec/views/shared/_header_navbar.html.erb_spec.rb
2088
2089
  - spec/views/shared/_masthead.html.erb_spec.rb
2089
2090
  - spec/views/shared/_user_util_links.html.erb_spec.rb
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'shared/_footer', type: :view do
4
- let(:current_exhibit) { double(title: 'Some title', subtitle: 'Subtitle') }
5
-
6
- before do
7
- allow(view).to receive_messages(current_exhibit: current_exhibit)
8
- end
9
-
10
- it 'includes analytics reporting' do
11
- stub_template 'shared/_analytics.html.erb' => 'analytics'
12
- render
13
- expect(rendered).to have_content 'analytics'
14
- end
15
- end