commonwealth-vlr-engine 0.0.4 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_120x120.png +0 -0
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_152x152.png +0 -0
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_60x60.png +0 -0
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_76x76.png +0 -0
- data/app/assets/javascripts/blacklight_google_analytics/blacklight_google_analytics.js.erb +11 -0
- data/app/assets/javascripts/commonwealth-vlr-engine.js +3 -0
- data/app/assets/javascripts/commonwealth-vlr-engine/download_utils.js +4 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/commonwealth-vlr-engine.css +1 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/downloads.scss +18 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/facets.scss +64 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/vlr_dependencies.css +3 -1
- data/app/controllers/bookmarks_controller.rb +7 -2
- data/app/controllers/collections_controller.rb +1 -109
- data/app/controllers/concerns/commonwealth_vlr_engine/collections_controller_behavior.rb +132 -0
- data/app/controllers/concerns/commonwealth_vlr_engine/downloads_controller_behavior.rb +184 -0
- data/app/controllers/concerns/commonwealth_vlr_engine/institutions_controller_behavior.rb +70 -0
- data/app/controllers/downloads_controller.rb +4 -0
- data/app/controllers/iiif_manifest_controller.rb +2 -7
- data/app/controllers/image_viewer_controller.rb +3 -13
- data/app/controllers/institutions_controller.rb +1 -65
- data/app/controllers/ocr_search_controller.rb +1 -1
- data/app/controllers/saved_searches_controller.rb +2 -0
- data/app/controllers/search_history_controller.rb +2 -0
- data/app/helpers/commonwealth_vlr_engine/application_helper.rb +20 -2
- data/app/helpers/commonwealth_vlr_engine/catalog_helper.rb +36 -53
- data/app/helpers/commonwealth_vlr_engine/downloads_helper_behavior.rb +192 -0
- data/app/helpers/commonwealth_vlr_engine/facets_helper.rb +3 -1
- data/app/helpers/commonwealth_vlr_engine/ocr_search_helper_behavior.rb +5 -0
- data/app/helpers/commonwealth_vlr_engine/search_history_constraints_helper.rb +25 -0
- data/app/helpers/downloads_helper.rb +3 -0
- data/app/views/catalog/_add_this.html.erb +3 -1
- data/app/views/catalog/_folder_item_control.html.erb +2 -1
- data/app/views/catalog/_index_mapview.html.erb +9 -0
- data/app/views/catalog/_more_like_this.html.erb +1 -1
- data/app/views/catalog/_show_cite_tools.html.erb +3 -0
- data/app/views/catalog/_show_default.html.erb +13 -12
- data/app/views/catalog/_show_partials/_show_book_viewer_link.html.erb +1 -1
- data/app/views/catalog/_show_partials/_show_default_metadata.html.erb +3 -3
- data/app/views/catalog/_show_partials/_show_downloads.html.erb +1 -1
- data/app/views/catalog/_show_partials/_show_volumes.html.erb +1 -1
- data/app/views/catalog/_show_sharing_tools.html.erb +3 -0
- data/app/views/collections/show.html.erb +1 -0
- data/app/views/downloads/_terms_of_use.html.erb +29 -0
- data/app/views/downloads/show.html.erb +29 -0
- data/app/views/image_viewer/_render_book_viewer.html.erb +1 -1
- data/app/views/institutions/show.html.erb +2 -10
- data/app/views/layouts/commonwealth-vlr-engine.html.erb +1 -4
- data/app/views/ocr_search/_index_ocr_list.html.erb +3 -3
- data/app/views/shared/_mobile_icon_tags.html.erb +4 -0
- data/app/views/shared/_search_form_header.html.erb +1 -1
- data/app/views/shared/_tools.html.erb +5 -5
- data/commonwealth-vlr-engine.gemspec +8 -6
- data/config/initializers/patch_blacklight_advanced_search.rb +6 -6
- data/config/initializers/patch_blacklight_range_limit.rb +18 -0
- data/config/jetty.yml +1 -1
- data/config/locales/commonwealth-vlr-engine.en.yml +12 -0
- data/config/routes.rb +6 -0
- data/lib/commonwealth-vlr-engine.rb +1 -0
- data/lib/commonwealth-vlr-engine/controller.rb +18 -3
- data/lib/commonwealth-vlr-engine/controller_override.rb +79 -21
- data/lib/commonwealth-vlr-engine/engine.rb +1 -0
- data/lib/commonwealth-vlr-engine/render_constraints_override.rb +15 -14
- data/lib/commonwealth-vlr-engine/search_builder/collections_search_builder.rb +1 -1
- data/lib/commonwealth-vlr-engine/search_builder/commonwealth_search_builder_behavior.rb +13 -1
- data/lib/commonwealth-vlr-engine/search_builder/flagged_search_builder.rb +1 -1
- data/lib/commonwealth-vlr-engine/search_builder/institutions_search_builder.rb +1 -1
- data/lib/commonwealth-vlr-engine/search_builder/mlt_search_builder.rb +2 -1
- data/lib/commonwealth-vlr-engine/streaming.rb +50 -0
- data/lib/commonwealth-vlr-engine/version.rb +1 -1
- data/lib/generators/commonwealth_vlr_engine/routes_generator.rb +8 -0
- data/lib/generators/commonwealth_vlr_engine/templates/commonwealth_search_builder.rb +4 -3
- data/lib/generators/commonwealth_vlr_engine/templates/config/vlr.yml +3 -0
- data/solr_conf/conf/solrconfig.xml +42 -5
- data/spec/controllers/collections_controller_spec.rb +20 -0
- data/spec/controllers/downloads_controller_spec.rb +65 -0
- data/spec/controllers/image_viewer_controller_spec.rb +0 -18
- data/spec/controllers/institutions_controller_spec.rb +7 -0
- data/spec/features/advanced_search_date_range_spec.rb +36 -0
- data/spec/features/collections/index_spec.rb +6 -0
- data/spec/features/collections/show_spec.rb +38 -0
- data/spec/features/more_like_this_search_spec.rb +18 -1
- data/spec/fixtures/sample_solr_documents.yml +107 -19
- data/spec/helpers/application_helper_spec.rb +9 -2
- data/spec/helpers/catalog_helper_spec.rb +26 -42
- data/spec/helpers/downloads_helper_spec.rb +173 -0
- data/spec/helpers/ocr_search_helper_spec.rb +15 -7
- data/spec/helpers/range_limit_helper_spec.rb +20 -0
- data/spec/helpers/search_history_constraints_helper_spec.rb +39 -0
- data/spec/lib/commonwealth-vlr-engine/controller_override_spec.rb +37 -0
- data/spec/lib/commonwealth-vlr-engine/render_constraints_override_spec.rb +0 -10
- data/spec/lib/commonwealth-vlr-engine/search_builder/commonwealth_search_builder_behavior_spec.rb +21 -3
- data/spec/lib/commonwealth-vlr-engine/search_builder/mlt_search_builder_spec.rb +1 -1
- metadata +99 -12
- data/app/helpers/commonwealth_vlr_engine/component_helper.rb +0 -22
- data/app/views/catalog/_show_tools.html.erb +0 -42
- data/spec/helpers/component_helper_spec.rb +0 -34
@@ -12,9 +12,9 @@ describe ApplicationHelper do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#render_format_index' do
|
15
|
-
let(:
|
15
|
+
let(:opts) { {value: ['Maps']} }
|
16
16
|
it 'should return the right value' do
|
17
|
-
expect(helper.render_format_index(
|
17
|
+
expect(helper.render_format_index(opts)).to eq('Maps/Atlases')
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -25,6 +25,13 @@ describe ApplicationHelper do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe '#date_range_constraints_to_s' do
|
29
|
+
let(:sample_params) { {date_start: '1970', date_end: '2000'} }
|
30
|
+
it 'should return the right string' do
|
31
|
+
expect(helper.date_range_constraints_to_s(sample_params)).to eq('1970-2000')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
28
35
|
describe '#link_to_facet' do
|
29
36
|
|
30
37
|
it 'should create a link to catalog#index with the facet params and display value' do
|
@@ -76,47 +76,22 @@ describe CatalogHelper do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe '
|
79
|
+
describe 'image file helpers' do
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
@download_links = helper.create_download_links(document, files_hash, 'link_class')
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#create_download_links' do
|
88
|
-
|
89
|
-
it 'should return an array of links' do
|
90
|
-
expect(@download_links.length).to eq(2)
|
91
|
-
expect(@download_links.first.match(/\A<a[a-z =\\"_]*href=/)).to be_truthy
|
81
|
+
describe '#has_image_files?' do
|
82
|
+
it 'should return true' do
|
83
|
+
expect(helper.has_image_files?(files_hash)).to be_truthy
|
92
84
|
end
|
93
|
-
|
94
|
-
it 'should link to the productionMaster datastream' do
|
95
|
-
expect(@download_links.first).to include("href=\"#{FEDORA_URL['url']}/objects/#{image_pid}/datastreams/productionMaster/content")
|
96
|
-
end
|
97
|
-
|
98
85
|
end
|
99
86
|
|
100
|
-
describe '#
|
101
|
-
|
102
|
-
|
87
|
+
describe '#image_file_pids' do
|
88
|
+
let (:image_file_pids_result) { helper.image_file_pids(files_hash[:images]) }
|
89
|
+
it 'should return an array of ImageFile pids' do
|
90
|
+
expect(image_file_pids_result.length).to eq(2)
|
91
|
+
expect(image_file_pids_result.first).to eq(image_pid)
|
103
92
|
end
|
104
93
|
end
|
105
94
|
|
106
|
-
describe '#ia_download_title' do
|
107
|
-
it 'should return the correct download title' do
|
108
|
-
expect(helper.ia_download_title('mobi')).to eq('Kindle')
|
109
|
-
expect(helper.ia_download_title('zip')).to eq('Daisy')
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
describe '#has_image_files?' do
|
116
|
-
it 'should return an array of ImageFile pids' do
|
117
|
-
expect(helper.has_image_files?(files_hash).length).to eq(2)
|
118
|
-
expect(helper.has_image_files?(files_hash).first).to eq(image_pid)
|
119
|
-
end
|
120
95
|
end
|
121
96
|
|
122
97
|
describe '#has_volumes?' do
|
@@ -286,12 +261,19 @@ describe CatalogHelper do
|
|
286
261
|
|
287
262
|
describe 'copyright date' do
|
288
263
|
it 'should return the correct date value' do
|
289
|
-
expect(helper.render_mods_date('1984', nil, nil, 'copyrightDate')).to eq('
|
264
|
+
expect(helper.render_mods_date('1984', nil, nil, 'copyrightDate')).to eq('(c) 1984')
|
290
265
|
end
|
291
266
|
end
|
292
267
|
|
293
268
|
end
|
294
269
|
|
270
|
+
describe '#render_search_to_page_title' do
|
271
|
+
before { @page_title = helper.render_search_to_page_title({mlt_id: item_pid}) }
|
272
|
+
it 'should return the correct string for the page title' do
|
273
|
+
expect(@page_title).to include(I18n.t('blacklight.more_like_this.constraint_label'))
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
295
277
|
describe '#render_mods_xml_record' do
|
296
278
|
before { @mods_xml_doc = helper.render_mods_xml_record(item_pid) }
|
297
279
|
it 'should return the XML document for the MODS record' do
|
@@ -342,27 +324,29 @@ describe CatalogHelper do
|
|
342
324
|
|
343
325
|
describe '#thumbnail_url' do
|
344
326
|
|
327
|
+
let(:document_to_hash) { document.to_h }
|
328
|
+
|
345
329
|
it 'should return the datastream path if there is an exemplary_image_ssi value' do
|
346
330
|
expect(helper.thumbnail_url(document)).to eq("#{FEDORA_URL['url']}/objects/#{image_pid}/datastreams/thumbnail300/content")
|
347
331
|
end
|
348
332
|
|
349
333
|
describe 'with no exemplary image' do
|
350
334
|
|
351
|
-
before {
|
335
|
+
before { document_to_hash.delete('exemplary_image_ssi') }
|
352
336
|
|
353
337
|
it 'should return the proper icon if there is a type_of_resource_ssim value' do
|
354
|
-
expect(helper.thumbnail_url(
|
338
|
+
expect(helper.thumbnail_url(SolrDocument.new(document_to_hash))).to include('dc_image-icon.png')
|
355
339
|
end
|
356
340
|
|
357
341
|
describe 'with no type_of_resource_ssim value' do
|
358
342
|
|
359
343
|
before do
|
360
|
-
|
361
|
-
|
344
|
+
document_to_hash.delete('type_of_resource_ssim')
|
345
|
+
document_to_hash[blacklight_config.index.display_type_field] = 'Collection'
|
362
346
|
end
|
363
347
|
|
364
348
|
it 'should return the collection icon' do
|
365
|
-
expect(helper.thumbnail_url(
|
349
|
+
expect(helper.thumbnail_url(SolrDocument.new(document_to_hash))).to include('dc_collection-icon.png')
|
366
350
|
end
|
367
351
|
|
368
352
|
end
|
@@ -371,10 +355,10 @@ describe CatalogHelper do
|
|
371
355
|
|
372
356
|
describe 'flagged item' do
|
373
357
|
|
374
|
-
before {
|
358
|
+
before { document_to_hash[blacklight_config.flagged_field] = true }
|
375
359
|
|
376
360
|
it 'should return the icon rather than the exemplary image' do
|
377
|
-
expect(helper.thumbnail_url(
|
361
|
+
expect(helper.thumbnail_url(SolrDocument.new(document_to_hash))).to include('dc_image-icon.png')
|
378
362
|
end
|
379
363
|
|
380
364
|
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DownloadsHelper do
|
4
|
+
|
5
|
+
class DownloadsHelperTestClass < CatalogController
|
6
|
+
cattr_accessor :blacklight_config
|
7
|
+
|
8
|
+
include Blacklight::SearchHelper
|
9
|
+
include CommonwealthVlrEngine::Finder
|
10
|
+
|
11
|
+
def initialize blacklight_config
|
12
|
+
self.blacklight_config = blacklight_config
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:blacklight_config) { CatalogController.blacklight_config }
|
18
|
+
let(:downloads_helper_test_class) { DownloadsHelperTestClass.new blacklight_config }
|
19
|
+
let(:item_pid) { 'bpl-dev:h702q6403' }
|
20
|
+
let(:image_pid) { 'bpl-dev:h702q641c' }
|
21
|
+
let(:document) { Blacklight.default_index.search({:q => "id:\"#{item_pid}\"", :rows => 1}).documents.first }
|
22
|
+
let(:files_hash) { downloads_helper_test_class.get_files(item_pid) }
|
23
|
+
let(:object_profile) { JSON.parse(files_hash[:images].first['object_profile_ssm'].first) }
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
27
|
+
end
|
28
|
+
|
29
|
+
before do
|
30
|
+
# copy :images to :documents, since we don't have any non-image items to test with at the moment
|
31
|
+
files_hash[:documents] = files_hash[:images]
|
32
|
+
@download_links = helper.create_download_links(document, files_hash)
|
33
|
+
@image_datastreams_output = helper.image_datastreams(object_profile)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#create_download_links' do
|
37
|
+
it 'should return an array of links' do
|
38
|
+
expect(@download_links.length).to eq(5)
|
39
|
+
expect(@download_links.first.match(/\A<a[a-z -=\\"_]*href=/)).to be_truthy
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#download_link_class' do
|
44
|
+
it 'should return a string' do
|
45
|
+
expect(helper.download_link_class.class).to eq(String)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#download_link_options' do
|
50
|
+
it 'should return a Hash of link options' do
|
51
|
+
expect(helper.download_link_options[:class]).to be_truthy
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#has_downloadable_files?' do
|
56
|
+
it 'should return true if there are documents, audio, or generic files' do
|
57
|
+
expect(helper.has_downloadable_files?(document, files_hash)).to be_truthy
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#has_downloadable_images?' do
|
62
|
+
it 'should return true if there are image files and the license allows download' do
|
63
|
+
expect(helper.has_downloadable_images?(document, files_hash)).to be_truthy
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#ia_download_title' do
|
68
|
+
it 'should return the correct download title' do
|
69
|
+
expect(helper.ia_download_title('mobi')).to eq('Kindle')
|
70
|
+
expect(helper.ia_download_title('zip')).to eq('Daisy')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#image_datastreams' do
|
75
|
+
it 'should return an array of image datastream ids' do
|
76
|
+
expect(@image_datastreams_output.class).to eq(Array)
|
77
|
+
expect(@image_datastreams_output[0]).to eq('productionMaster')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#image_download_links' do
|
82
|
+
|
83
|
+
before do
|
84
|
+
@image_download_links = helper.image_download_links(document, files_hash[:images])
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should return an array of links' do
|
88
|
+
expect(@image_download_links.length).to eq(3)
|
89
|
+
expect(@image_download_links.first.match(/\A<a[a-z -=\\"_]*href=/)).to be_truthy
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#license_allows_download?' do
|
95
|
+
it 'should return true if the license allows download' do
|
96
|
+
expect(helper.license_allows_download?(document)).to be_truthy
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#file_download_link' do
|
101
|
+
|
102
|
+
let (:file_download_link_output) { helper.file_download_link(image_pid,
|
103
|
+
'foo',
|
104
|
+
object_profile,
|
105
|
+
@image_datastreams_output[0]) }
|
106
|
+
|
107
|
+
it 'should return a link' do
|
108
|
+
expect(file_download_link_output.match(/\A<a[a-z -=\\"_]*href=/)).to be_truthy
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should link to the downloads controller show action with the correct datastream param' do
|
112
|
+
expect(file_download_link_output).to include(download_path(image_pid, datastream_id: @image_datastreams_output[0]))
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should include a <span> with the file type and size' do
|
116
|
+
expect(file_download_link_output).to include('<span')
|
117
|
+
expect(file_download_link_output).to include('TIF')
|
118
|
+
expect(file_download_link_output).to include('10.5 MB')
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#file_type_string' do
|
124
|
+
it 'should return the correct file type' do
|
125
|
+
expect(helper.file_type_string(@image_datastreams_output[0], object_profile)).to eq('TIF')
|
126
|
+
expect(helper.file_type_string(@image_datastreams_output[1], nil)).to eq('JPEG')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#file_size_string' do
|
131
|
+
it 'should return the correct file size' do
|
132
|
+
expect(helper.file_size_string(@image_datastreams_output[0], object_profile)).to eq('10.5 MB')
|
133
|
+
expect(helper.file_size_string(@image_datastreams_output[1], nil)).to eq('multi-file ZIP')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#setup_zip_object_profile' do
|
138
|
+
|
139
|
+
let (:zip_object_profile) { helper.setup_zip_object_profile(files_hash[:images], @image_datastreams_output[0]) }
|
140
|
+
|
141
|
+
it 'should return a hash with the right structure' do
|
142
|
+
expect(zip_object_profile['zip']).to be_truthy
|
143
|
+
expect(zip_object_profile['datastreams'][@image_datastreams_output[0]]['dsSize']).to be_truthy
|
144
|
+
end
|
145
|
+
|
146
|
+
# should be greater than 10.5 MB
|
147
|
+
it 'should estimate the zip size' do
|
148
|
+
expect(zip_object_profile['datastreams'][@image_datastreams_output[0]]['dsSize'] > 11010048).to be_truthy
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#url_for_download' do
|
154
|
+
|
155
|
+
it 'should return the correct link path for a hosted item' do
|
156
|
+
expect(helper.url_for_download(document, @image_datastreams_output[0])).to include(trigger_downloads_path(item_pid,
|
157
|
+
datastream_id: @image_datastreams_output[0]))
|
158
|
+
end
|
159
|
+
|
160
|
+
describe 'item from Internet Archive' do
|
161
|
+
|
162
|
+
let (:document_to_hash) { document.to_h }
|
163
|
+
before { document_to_hash['identifier_ia_id_ssi'] = 'foo' }
|
164
|
+
|
165
|
+
it 'should return the correct link path for an Internet Archive item' do
|
166
|
+
expect(helper.url_for_download(SolrDocument.new(document_to_hash), 'JPEG2000')).to include('archive.org')
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
@@ -16,11 +16,19 @@ describe OcrSearchHelper do
|
|
16
16
|
|
17
17
|
let(:blacklight_config) { CatalogController.blacklight_config }
|
18
18
|
let(:ocr_search_helper_test_class) { OcrSearchHelperTestClass.new blacklight_config }
|
19
|
+
let(:book_pid) { 'bpl-dev:7s75dn48d' }
|
20
|
+
let(:book_document) { Blacklight.default_index.search({:q => "id:\"#{book_pid}\"", :rows => 1}).documents.first }
|
19
21
|
|
20
22
|
before(:each) do
|
21
23
|
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
22
24
|
end
|
23
25
|
|
26
|
+
describe '#has_searchable_text?' do
|
27
|
+
it 'should return true if the item has searchable text' do
|
28
|
+
expect(helper.has_searchable_text?(book_document)).to be_truthy
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
24
32
|
describe '#ocr_q_params' do
|
25
33
|
|
26
34
|
let(:current_search_session) { double(:query_params => {'q' => 'foo'}) }
|
@@ -33,21 +41,20 @@ describe OcrSearchHelper do
|
|
33
41
|
|
34
42
|
describe '#render_page_link' do
|
35
43
|
|
36
|
-
let(:book_pid) { 'bpl-dev:7s75dn48d' }
|
37
44
|
let(:page_pid) { 'bpl-dev:7s75dn58n' }
|
38
|
-
let(:
|
39
|
-
let(:image_pid_list) { ocr_search_helper_test_class.
|
45
|
+
let(:page_document) { Blacklight.default_index.search({:q => "id:\"#{page_pid}\"", :rows => 1}).documents.first }
|
46
|
+
let(:image_pid_list) { ocr_search_helper_test_class.image_file_pids(ocr_search_helper_test_class.get_image_files(book_pid)) }
|
40
47
|
|
41
48
|
describe 'with a page_num_field value' do
|
42
49
|
|
43
|
-
before { @ocr_page_link = helper.render_page_link(
|
50
|
+
before { @ocr_page_link = helper.render_page_link(page_document, image_pid_list, book_pid) }
|
44
51
|
|
45
52
|
it 'should create a link to the book viewer' do
|
46
53
|
expect(@ocr_page_link).to include("href=\"/book_viewer/#{book_pid}?ocr_q=#1/1")
|
47
54
|
end
|
48
55
|
|
49
56
|
it 'should have the correct label' do
|
50
|
-
expect(@ocr_page_link).to include(
|
57
|
+
expect(@ocr_page_link).to include(page_document[blacklight_config.page_num_field.to_sym])
|
51
58
|
end
|
52
59
|
|
53
60
|
end
|
@@ -55,8 +62,9 @@ describe OcrSearchHelper do
|
|
55
62
|
describe 'without page_num_field value' do
|
56
63
|
|
57
64
|
before do
|
58
|
-
|
59
|
-
|
65
|
+
no_page_num = page_document.to_h
|
66
|
+
no_page_num[blacklight_config.page_num_field] = nil
|
67
|
+
@ocr_page_link = helper.render_page_link(SolrDocument.new(no_page_num), image_pid_list, book_pid)
|
60
68
|
end
|
61
69
|
|
62
70
|
it 'should have the correct label' do
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RangeLimitHelper do
|
4
|
+
|
5
|
+
let(:range_field_name) { 'date_facet_yearly_ssim' }
|
6
|
+
let(:params) { {'f'=>{'institution_name_ssim'=>['Boston Public Library']},
|
7
|
+
'id'=>'bpl-dev:abcd12345',
|
8
|
+
'range_end'=>'1922s',
|
9
|
+
'range_field'=> range_field_name,
|
10
|
+
'range_start'=>'1851s'} }
|
11
|
+
|
12
|
+
describe '#add_range_missing' do
|
13
|
+
|
14
|
+
it 'create a link to catalog#show' do
|
15
|
+
expect(helper.add_range_missing(range_field_name,params)).to include(search_catalog_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CommonwealthVlrEngine::SearchHistoryConstraintsHelper do
|
4
|
+
|
5
|
+
class SearchHistoryConstraintsHelperTestClass < CatalogController
|
6
|
+
attr_accessor :params
|
7
|
+
include CommonwealthVlrEngine::ApplicationHelper
|
8
|
+
end
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@fake_controller = SearchHistoryConstraintsHelperTestClass.new
|
12
|
+
@fake_controller.extend(CommonwealthVlrEngine::SearchHistoryConstraintsHelper)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'render_search_to_s_mlt' do
|
16
|
+
|
17
|
+
let (:mlt_test_params) { {mlt_id: 'bpl-dev:h702q6403'} }
|
18
|
+
|
19
|
+
it 'should return render_search_to_s_element when mlt params are present' do
|
20
|
+
expect(@fake_controller).to receive(:render_search_to_s_element)
|
21
|
+
expect(@fake_controller).to receive(:render_filter_value)
|
22
|
+
@fake_controller.render_search_to_s_mlt(mlt_test_params)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'render_search_to_s_advanced' do
|
28
|
+
|
29
|
+
let (:date_range_params) { {date_start: '1970', date_end: '2000'} }
|
30
|
+
|
31
|
+
it 'should return render_search_to_s_element when date range params are present' do
|
32
|
+
expect(@fake_controller).to receive(:render_search_to_s_element)
|
33
|
+
expect(@fake_controller).to receive(:render_filter_value)
|
34
|
+
@fake_controller.render_search_to_s_advanced(date_range_params)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CommonwealthVlrEngine::ControllerOverride do
|
4
|
+
|
5
|
+
class ControllerOverrideTestClass < CatalogController
|
6
|
+
end
|
7
|
+
|
8
|
+
let (:mock_controller) { ControllerOverrideTestClass.new }
|
9
|
+
let (:override_config) { mock_controller.blacklight_config }
|
10
|
+
|
11
|
+
describe 'customized blacklight configuration' do
|
12
|
+
|
13
|
+
describe 'index document actions' do
|
14
|
+
|
15
|
+
it 'should remove the unwanted actions' do
|
16
|
+
expect(override_config.index.document_actions[:bookmark]).to be_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'show document actions' do
|
22
|
+
|
23
|
+
it 'should remove the unwanted actions' do
|
24
|
+
expect(override_config.show.document_actions[:email]).to be_empty
|
25
|
+
expect(override_config.show.document_actions[:bookmark]).to be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should add the desired actions' do
|
29
|
+
expect(override_config.show.document_actions[:custom_email]).not_to be_empty
|
30
|
+
expect(override_config.show.document_actions[:folder_items]).not_to be_empty
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|