geoblacklight 4.0.0.pre.alpha.1 → 4.0.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +1 -1
  3. data/.github/workflows/ruby.yml +32 -64
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +6 -6
  6. data/.rubocop_todo.yml +0 -3
  7. data/.solr_wrapper +1 -0
  8. data/README.md +1 -4
  9. data/Rakefile +0 -1
  10. data/app/assets/images/blacklight/child-item.svg +3 -0
  11. data/app/assets/images/blacklight/collections.svg +4 -0
  12. data/app/assets/images/blacklight/datasets.svg +7 -0
  13. data/app/assets/images/blacklight/geoblacklight-icons.json +363 -332
  14. data/app/assets/images/blacklight/imagery.svg +4 -0
  15. data/app/assets/images/blacklight/maps.svg +4 -0
  16. data/app/assets/images/blacklight/michigan-state-university.svg +0 -1
  17. data/app/assets/images/blacklight/parent-item.svg +3 -0
  18. data/app/assets/images/blacklight/pennsylvania-state-university.svg +0 -1
  19. data/app/assets/images/blacklight/purdue-university.svg +0 -1
  20. data/app/assets/images/blacklight/the-ohio-state-university.svg +0 -1
  21. data/app/assets/images/blacklight/university-of-chicago.svg +0 -1
  22. data/app/assets/images/blacklight/university-of-colorado-boulder.svg +6 -0
  23. data/app/assets/images/blacklight/university-of-illinois-urbana-champaign.svg +0 -1
  24. data/app/assets/images/blacklight/university-of-iowa.svg +0 -1
  25. data/app/assets/images/blacklight/university-of-maryland.svg +0 -1
  26. data/app/assets/images/blacklight/university-of-michigan.svg +0 -1
  27. data/app/assets/images/blacklight/university-of-minnesota.svg +0 -1
  28. data/app/assets/images/blacklight/university-of-nebraska-lincoln.svg +0 -1
  29. data/app/assets/images/blacklight/university-of-wisconsin-madison.svg +0 -1
  30. data/app/assets/images/blacklight/websites.svg +4 -0
  31. data/app/assets/javascripts/geoblacklight/controls/fullscreen.js +8 -0
  32. data/app/assets/javascripts/geoblacklight/geoblacklight.js +2 -1
  33. data/app/assets/javascripts/geoblacklight/viewers/esri.js +1 -0
  34. data/app/assets/javascripts/geoblacklight/viewers/index_map.js +1 -0
  35. data/app/assets/javascripts/geoblacklight/viewers/tilejson.js +33 -0
  36. data/app/assets/javascripts/geoblacklight/viewers/tms.js +2 -2
  37. data/app/assets/javascripts/geoblacklight/viewers/viewer.js +3 -0
  38. data/app/assets/javascripts/geoblacklight/viewers/wms.js +2 -2
  39. data/app/assets/javascripts/geoblacklight/viewers/wmts.js +85 -0
  40. data/app/assets/javascripts/geoblacklight/viewers/xyz.js +10 -0
  41. data/app/assets/stylesheets/geoblacklight/geoblacklight.scss +1 -0
  42. data/app/assets/stylesheets/geoblacklight/modules/_base.scss +0 -1
  43. data/app/assets/stylesheets/geoblacklight/modules/_styles.scss +5 -1
  44. data/app/assets/stylesheets/geoblacklight/modules/downloads.scss +20 -47
  45. data/app/assets/stylesheets/geoblacklight/modules/index_maps.scss +68 -0
  46. data/app/assets/stylesheets/geoblacklight/modules/item.scss +16 -0
  47. data/app/assets/stylesheets/geoblacklight/modules/modal.scss +6 -0
  48. data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +4 -0
  49. data/app/components/geoblacklight/icon_facet_item_component.rb +33 -0
  50. data/app/helpers/geoblacklight_helper.rb +6 -45
  51. data/app/models/concerns/geoblacklight/bbox_filter_field.rb +45 -0
  52. data/app/models/concerns/geoblacklight/bbox_filter_query.rb +50 -0
  53. data/app/models/concerns/geoblacklight/solr_document.rb +1 -1
  54. data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +26 -0
  55. data/app/presenters/geoblacklight/bbox_item_presenter.rb +9 -0
  56. data/app/views/catalog/_downloads_collapse.html.erb +27 -0
  57. data/app/views/catalog/_header_icons.html.erb +2 -2
  58. data/app/views/catalog/_index_split_default.html.erb +2 -2
  59. data/app/views/catalog/_show_default_viewer_container.html.erb +17 -0
  60. data/app/views/catalog/_show_downloads.html.erb +10 -21
  61. data/app/views/catalog/_show_sidebar.html.erb +3 -0
  62. data/app/views/catalog/_show_web_services.html.erb +11 -0
  63. data/app/views/catalog/_web_services.html.erb +3 -2
  64. data/app/views/catalog/web_services.html.erb +1 -1
  65. data/app/views/relation/_relations.html.erb +1 -1
  66. data/app/views/relation/index.html.erb +1 -1
  67. data/config/locales/geoblacklight.en.yml +4 -1
  68. data/geoblacklight.gemspec +6 -6
  69. data/lib/generators/geoblacklight/install_generator.rb +1 -1
  70. data/lib/generators/geoblacklight/templates/assets/_customizations.scss +5 -4
  71. data/lib/generators/geoblacklight/templates/assets/application.scss +0 -3
  72. data/lib/generators/geoblacklight/templates/catalog_controller.rb +74 -56
  73. data/lib/generators/geoblacklight/templates/settings.gbl_v1.yml +5 -5
  74. data/lib/generators/geoblacklight/templates/settings.yml +36 -23
  75. data/lib/geoblacklight/bounding_box.rb +4 -0
  76. data/lib/geoblacklight/constants.rb +3 -0
  77. data/lib/geoblacklight/engine.rb +3 -2
  78. data/lib/geoblacklight/faraday_middleware/follow_redirects.rb +176 -0
  79. data/lib/geoblacklight/item_viewer.rb +13 -1
  80. data/lib/geoblacklight/metadata/base.rb +2 -1
  81. data/lib/geoblacklight/version.rb +1 -1
  82. data/lib/geoblacklight/view_helper_override.rb +2 -28
  83. data/lib/geoblacklight.rb +0 -10
  84. data/lib/tasks/geoblacklight.rake +1 -1
  85. data/schema/geoblacklight-schema-aardvark.json +3 -23
  86. data/solr/conf/schema.xml +37 -43
  87. data/solr/conf/solrconfig.xml +17 -17
  88. data/spec/components/geoblacklight/icon_facet_item_component_spec.rb +17 -0
  89. data/spec/controllers/catalog_controller_spec.rb +1 -1
  90. data/spec/features/download_layer_spec.rb +31 -14
  91. data/spec/features/esri_viewer_spec.rb +5 -1
  92. data/spec/features/full_screen_controll_spec.rb +15 -0
  93. data/spec/features/home_page_spec.rb +2 -2
  94. data/spec/features/index_map_spec.rb +2 -2
  95. data/spec/features/missing_metadata_spec.rb +1 -1
  96. data/spec/features/multiple_downloads_spec.rb +2 -1
  97. data/spec/features/relations_spec.rb +1 -1
  98. data/spec/features/saved_searches_spec.rb +1 -1
  99. data/spec/features/search_results_complex_geometry_spec.rb +24 -0
  100. data/spec/features/search_results_icons_spec.rb +16 -0
  101. data/spec/features/search_results_map_spec.rb +2 -2
  102. data/spec/features/search_spec.rb +22 -0
  103. data/spec/features/show_page_download_spec.rb +29 -0
  104. data/spec/features/show_page_metadata_spec.rb +2 -2
  105. data/spec/features/split_view.html.erb_spec.rb +12 -1
  106. data/spec/features/tilejson_spec.rb +22 -0
  107. data/spec/features/tms_spec.rb +2 -2
  108. data/spec/features/web_services_modal_spec.rb +35 -2
  109. data/spec/features/wmts_spec.rb +34 -0
  110. data/spec/features/xyz_spec.rb +10 -0
  111. data/spec/fixtures/manifests/tilejson.json +21 -0
  112. data/spec/fixtures/manifests/wmts-multiple.xml +813 -0
  113. data/spec/fixtures/manifests/wmts-single.xml +126 -0
  114. data/spec/fixtures/solr_documents/README.md +46 -43
  115. data/spec/fixtures/solr_documents/actual-papermap1.json +2 -1
  116. data/spec/fixtures/solr_documents/actual-point1.json +2 -1
  117. data/spec/fixtures/solr_documents/actual-polygon1.json +2 -1
  118. data/spec/fixtures/solr_documents/actual-raster1.json +3 -2
  119. data/spec/fixtures/solr_documents/baruch_ancestor1.json +2 -1
  120. data/spec/fixtures/solr_documents/baruch_ancestor2.json +2 -1
  121. data/spec/fixtures/solr_documents/baruch_documentation_download.json +1 -1
  122. data/spec/fixtures/solr_documents/bbox-spans-180.json +2 -1
  123. data/spec/fixtures/solr_documents/cornell_html_metadata.json +4 -3
  124. data/spec/fixtures/solr_documents/esri-dynamic-layer-all-layers.json +3 -2
  125. data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +3 -2
  126. data/spec/fixtures/solr_documents/esri-feature-layer.json +2 -1
  127. data/spec/fixtures/solr_documents/esri-image-map-layer.json +3 -2
  128. data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +2 -1
  129. data/spec/fixtures/solr_documents/esri-wms-layer.json +2 -1
  130. data/spec/fixtures/solr_documents/harvard_raster.json +3 -2
  131. data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +3 -2
  132. data/spec/fixtures/solr_documents/index-map-polygon-no-downloadurl.json +2 -1
  133. data/spec/fixtures/solr_documents/index-map-polygon.json +2 -1
  134. data/spec/fixtures/solr_documents/index-map-stanford.json +2 -1
  135. data/spec/fixtures/solr_documents/index_map_point.json +3 -2
  136. data/spec/fixtures/solr_documents/metadata_no_provider.json +2 -1
  137. data/spec/fixtures/solr_documents/multiple-downloads.json +3 -2
  138. data/spec/fixtures/solr_documents/no_spatial.json +1 -4
  139. data/spec/fixtures/solr_documents/oembed.json +2 -1
  140. data/spec/fixtures/solr_documents/princeton-child1.json +3 -2
  141. data/spec/fixtures/solr_documents/princeton-child2.json +3 -2
  142. data/spec/fixtures/solr_documents/princeton-child3.json +2 -1
  143. data/spec/fixtures/solr_documents/princeton-child4.json +3 -2
  144. data/spec/fixtures/solr_documents/princeton-parent.json +5 -3
  145. data/spec/fixtures/solr_documents/public_direct_download.json +2 -1
  146. data/spec/fixtures/solr_documents/public_iiif_princeton.json +3 -2
  147. data/spec/fixtures/solr_documents/public_polygon_mit.json +2 -1
  148. data/spec/fixtures/solr_documents/restricted-line.json +2 -1
  149. data/spec/fixtures/solr_documents/tilejson.json +48 -0
  150. data/spec/fixtures/solr_documents/tms.json +15 -18
  151. data/spec/fixtures/solr_documents/umn_metro_result1.json +5 -3
  152. data/spec/fixtures/solr_documents/umn_state_result1.json +3 -2
  153. data/spec/fixtures/solr_documents/umn_state_result2.json +3 -5
  154. data/spec/fixtures/solr_documents/uva_slug_colon.json +2 -1
  155. data/spec/fixtures/solr_documents/wmts-multiple.json +41 -0
  156. data/spec/fixtures/solr_documents/wmts-single-layer.json +48 -0
  157. data/spec/fixtures/solr_documents/xyz.json +46 -0
  158. data/spec/helpers/geoblacklight_helper_spec.rb +12 -35
  159. data/spec/lib/geoblacklight/document_presenter_spec.rb +3 -3
  160. data/spec/lib/geoblacklight/download/geojson_download_spec.rb +1 -1
  161. data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +1 -1
  162. data/spec/lib/geoblacklight/download/kmz_download_spec.rb +1 -1
  163. data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +1 -1
  164. data/spec/lib/geoblacklight/download_spec.rb +2 -2
  165. data/spec/lib/geoblacklight/metadata/base_spec.rb +19 -1
  166. data/spec/lib/geoblacklight/references_spec.rb +1 -1
  167. data/spec/lib/geoblacklight/relation/relation_response_spec.rb +5 -0
  168. data/spec/lib/geoblacklight/view_helper_override_spec.rb +0 -10
  169. data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +77 -0
  170. data/spec/models/concerns/geoblacklight/bbox_filter_query_spec.rb +105 -0
  171. data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +2 -1
  172. data/spec/models/concerns/geoblacklight/suppressed_records_search_behavior_spec.rb +31 -0
  173. data/spec/presenters/geoblacklight/bbox_item_presenter_spec.rb +36 -0
  174. data/spec/spec_helper.rb +6 -1
  175. data/spec/test_app_templates/Gemfile.extra +1 -0
  176. data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -4
  177. data/spec/views/catalog/_show_downloads.html.erb_spec.rb +5 -5
  178. data/template.rb +2 -4
  179. data/vendor/assets/images/fullscreen.png +0 -0
  180. data/vendor/assets/images/fullscreen@2x.png +0 -0
  181. data/vendor/assets/javascripts/Leaflet.fullscreen.js +152 -0
  182. data/vendor/assets/javascripts/esri-leaflet.js +10 -3
  183. data/vendor/assets/javascripts/esri-leaflet.js.map +1 -1
  184. data/vendor/assets/javascripts/leaflet-iiif.js +39 -18
  185. data/vendor/assets/javascripts/leaflet-src.js.erb +14062 -0
  186. data/vendor/assets/javascripts/leaflet-src.js.map +1 -1
  187. data/vendor/assets/stylesheets/leaflet.css +640 -634
  188. data/vendor/assets/stylesheets/leaflet.fullscreen.css +40 -0
  189. metadata +91 -46
  190. data/app/models/concerns/geoblacklight/spatial_search_behavior.rb +0 -71
  191. data/app/views/catalog/_download_generated_link.html.erb +0 -4
  192. data/app/views/catalog/_download_link.html.erb +0 -3
  193. data/app/views/catalog/_downloads_generated.html.erb +0 -6
  194. data/app/views/catalog/_downloads_primary.html.erb +0 -21
  195. data/app/views/catalog/_downloads_secondary.html.erb +0 -39
  196. data/app/views/catalog/_icon_facet.html.erb +0 -16
  197. data/bin/coverage.rb +0 -36
  198. data/lib/generators/geoblacklight/templates/Procfile +0 -3
  199. data/lib/generators/geoblacklight/templates/package.json +0 -14
  200. data/lib/generators/geoblacklight/templates/webpacker.yml +0 -67
  201. data/lib/generators/geoblacklight/webpacker_generator.rb +0 -36
  202. data/lib/geoblacklight/catalog_helper_override.rb +0 -14
  203. data/spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb +0 -97
  204. data/vendor/assets/javascripts/leaflet.js.erb +0 -13922
  205. data/vendor/assets/stylesheets/leaflet-label.css +0 -54
@@ -5,17 +5,6 @@ describe GeoblacklightHelper, type: :helper do
5
5
  include BlacklightHelper
6
6
  include ActionView::Helpers::UrlHelper
7
7
  include ActionView::Helpers::TranslationHelper
8
- describe '#render_facet_links' do
9
- let(:subject_field) { Settings.FIELDS.SUBJECT }
10
- it 'contains unique links' do
11
- expect(self).to receive(:search_catalog_path).exactly(3).times.and_return("http://example.com/catalog?f[#{subject_field}][]=category")
12
- html = Capybara.string(render_facet_links(subject_field, %w[Test Test Earth Science]))
13
- expect(html).to have_css 'a', count: 3
14
- expect(html).to have_css 'a', text: 'Test', count: 1
15
- expect(html).to have_css 'a', text: 'Earth', count: 1
16
- expect(html).to have_css 'a', text: 'Science', count: 1
17
- end
18
- end
19
8
 
20
9
  describe '#geoblacklight_icon' do
21
10
  it 'supports in use cases' do
@@ -59,8 +48,7 @@ describe GeoblacklightHelper, type: :helper do
59
48
  let(:url) { 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip' }
60
49
 
61
50
  it 'generates a link to download the original file' do
62
- puts download_link_file(label, id, url)
63
- expect(download_link_file(label, id, url)).to eq '<a contentUrl="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip" class="btn btn-default download download-original" data-download="trigger" data-download-type="direct" data-download-id="test-id" href="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip">Test Link Text</a>'
51
+ expect(download_link_file(label, id, url)).to eq '<a contentUrl="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip" data-download="trigger" data-download-type="direct" data-download-id="test-id" href="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip">Test Link Text</a>'
64
52
  end
65
53
  end
66
54
 
@@ -74,7 +62,7 @@ describe GeoblacklightHelper, type: :helper do
74
62
  end
75
63
 
76
64
  it 'generates a link to the HGL route' do
77
- expect(download_link_hgl(text, document)).to eq '<a class="btn btn-default download download-original" data-blacklight-modal="trigger" data-download="trigger" data-download-type="harvard-hgl" data-download-id="test-id" href="/download/hgl/test-id">Test Link Text</a>'
65
+ expect(download_link_hgl(text, document)).to eq '<a data-blacklight-modal="trigger" data-download="trigger" data-download-type="harvard-hgl" data-download-id="test-id" href="/download/hgl/test-id">Test Link Text</a>'
78
66
  end
79
67
  end
80
68
 
@@ -95,7 +83,7 @@ describe GeoblacklightHelper, type: :helper do
95
83
 
96
84
  it 'generates a link to download the JPG file from the IIIF server' do
97
85
  assign(:document, document)
98
- expect(helper.download_link_iiif).to eq '<a contentUrl="https://example.edu/image/full/full/0/default.jpg" class="btn btn-default download download-generated" data-download="trigger" href="https://example.edu/image/full/full/0/default.jpg">Original JPG</a>'
86
+ expect(helper.download_link_iiif).to eq '<a contentUrl="https://example.edu/image/full/full/0/default.jpg" data-download="trigger" href="https://example.edu/image/full/full/0/default.jpg">Original JPG</a>'
99
87
  end
100
88
  end
101
89
 
@@ -109,7 +97,10 @@ describe GeoblacklightHelper, type: :helper do
109
97
  end
110
98
 
111
99
  it 'generates a link to download the JPG file from the IIIF server' do
112
- expect(download_link_generated(download_type, document)).to eq '<a class="btn btn-default download download-generated" data-download-path="/download/test-id?type=SHAPEFILE" data-download="trigger" data-download-type="SHAPEFILE" data-download-id="test-id" href="">Export</a>'
100
+ # Stub I18n to ensure the link can be customized via `export_` labels.
101
+ allow(helper).to receive(:t).and_call_original
102
+ allow(helper).to receive(:t).with('geoblacklight.download.export_shapefile_link').and_return('Shapefile Export Customization')
103
+ expect(helper.download_link_generated(download_type, document)).to eq '<a data-download-path="/download/test-id?type=SHAPEFILE" data-download="trigger" data-download-type="SHAPEFILE" data-download-id="test-id" href="">Export Shapefile Export Customization</a>'
113
104
  end
114
105
  end
115
106
 
@@ -149,8 +140,8 @@ describe GeoblacklightHelper, type: :helper do
149
140
  let(:document_attributes) do
150
141
  {
151
142
  value: 'This is a really long string that should get truncated when it gets rendered'\
152
- 'in the index view to give a brief description of the contents of a particular document'\
153
- 'indexed into Solr'
143
+ 'in the index view to give a brief description of the contents of a particular document'\
144
+ 'indexed into Solr'
154
145
  }
155
146
  end
156
147
  it 'truncates longer strings to 150 characters' do
@@ -164,8 +155,8 @@ describe GeoblacklightHelper, type: :helper do
164
155
  let(:document_attributes) do
165
156
  {
166
157
  value: ['This is a really long string that should get truncated when it gets rendered'\
167
- 'in the index view to give a brief description of the contents of a particular document'\
168
- 'indexed into Solr']
158
+ 'in the index view to give a brief description of the contents of a particular document'\
159
+ 'indexed into Solr']
169
160
  }
170
161
  end
171
162
  it 'truncates longer strings to 150 characters' do
@@ -190,20 +181,6 @@ describe GeoblacklightHelper, type: :helper do
190
181
  end
191
182
  end
192
183
 
193
- context 'when CartoHelper methods are within scope' do
194
- include CartoHelper
195
-
196
- before do
197
- allow(helper).to receive(:application_name).and_return('GeoBlacklight')
198
- end
199
-
200
- describe '#carto_link' do
201
- it 'aliases CartoHelper#carto_link' do
202
- expect(helper.carto_link('http://demo.org/wfs/layer.json')).to eq(helper.carto_link('http://demo.org/wfs/layer.json'))
203
- end
204
- end
205
- end
206
-
207
184
  describe '#render_web_services' do
208
185
  let(:reference) { instance_double(Geoblacklight::Reference, type: 'wms') }
209
186
  it 'with a reference to a defined partial' do
@@ -227,7 +204,7 @@ describe GeoblacklightHelper, type: :helper do
227
204
 
228
205
  describe '#leaflet_options' do
229
206
  it 'returns a hash of options for leaflet' do
230
- expect(leaflet_options[:VIEWERS][:WMS][:CONTROLS]).to eq(['Opacity'])
207
+ expect(leaflet_options[:VIEWERS][:WMS][:CONTROLS]).to eq(%w[Opacity Fullscreen])
231
208
  end
232
209
  end
233
210
 
@@ -7,7 +7,7 @@ describe Geoblacklight::DocumentPresenter do
7
7
  let(:request_context) { double(document_index_view_type: 'list') }
8
8
  let(:blacklight_config) do
9
9
  Blacklight::Configuration.new.configure do |config|
10
- config.add_index_field 'layer_id_s'
10
+ config.add_index_field 'gbl_wxsIdentifier_s'
11
11
  config.add_index_field 'index_display'
12
12
  config.add_index_field 'period'
13
13
  config.add_index_field 'multi_display'
@@ -21,7 +21,7 @@ describe Geoblacklight::DocumentPresenter do
21
21
  let(:document) do
22
22
  SolrDocument.new(
23
23
  id: 1,
24
- layer_id_s: 'druid:abc123',
24
+ gbl_wxsIdentifier_s: 'druid:abc123',
25
25
  non_index_field: 'do not render',
26
26
  period: 'Ends with period.',
27
27
  multi_display: %w[blue blah]
@@ -31,7 +31,7 @@ describe Geoblacklight::DocumentPresenter do
31
31
  describe '#index_fields_display' do
32
32
  let(:rendered_index_text) { subject.index_fields_display }
33
33
  let(:multi_valued_text) { document['multi_display'].join(' and ') }
34
- let(:combined_fields) { document['layer_id_s'] + '. ' + document['period'] }
34
+ let(:combined_fields) { document['gbl_wxsIdentifier_s'] + '. ' + document['period'] }
35
35
 
36
36
  context 'with multi-valued field' do
37
37
  it 'each value is separated by comma' do
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Geoblacklight::GeojsonDownload do
5
- let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', solr_wfs_url: 'http://www.example.com/wfs', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.SPATIAL_EXTENT => 'ENVELOPE(-180, 180, 90, -90)') }
5
+ let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', solr_wfs_url: 'http://www.example.com/wfs', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
6
  let(:download) { described_class.new(document) }
7
7
  describe '#initialize' do
8
8
  it 'initializes as a GeojsonDownload object with specific options' do
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Geoblacklight::GeotiffDownload do
5
- let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.SPATIAL_EXTENT => 'ENVELOPE(-180, 180, 90, -90)') }
5
+ let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
6
  let(:download) { described_class.new(document) }
7
7
  describe '#initialize' do
8
8
  it 'initializes as a GeotiffDownload object with specific options' do
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Geoblacklight::KmzDownload do
5
- let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', solr_wfs_url: 'http://www.example.com/wfs', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.SPATIAL_EXTENT => 'ENVELOPE(-180, 180, 90, -90)') }
5
+ let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', solr_wfs_url: 'http://www.example.com/wfs', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
6
  let(:download) { described_class.new(document) }
7
7
  describe '#initialize' do
8
8
  it 'initializes as a KmzDownload object with specific options' do
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Geoblacklight::ShapefileDownload do
5
- let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', solr_wfs_url: 'http://www.example.com/wfs', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.SPATIAL_EXTENT => 'ENVELOPE(-180, 180, 90, -90)') }
5
+ let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', solr_wfs_url: 'http://www.example.com/wfs', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
6
  let(:download) { described_class.new(document) }
7
7
  describe '#initialize' do
8
8
  it 'initializes as a ShapefileDownload object with specific options' do
@@ -171,8 +171,8 @@ describe Geoblacklight::Download do
171
171
 
172
172
  it 'creates a download url with params' do
173
173
  expect(download.url_with_params).to eq 'http://www.example.com/wms/?ser' \
174
- 'vice=wfs&version=2.0.0&request=GetFeature&srsName=EPSG%3A4326&output' \
175
- 'format=SHAPE-ZIP&typeName='
174
+ 'vice=wfs&version=2.0.0&request=GetFeature&srsName=EPSG%3A4326&output' \
175
+ 'format=SHAPE-ZIP&typeName='
176
176
  end
177
177
  end
178
178
  end
@@ -27,6 +27,24 @@ describe Geoblacklight::Metadata::Base do
27
27
  end
28
28
  end
29
29
 
30
+ context "when there's a redirect" do
31
+ before do
32
+ allow(Faraday).to receive(:new).and_call_original
33
+ WebMock.disable_net_connect!(allow_localhost: true, allow: 'chromedriver.storage.googleapis.com')
34
+ stub_request(:get, 'http://purl.stanford.edu/cg357zz0321.mods').to_return(status: 301, headers: { location: 'https://purl.stanford.edu/cg357zz0321.mods' })
35
+ stub_request(:get, 'https://purl.stanford.edu/cg357zz0321.mods').to_return(status: 200, headers: { 'content-type' => 'application/xml' }, body: '<test>data</test>')
36
+ end
37
+
38
+ after do
39
+ WebMock.allow_net_connect!(net_http_connect_on_start: true)
40
+ end
41
+
42
+ it 'follows the redirect' do
43
+ expect(metadata.document).to be_a Nokogiri::XML::Document
44
+ expect(metadata.document.text).to eq 'data'
45
+ end
46
+ end
47
+
30
48
  context 'when attempts to connect to an endpoint URL fail' do
31
49
  subject { metadata.document }
32
50
 
@@ -119,7 +137,7 @@ describe Geoblacklight::Metadata::Base do
119
137
  allow(response).to receive(:body).and_return('<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE metadata SYSTEM "http://www.fgdc.gov/metadata/fgdc-std-001-1998.dtd"><metadata></metadata>')
120
138
  end
121
139
 
122
- it 'retrieves the metadata and transforms it into the HTML' do
140
+ it 'retrieves the metadata and transforms it into the HTML' do
123
141
  allow(geocombine_metadata).to receive(:to_html).and_return(html)
124
142
  allow(connection).to receive(:get).and_return(response)
125
143
 
@@ -135,7 +135,7 @@ describe Geoblacklight::References do
135
135
  let(:settings_klass) { class_double('Settings').as_stubbed_const }
136
136
  before do
137
137
  allow(settings_klass).to receive(:METADATA_SHOWN).and_return %w[iso19139 mods]
138
- allow(settings_klass).to receive(:FIELDS).and_return OpenStruct.new(FORMAT: 'dc_format_s')
138
+ allow(settings_klass).to receive(:FIELDS).and_return OpenStruct.new(FORMAT: 'dct_format_s')
139
139
  end
140
140
  it 'is ordered by the configuration' do
141
141
  expect(complex_shapefile.shown_metadata_refs.first.type.to_s).to eq 'iso19139'
@@ -41,6 +41,8 @@ describe Geoblacklight::Relation::RelationResponse do
41
41
 
42
42
  describe '#query_type' do
43
43
  it 'fails for a bad query type request' do
44
+ # Cache the existing relationship values and add a test value
45
+ relationships = Settings.RELATIONSHIPS_SHOWN
44
46
  Settings.add_source!({
45
47
  RELATIONSHIPS_SHOWN: {
46
48
  BAD: {
@@ -54,6 +56,9 @@ describe Geoblacklight::Relation::RelationResponse do
54
56
  Settings.reload!
55
57
 
56
58
  expect { relation_resp.BAD }.to raise_error(ArgumentError)
59
+
60
+ # Restore relationship values
61
+ Settings.RELATIONSHIPS_SHOWN = relationships
57
62
  end
58
63
  end
59
64
  end
@@ -12,16 +12,6 @@ describe Geoblacklight::ViewHelperOverride do
12
12
  .extend(described_class)
13
13
  end
14
14
 
15
- describe 'spatial_parameters?' do
16
- it 'does not have spatial parameters' do
17
- fake_controller.params = {}
18
- expect(fake_controller.spatial_parameters?).to be_falsey
19
- end
20
- it 'has spatial parameters' do
21
- fake_controller.params = { bbox: '123' }
22
- expect(fake_controller.spatial_parameters?).to be_truthy
23
- end
24
- end
25
15
  describe 'render_search_to_s_bbox' do
26
16
  it 'returns an empty string for no bbox' do
27
17
  fake_controller.params = {}
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Geoblacklight::BboxFilterField do
6
+ let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, blacklight_config, controller) }
7
+
8
+ let(:params) { {} }
9
+ let(:blacklight_config) do
10
+ Blacklight::Configuration.new.configure do |config|
11
+ config.add_facet_field 'bbox', filter_class: described_class
12
+ end
13
+ end
14
+ let(:controller) { double }
15
+
16
+ describe '#add' do
17
+ context 'with a ordinary parameter' do
18
+ it 'adds the parameter to the facets' do
19
+ filter = search_state.filter('bbox')
20
+ new_state = filter.add('140.143709 -65.487905 160.793791 86.107541')
21
+
22
+ expect(new_state.params).to include bbox: '140.143709 -65.487905 160.793791 86.107541'
23
+ end
24
+ end
25
+
26
+ context 'with a bounding box' do
27
+ it 'adds the parameter to the bbox parameter' do
28
+ filter = search_state.filter('bbox')
29
+ new_state = filter.add(Geoblacklight::BoundingBox.from_rectangle('140.143709 -65.487905 160.793791 86.107541'))
30
+
31
+ expect(new_state.params).to include bbox: '140.143709 -65.487905 160.793791 86.107541'
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'with some existing data' do
37
+ let(:params) { { bbox: '140.143709 -65.487905 160.793791 86.107541' } }
38
+
39
+ describe '#add' do
40
+ it 'replaces the existing range' do
41
+ filter = search_state.filter('bbox')
42
+ new_state = filter.add(Geoblacklight::BoundingBox.from_rectangle('100.143709 -70.487905 100.793791 96.107541'))
43
+
44
+ expect(new_state.params).to include bbox: '100.143709 -70.487905 100.793791 96.107541'
45
+ end
46
+ end
47
+
48
+ describe '#remove' do
49
+ it 'removes the existing bbox' do
50
+ filter = search_state.filter('bbox')
51
+ new_state = filter.remove(Geoblacklight::BoundingBox.from_rectangle('140.143709 -65.487905 160.793791 86.107541'))
52
+
53
+ expect(new_state.params[:bbox]).to be_nil
54
+ end
55
+ end
56
+
57
+ describe '#values' do
58
+ let(:params) { { bbox: '140.143709 -65.487905 160.793791 86.107541' } }
59
+
60
+ it 'converts the parameters to a Geoblacklight::BoundingBox' do
61
+ filter = search_state.filter('bbox')
62
+
63
+ expect(filter.values.first).to be_a(Geoblacklight::BoundingBox).and(have_attributes(to_param: '140.143709 -65.487905 160.793791 86.107541'))
64
+ end
65
+ end
66
+ end
67
+
68
+ context 'with a malformed bbox' do
69
+ let(:params) { { bbox: 'totally-not-a-bbox' } }
70
+
71
+ it 'excludes it from the values' do
72
+ filter = search_state.filter('bbox')
73
+
74
+ expect(filter.values).to be_empty
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Geoblacklight::BboxFilterQuery do
6
+ # Subject
7
+ subject(:bbox_filter_query) { described_class.new(filter, solr_params) }
8
+
9
+ let(:solr_params) { {} }
10
+
11
+ # Search State
12
+ let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, {}) }
13
+
14
+ let(:params) do
15
+ { bbox: '-180 -80 120 80' }
16
+ end
17
+
18
+ let(:facet_config) do
19
+ Blacklight::Configuration::FacetField.new(
20
+ key: 'bbox',
21
+ filter_class: Geoblacklight::BboxFilterField
22
+ )
23
+ end
24
+
25
+ # Filter
26
+ let(:filter) { Geoblacklight::BboxFilterField.new(facet_config, search_state) }
27
+
28
+ describe '#initialize' do
29
+ it 'initializes as a BboxFilterQuery object' do
30
+ expect(bbox_filter_query).to be_a described_class
31
+ end
32
+ end
33
+
34
+ describe '#envelope_bounds' do
35
+ it 'returns an BoundingBox envelope' do
36
+ expect(bbox_filter_query.envelope_bounds).to eq('ENVELOPE(-180, 120, 80, -80)')
37
+ end
38
+ end
39
+
40
+ describe '#boost' do
41
+ context 'without an explicit boost' do
42
+ before do
43
+ facet_config.within_boost = nil
44
+ end
45
+
46
+ it 'returns an default boost value' do
47
+ expect(bbox_filter_query.boost).to eq('^10')
48
+ end
49
+ end
50
+
51
+ context 'with an explicit boost' do
52
+ before do
53
+ facet_config.within_boost = 99
54
+ end
55
+
56
+ it 'applies boost based on configured Settings.BBOX_WITHIN_BOOST' do
57
+ expect(bbox_filter_query.boost).to eq('^99')
58
+ end
59
+ end
60
+ end
61
+
62
+ describe '#relevancy_boost' do
63
+ it 'returns a relevancy_boost' do
64
+ expect(bbox_filter_query.relevancy_boost[:bq].to_s).to include('IsWithin')
65
+ end
66
+
67
+ context 'with overlap boost' do
68
+ before do
69
+ facet_config.overlap_boost = 2
70
+ end
71
+
72
+ it 'applies overlapRatio when Settings.OVERLAP_RATIO_BOOST is configured' do
73
+ expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include('$overlap^2')
74
+ end
75
+ end
76
+
77
+ context 'without an overlap boost' do
78
+ before do
79
+ facet_config.overlap_boost = nil
80
+ end
81
+
82
+ it 'does not apply overlapRatio when Settings.OVERLAP_RATIO_BOOST not configured' do
83
+ expect(bbox_filter_query.relevancy_boost).not_to have_key(:overlap)
84
+ end
85
+ end
86
+
87
+ context 'when local boost parameter is present' do
88
+ before do
89
+ solr_params[:bf] = ['local_boost^5']
90
+ facet_config.overlap_boost = 2
91
+ end
92
+
93
+ it 'appends overlap and includes the local boost' do
94
+ expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include('$overlap^2')
95
+ expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include('local_boost^5')
96
+ end
97
+ end
98
+ end
99
+
100
+ describe '#intersects_filter' do
101
+ it 'returns an Intersects query' do
102
+ expect(bbox_filter_query.intersects_filter).to include('Intersects')
103
+ end
104
+ end
105
+ end
@@ -2,7 +2,8 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Geoblacklight::SolrDocument::Inspection do
5
- let(:subject) { SolrDocument.new }
5
+ subject { SolrDocument.new }
6
+
6
7
  describe '#inspectable?' do
7
8
  it 'returns true for wms viewer protocol' do
8
9
  expect(subject).to receive(:viewer_protocol).and_return('wms')
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ describe Geoblacklight::SuppressedRecordsSearchBehavior do
5
+ subject(:searcher) { search_builder.with(user_params) }
6
+
7
+ let(:user_params) { {} }
8
+ let(:solr_params) { { q: 'water' } }
9
+ let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
10
+ let(:context) { CatalogController.new }
11
+ let(:search_builder_class) do
12
+ Class.new(Blacklight::SearchBuilder).tap do |klass|
13
+ include Blacklight::Solr::SearchBuilderBehavior
14
+ klass.include(described_class)
15
+ end
16
+ end
17
+ let(:search_builder) { search_builder_class.new(context) }
18
+
19
+ describe '#hide_suppressed_records' do
20
+ it 'hides/filters suppressed records' do
21
+ expect(searcher.hide_suppressed_records(solr_params)).to include('-gbl_suppressed_b: true')
22
+ end
23
+ end
24
+
25
+ context 'when document action call like CatalogController#web_services' do
26
+ it 'does not hide/filter suppressed records' do
27
+ solr_params[:q] = "{!lucene}#{Settings.FIELDS.ID}:"
28
+ expect(searcher.hide_suppressed_records(solr_params)).to be_nil
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Geoblacklight::BboxItemPresenter, type: :presenter do
6
+ subject(:presenter) do
7
+ described_class.new(facet_item, facet_config, view_context, facet_field, search_state)
8
+ end
9
+
10
+ let(:facet_item) { instance_double(Blacklight::Solr::Response::Facets::FacetItem) }
11
+ let(:filter_field) { instance_double(Blacklight::SearchState::FilterField, include?: true) }
12
+ let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'key') }
13
+ let(:facet_field) { instance_double(Blacklight::Solr::Response::Facets::FacetField) }
14
+ let(:view_context) { controller.view_context }
15
+ let(:search_state) { instance_double(Blacklight::SearchState, filter: filter_field) }
16
+ let(:controller) { CatalogController.new }
17
+
18
+ describe '#label' do
19
+ context 'with a single value' do
20
+ let(:facet_item) { 'blah' }
21
+
22
+ it 'uses the normal logic for item values' do
23
+ expect(presenter.label).to eq 'blah'
24
+ end
25
+ end
26
+
27
+ context 'with a bbox' do
28
+ let(:facet_item) { Geoblacklight::BoundingBox.new(-160, -80, 120, 70) }
29
+
30
+ it 'translates the bbox into some nice, human-readable html' do
31
+ expect(Capybara.string(presenter.label))
32
+ .to have_text('-160 -80 120 70')
33
+ end
34
+ end
35
+ end
36
+ end
data/spec/spec_helper.rb CHANGED
@@ -16,6 +16,7 @@ SimpleCov.start 'rails' do
16
16
  add_filter 'lib/tasks/geoblacklight.rake'
17
17
  add_filter '/spec'
18
18
  add_filter '.internal_test_app/'
19
+ minimum_coverage 100
19
20
  end
20
21
 
21
22
  require 'factory_bot'
@@ -30,6 +31,10 @@ require 'capybara/rspec'
30
31
  require 'selenium-webdriver'
31
32
  require 'webdrivers'
32
33
 
34
+ # Setup webmock for specific tests
35
+ require 'webmock/rspec'
36
+ WebMock.allow_net_connect!(net_http_connect_on_start: true)
37
+
33
38
  Capybara.register_driver(:headless_chrome) do |app|
34
39
  Capybara::Selenium::Driver.load_selenium
35
40
  browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
@@ -43,7 +48,7 @@ Capybara.register_driver(:headless_chrome) do |app|
43
48
  Capybara::Selenium::Driver.new(app,
44
49
  browser: :chrome,
45
50
  http_client: http_client,
46
- options: browser_options)
51
+ capabilities: [browser_options])
47
52
  end
48
53
 
49
54
  Capybara.javascript_driver = :headless_chrome
@@ -1,2 +1,3 @@
1
1
  gem 'sprockets', '< 4'
2
2
  gem 'view_component', '!= 2.26.0'
3
+ gem 'faraday', ENV["FARADAY_VERSION"].to_s != "" ? ENV["FARADAY_VERSION"] : '>= 1.0'
@@ -20,6 +20,10 @@ class TestAppGenerator < Rails::Generators::Base
20
20
  end
21
21
  end
22
22
 
23
+ def install_webpacker
24
+ run 'bundle exec rails webpacker:install'
25
+ end
26
+
23
27
  def run_blacklight_generator
24
28
  say_status('warning', 'GENERATING BL', :yellow)
25
29
 
@@ -30,10 +34,6 @@ class TestAppGenerator < Rails::Generators::Base
30
34
  generate 'geoblacklight:install', '-f'
31
35
  end
32
36
 
33
- def integrate_webpacker
34
- generate 'geoblacklight:webpacker', '-f'
35
- end
36
-
37
37
  def fixtures
38
38
  FileUtils.mkdir_p 'spec/fixtures/solr_documents'
39
39
  directory 'solr_documents', 'spec/fixtures/solr_documents'
@@ -13,18 +13,18 @@ describe 'catalog/_show_downloads.html.erb', type: :view do
13
13
  allow(document).to receive(:iiif_download).and_return({})
14
14
  allow(document).to receive(:download_types).and_return(shapefile: {})
15
15
  end
16
- it 'renders the button group with primary and generated partials' do
16
+
17
+ it 'renders the downloads collapse partial' do
17
18
  expect(view).to receive(:document_downloadable?).and_return(true)
18
19
 
19
- stub_template 'catalog/_downloads_primary.html.erb' => 'stubbed_primary_downloads'
20
- stub_template 'catalog/_downloads_generated.html.erb' => 'stubbed_generated_downloads'
20
+ stub_template 'catalog/_downloads_collapse.html.erb' => 'stubbed_downloads_collapse'
21
21
 
22
22
  render
23
23
 
24
- expect(rendered).to have_content 'stubbed_primary_downloads'
25
- expect(rendered).to have_content 'stubbed_generated_downloads'
24
+ expect(rendered).to have_content 'stubbed_downloads_collapse'
26
25
  end
27
26
  end
27
+
28
28
  context 'document is not downloadable' do
29
29
  let(:document) { instance_double(SolrDocument, restricted?: true, same_institution?: true) }
30
30
  before do
data/template.rb CHANGED
@@ -1,13 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  gem 'blacklight', '~> 7.0'
3
- gem 'geoblacklight', '~> 3.0'
4
- gem 'webpacker' unless Rails.version.to_s.start_with? '6.1.'
3
+ gem 'geoblacklight', '~> 4.0'
5
4
  gem 'sprockets', '< 4.0' # Use sprockets less than 4.0, let webpacker users set this up themselves
6
5
 
7
6
  # Hack for https://github.com/rails/rails/issues/35153
8
7
  # Adapted from https://github.com/projectblacklight/blacklight/pull/2065
9
8
  gemfile = File.expand_path('Gemfile')
10
- IO.write(gemfile, File.open(gemfile) do |f|
9
+ File.write(gemfile, File.open(gemfile) do |f|
11
10
  text = f.read
12
11
  text.gsub(/^gem 'sqlite3'$/, 'gem "sqlite3", "~> 1.3.6"')
13
12
  end)
@@ -16,6 +15,5 @@ run 'bundle install'
16
15
 
17
16
  generate 'blacklight:install', '--devise'
18
17
  generate 'geoblacklight:install', '-f'
19
- generate 'geoblacklight:webpacker', '-f'
20
18
 
21
19
  rake 'db:migrate'
Binary file