geoblacklight 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +21 -6
  3. data/.solr_wrapper +1 -0
  4. data/.standard.yml +1 -0
  5. data/Gemfile +13 -11
  6. data/README.md +1 -1
  7. data/Rakefile +42 -50
  8. data/app/assets/images/blacklight/american-geographical-society-library-uwm-libraries.svg +26 -0
  9. data/app/assets/images/blacklight/arizona.svg +4 -0
  10. data/app/assets/images/blacklight/circle-info-solid.svg +1 -0
  11. data/app/assets/images/blacklight/fire-solid.svg +1 -0
  12. data/app/assets/images/blacklight/lightbulb-solid.svg +1 -0
  13. data/app/assets/images/blacklight/nebraska.svg +4 -0
  14. data/app/assets/images/blacklight/rutgers.svg +5 -0
  15. data/app/assets/images/blacklight/triangle-exclamation-solid.svg +1 -0
  16. data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +8 -0
  17. data/app/components/geoblacklight/display_note_component.html.erb +1 -0
  18. data/app/components/geoblacklight/display_note_component.rb +47 -0
  19. data/app/components/geoblacklight/icon_facet_item_component.rb +2 -2
  20. data/app/controllers/download_controller.rb +36 -37
  21. data/app/controllers/relation_controller.rb +1 -0
  22. data/app/controllers/wms_controller.rb +1 -0
  23. data/app/helpers/arcgis_helper.rb +2 -1
  24. data/app/helpers/blacklight_helper.rb +2 -1
  25. data/app/helpers/carto_helper.rb +3 -2
  26. data/app/helpers/geoblacklight/geoblacklight_helper_behavior.rb +2 -1
  27. data/app/helpers/geoblacklight_helper.rb +44 -36
  28. data/app/models/concerns/geoblacklight/bbox_filter_query.rb +1 -1
  29. data/app/models/concerns/geoblacklight/solr_document/arcgis.rb +1 -0
  30. data/app/models/concerns/geoblacklight/solr_document/carto.rb +1 -0
  31. data/app/models/concerns/geoblacklight/solr_document/citation.rb +3 -2
  32. data/app/models/concerns/geoblacklight/solr_document/finder.rb +1 -0
  33. data/app/models/concerns/geoblacklight/solr_document/inspection.rb +1 -0
  34. data/app/models/concerns/geoblacklight/solr_document.rb +17 -9
  35. data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +2 -1
  36. data/app/presenters/geoblacklight/document_presenter.rb +3 -2
  37. data/app/views/catalog/_show_default_display_note.html.erb +7 -0
  38. data/app/views/catalog/_show_sidebar.html.erb +1 -0
  39. data/app/views/catalog/_show_sidebar_static_map.html.erb +10 -0
  40. data/app/views/relation/index.json.jbuilder +1 -1
  41. data/config/initializers/new_gbl_settings_defaults_4.1.yml +104 -0
  42. data/config/initializers/rails_config.rb +5 -1
  43. data/config/locales/geoblacklight.en.yml +18 -10
  44. data/geoblacklight.gemspec +36 -40
  45. data/lib/generators/geoblacklight/assets_generator.rb +15 -15
  46. data/lib/generators/geoblacklight/install_generator.rb +24 -23
  47. data/lib/generators/geoblacklight/templates/catalog_controller.rb +66 -71
  48. data/lib/generators/geoblacklight/templates/settings.yml +74 -22
  49. data/lib/geoblacklight/bounding_box.rb +1 -0
  50. data/lib/geoblacklight/constants.rb +26 -25
  51. data/lib/geoblacklight/download/geojson_download.rb +10 -9
  52. data/lib/geoblacklight/download/geotiff_download.rb +6 -5
  53. data/lib/geoblacklight/download/hgl_download.rb +4 -3
  54. data/lib/geoblacklight/download/kmz_download.rb +11 -10
  55. data/lib/geoblacklight/download/shapefile_download.rb +10 -9
  56. data/lib/geoblacklight/download.rb +12 -11
  57. data/lib/geoblacklight/engine.rb +10 -9
  58. data/lib/geoblacklight/exceptions.rb +3 -0
  59. data/lib/geoblacklight/faraday_middleware/follow_redirects.rb +12 -11
  60. data/lib/geoblacklight/geometry.rb +6 -5
  61. data/lib/geoblacklight/item_viewer.rb +4 -3
  62. data/lib/geoblacklight/metadata/base.rb +4 -3
  63. data/lib/geoblacklight/metadata/fgdc.rb +1 -0
  64. data/lib/geoblacklight/metadata/html.rb +5 -4
  65. data/lib/geoblacklight/metadata/iso19139.rb +1 -0
  66. data/lib/geoblacklight/metadata.rb +1 -0
  67. data/lib/geoblacklight/metadata_transformer/base.rb +5 -4
  68. data/lib/geoblacklight/metadata_transformer/fgdc.rb +1 -0
  69. data/lib/geoblacklight/metadata_transformer/iso19139.rb +1 -0
  70. data/lib/geoblacklight/metadata_transformer.rb +6 -2
  71. data/lib/geoblacklight/reference.rb +3 -2
  72. data/lib/geoblacklight/references.rb +11 -6
  73. data/lib/geoblacklight/relation/ancestors.rb +4 -3
  74. data/lib/geoblacklight/relation/descendants.rb +4 -3
  75. data/lib/geoblacklight/relation/relation_response.rb +3 -2
  76. data/lib/geoblacklight/routes/downloadable.rb +3 -2
  77. data/lib/geoblacklight/routes/exportable.rb +4 -3
  78. data/lib/geoblacklight/routes/wms.rb +2 -1
  79. data/lib/geoblacklight/routes.rb +4 -3
  80. data/lib/geoblacklight/version.rb +2 -1
  81. data/lib/geoblacklight/view_helper_override.rb +3 -2
  82. data/lib/geoblacklight/wms_layer/feature_info_response.rb +5 -4
  83. data/lib/geoblacklight/wms_layer.rb +4 -3
  84. data/lib/geoblacklight.rb +32 -31
  85. data/lib/tasks/geoblacklight.rake +45 -44
  86. data/schema/geoblacklight-schema-aardvark.json +6 -0
  87. data/spec/components/geoblacklight/display_note_component_spec.rb +27 -0
  88. data/spec/components/geoblacklight/homepage_feature_facet_component_spec.rb +11 -10
  89. data/spec/components/geoblacklight/icon_facet_item_component_spec.rb +8 -7
  90. data/spec/config/initializers/rails_config_spec.rb +10 -9
  91. data/spec/controllers/catalog_controller_spec.rb +27 -26
  92. data/spec/controllers/download_controller_spec.rb +50 -49
  93. data/spec/controllers/relation_controller_spec.rb +5 -4
  94. data/spec/controllers/wms_controller_spec.rb +10 -9
  95. data/spec/factories/user.rb +3 -2
  96. data/spec/features/bookmarks_spec.rb +7 -6
  97. data/spec/features/configurable_basemap_spec.rb +12 -11
  98. data/spec/features/data_dictionary_download_spec.rb +11 -10
  99. data/spec/features/download_layer_spec.rb +64 -63
  100. data/spec/features/empty_search_spec.rb +6 -5
  101. data/spec/features/esri_viewer_spec.rb +33 -32
  102. data/spec/features/exports_spec.rb +18 -17
  103. data/spec/features/full_screen_controll_spec.rb +8 -8
  104. data/spec/features/help_text_spec.rb +6 -5
  105. data/spec/features/home_page_spec.rb +30 -29
  106. data/spec/features/iiif_viewer_spec.rb +6 -5
  107. data/spec/features/index_map_spec.rb +17 -16
  108. data/spec/features/layer_inspection_spec.rb +8 -7
  109. data/spec/features/layer_opacity_spec.rb +15 -14
  110. data/spec/features/layer_preview_spec.rb +11 -10
  111. data/spec/features/layer_with_no_references_spec.rb +5 -4
  112. data/spec/features/linkified_attribute_table_spec.rb +8 -7
  113. data/spec/features/metadata_panel_spec.rb +32 -31
  114. data/spec/features/missing_metadata_spec.rb +18 -17
  115. data/spec/features/multiple_downloads_spec.rb +11 -10
  116. data/spec/features/oembed_spec.rb +6 -5
  117. data/spec/features/relations_spec.rb +51 -26
  118. data/spec/features/saved_searches_spec.rb +7 -6
  119. data/spec/features/search_bar_spec.rb +9 -8
  120. data/spec/features/search_results_complex_geometry_spec.rb +12 -11
  121. data/spec/features/search_results_icons_spec.rb +10 -9
  122. data/spec/features/search_results_map_spec.rb +21 -20
  123. data/spec/features/search_results_overlap_ratio_spec.rb +17 -16
  124. data/spec/features/search_spec.rb +19 -18
  125. data/spec/features/show_page_download_spec.rb +15 -14
  126. data/spec/features/show_page_metadata_spec.rb +9 -8
  127. data/spec/features/show_page_sidebar_static_map_spec.rb +21 -0
  128. data/spec/features/sms_spec.rb +12 -11
  129. data/spec/features/split_view.html.erb_spec.rb +56 -55
  130. data/spec/features/suppressed_records_spec.rb +10 -9
  131. data/spec/features/tilejson_spec.rb +9 -8
  132. data/spec/features/tms_spec.rb +6 -5
  133. data/spec/features/web_services_modal_spec.rb +37 -36
  134. data/spec/features/wmts_spec.rb +16 -15
  135. data/spec/features/xyz_spec.rb +6 -5
  136. data/spec/fixtures/solr_documents/actual-papermap1.json +1 -1
  137. data/spec/fixtures/solr_documents/actual-point1.json +1 -1
  138. data/spec/fixtures/solr_documents/actual-polygon1.json +1 -1
  139. data/spec/fixtures/solr_documents/actual-raster1.json +1 -1
  140. data/spec/fixtures/solr_documents/baruch_ancestor1.json +1 -1
  141. data/spec/fixtures/solr_documents/baruch_ancestor2.json +1 -1
  142. data/spec/fixtures/solr_documents/baruch_documentation_download.json +2 -2
  143. data/spec/fixtures/solr_documents/cornell_html_metadata.json +1 -1
  144. data/spec/fixtures/solr_documents/display-note.json +52 -0
  145. data/spec/fixtures/solr_documents/esri-dynamic-layer-all-layers.json +1 -1
  146. data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +1 -1
  147. data/spec/fixtures/solr_documents/esri-feature-layer.json +1 -1
  148. data/spec/fixtures/solr_documents/esri-image-map-layer.json +1 -1
  149. data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +1 -1
  150. data/spec/fixtures/solr_documents/esri-wms-layer.json +1 -1
  151. data/spec/fixtures/solr_documents/harvard_raster.json +1 -1
  152. data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +1 -1
  153. data/spec/fixtures/solr_documents/index-map-polygon-no-downloadurl.json +1 -1
  154. data/spec/fixtures/solr_documents/index-map-polygon.json +1 -1
  155. data/spec/fixtures/solr_documents/index-map-stanford.json +1 -1
  156. data/spec/fixtures/solr_documents/index_map_point.json +1 -1
  157. data/spec/fixtures/solr_documents/princeton-parent.json +1 -1
  158. data/spec/fixtures/solr_documents/public_direct_download.json +1 -1
  159. data/spec/fixtures/solr_documents/public_iiif_princeton.json +1 -1
  160. data/spec/fixtures/solr_documents/restricted-line.json +1 -1
  161. data/spec/fixtures/solr_documents/tilejson.json +2 -2
  162. data/spec/fixtures/solr_documents/umn_metro_result1.json +2 -2
  163. data/spec/fixtures/solr_documents/umn_state_result1.json +1 -1
  164. data/spec/fixtures/solr_documents/umn_state_result2.json +1 -1
  165. data/spec/fixtures/solr_documents/uva_slug_colon.json +1 -1
  166. data/spec/fixtures/solr_documents/wmts-multiple.json +1 -1
  167. data/spec/fixtures/solr_documents/wmts-single-layer.json +6 -6
  168. data/spec/fixtures/solr_documents/xyz.json +3 -3
  169. data/spec/helpers/arcgis_helper_spec.rb +8 -7
  170. data/spec/helpers/carto_helper_spec.rb +6 -5
  171. data/spec/helpers/geoblacklight/geoblacklight_helper_behavior_spec.rb +10 -15
  172. data/spec/helpers/geoblacklight_helper_spec.rb +139 -138
  173. data/spec/lib/geoblacklight/bounding_box_spec.rb +14 -13
  174. data/spec/lib/geoblacklight/document_presenter_spec.rb +26 -25
  175. data/spec/lib/geoblacklight/download/geojson_download_spec.rb +8 -7
  176. data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +8 -7
  177. data/spec/lib/geoblacklight/download/hgl_download_spec.rb +16 -15
  178. data/spec/lib/geoblacklight/download/kmz_download_spec.rb +9 -8
  179. data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +8 -7
  180. data/spec/lib/geoblacklight/download_spec.rb +61 -60
  181. data/spec/lib/geoblacklight/geometry_spec.rb +29 -28
  182. data/spec/lib/geoblacklight/item_viewer_spec.rb +25 -24
  183. data/spec/lib/geoblacklight/metadata/base_spec.rb +44 -43
  184. data/spec/lib/geoblacklight/metadata/html_spec.rb +7 -6
  185. data/spec/lib/geoblacklight/metadata_spec.rb +15 -14
  186. data/spec/lib/geoblacklight/metadata_transformer/base_spec.rb +13 -12
  187. data/spec/lib/geoblacklight/metadata_transformer/fgdc_spec.rb +8 -7
  188. data/spec/lib/geoblacklight/metadata_transformer/iso19139_spec.rb +8 -7
  189. data/spec/lib/geoblacklight/metadata_transformer_spec.rb +15 -14
  190. data/spec/lib/geoblacklight/reference_spec.rb +28 -27
  191. data/spec/lib/geoblacklight/references_spec.rb +89 -76
  192. data/spec/lib/geoblacklight/relation/ancestors_spec.rb +17 -16
  193. data/spec/lib/geoblacklight/relation/descendants_spec.rb +17 -16
  194. data/spec/lib/geoblacklight/relation/relation_response_spec.rb +29 -28
  195. data/spec/lib/geoblacklight/view_helper_override_spec.rb +14 -13
  196. data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +19 -18
  197. data/spec/lib/geoblacklight/wms_layer_spec.rb +31 -30
  198. data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +31 -31
  199. data/spec/models/concerns/geoblacklight/bbox_filter_query_spec.rb +32 -32
  200. data/spec/models/concerns/geoblacklight/solr_document/carto_spec.rb +16 -15
  201. data/spec/models/concerns/geoblacklight/solr_document/citation_spec.rb +7 -6
  202. data/spec/models/concerns/geoblacklight/solr_document/finder_spec.rb +16 -17
  203. data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +7 -6
  204. data/spec/models/concerns/geoblacklight/solr_document_spec.rb +121 -107
  205. data/spec/models/concerns/geoblacklight/suppressed_records_search_behavior_spec.rb +8 -7
  206. data/spec/presenters/geoblacklight/bbox_item_presenter_spec.rb +10 -10
  207. data/spec/routing/catalog_routing_spec.rb +4 -3
  208. data/spec/spec_helper.rb +34 -33
  209. data/spec/support/backport_test_helpers.rb +6 -5
  210. data/spec/support/features/session_helpers.rb +8 -7
  211. data/spec/support/features.rb +2 -1
  212. data/spec/support/fixtures.rb +2 -1
  213. data/spec/tasks/geoblacklight_spec.rb +10 -9
  214. data/spec/test_app_templates/lib/generators/test_app_generator.rb +16 -15
  215. data/spec/views/catalog/_document_split.html.erb_spec.rb +3 -2
  216. data/spec/views/catalog/_index_split.html.erb_spec.rb +3 -2
  217. data/spec/views/catalog/_results_pagination.html.erb_spec.rb +5 -4
  218. data/spec/views/catalog/_show_downloads.html.erb_spec.rb +11 -10
  219. data/spec/views/catalog/_show_tools.html.erb_spec.rb +13 -12
  220. data/template.rb +9 -8
  221. metadata +29 -212
  222. data/.gitmodules +0 -0
  223. data/.rubocop.yml +0 -111
  224. data/.rubocop_todo.yml +0 -437
  225. data/config/initializers/new_gbl_settings_defaults_3_4.yml +0 -6
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  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.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
+ 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
7
  let(:download) { described_class.new(document) }
7
- describe '#initialize' do
8
- it 'initializes as a GeojsonDownload object with specific options' do
8
+ describe "#initialize" do
9
+ it "initializes as a GeojsonDownload object with specific options" do
9
10
  expect(download).to be_an described_class
10
11
  options = download.instance_variable_get(:@options)
11
- expect(options[:content_type]).to eq 'application/json'
12
- expect(options[:request_params][:typeName]).to eq 'stanford-test'
12
+ expect(options[:content_type]).to eq "application/json"
13
+ expect(options[:request_params][:typeName]).to eq "stanford-test"
13
14
  end
14
- it 'merges custom options' do
15
+ it "merges custom options" do
15
16
  download = described_class.new(document, timeout: 33)
16
17
  options = download.instance_variable_get(:@options)
17
18
  expect(options[:timeout]).to eq 33
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  describe Geoblacklight::GeotiffDownload do
5
- let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', Settings.FIELDS.WXS_IDENTIFIER => 'stanford-test', Settings.FIELDS.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
+ let(:document) { SolrDocument.new(Settings.FIELDS.ID => "test", Settings.FIELDS.WXS_IDENTIFIER => "stanford-test", Settings.FIELDS.GEOMETRY => "ENVELOPE(-180, 180, 90, -90)") }
6
7
  let(:download) { described_class.new(document) }
7
- describe '#initialize' do
8
- it 'initializes as a GeotiffDownload object with specific options' do
8
+ describe "#initialize" do
9
+ it "initializes as a GeotiffDownload object with specific options" do
9
10
  expect(download).to be_an described_class
10
11
  options = download.instance_variable_get(:@options)
11
- expect(options[:content_type]).to eq 'image/geotiff'
12
- expect(options[:request_params][:layers]).to eq 'stanford-test'
12
+ expect(options[:content_type]).to eq "image/geotiff"
13
+ expect(options[:request_params][:layers]).to eq "stanford-test"
13
14
  expect(options[:reflect]).to be_truthy
14
15
  end
15
- it 'merges custom options' do
16
+ it "merges custom options" do
16
17
  download = described_class.new(document, timeout: 33)
17
18
  options = download.instance_variable_get(:@options)
18
19
  expect(options[:timeout]).to eq 33
@@ -1,36 +1,37 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  describe Geoblacklight::HglDownload do
5
6
  subject(:download) { described_class.new(document, options) }
6
7
 
7
- let(:document) { SolrDocument.new(Settings.FIELDS.ID => 'test', Settings.FIELDS.WXS_IDENTIFIER => 'cite:harvard-test') }
8
- let(:options) { 'foo@example.com' }
8
+ let(:document) { SolrDocument.new(Settings.FIELDS.ID => "test", Settings.FIELDS.WXS_IDENTIFIER => "cite:harvard-test") }
9
+ let(:options) { "foo@example.com" }
9
10
 
10
- describe '#initialize' do
11
- it 'initializes as an HglDownload object with specific options' do
11
+ describe "#initialize" do
12
+ it "initializes as an HglDownload object with specific options" do
12
13
  expect(download).to be_an described_class
13
14
  options = download.instance_variable_get(:@options)
14
- expect(options[:request_params]['LayerName']).to eq 'harvard-test'
15
- expect(options[:request_params]['UserEmail']).to eq 'foo@example.com'
15
+ expect(options[:request_params]["LayerName"]).to eq "harvard-test"
16
+ expect(options[:request_params]["UserEmail"]).to eq "foo@example.com"
16
17
  end
17
- it 'merges custom options' do
18
- download = described_class.new(document, 'foo@example.com', timeout: 33)
18
+ it "merges custom options" do
19
+ download = described_class.new(document, "foo@example.com", timeout: 33)
19
20
  options = download.instance_variable_get(:@options)
20
21
  expect(options[:timeout]).to eq 33
21
22
  end
22
23
  end
23
24
 
24
- describe '#get' do
25
+ describe "#get" do
25
26
  let(:references_field) { Settings.FIELDS.REFERENCES }
26
27
  let(:references_values) do
27
28
  {
28
- 'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://www.example.com/wms'
29
+ "http://www.opengis.net/def/serviceType/ogc/wms" => "http://www.example.com/wms"
29
30
  }
30
31
  end
31
32
  let(:options) do
32
33
  {
33
- service_type: 'wms',
34
+ :service_type => "wms",
34
35
  references_field => references_values.to_json
35
36
  }
36
37
  end
@@ -40,8 +41,8 @@ describe Geoblacklight::HglDownload do
40
41
  let(:faraday_request_options) { OpenStruct.new(timeout: nil, open_timeout: nil) }
41
42
  let(:reference) { instance_double(Geoblacklight::Reference) }
42
43
  # Methods cannot be stubbed which are automatically generated from Hash keys
43
- let(:references) { double('references') }
44
- let(:endpoint) { 'http://www.example.com/wms' }
44
+ let(:references) { double("references") }
45
+ let(:endpoint) { "http://www.example.com/wms" }
45
46
 
46
47
  before do
47
48
  allow(reference).to receive(:endpoint).and_return(endpoint)
@@ -51,7 +52,7 @@ describe Geoblacklight::HglDownload do
51
52
  allow(faraday_request).to receive(:options).and_return(faraday_request_options)
52
53
  end
53
54
 
54
- it 'downloads the file and generates a message for the client' do
55
+ it "downloads the file and generates a message for the client" do
55
56
  allow(faraday_connection).to receive(:get).and_yield(faraday_request).and_return(faraday_response)
56
57
  allow(Faraday).to receive(:new).with(url: endpoint).and_return(faraday_connection)
57
58
 
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  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.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
+ 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
7
  let(:download) { described_class.new(document) }
7
- describe '#initialize' do
8
- it 'initializes as a KmzDownload object with specific options' do
8
+ describe "#initialize" do
9
+ it "initializes as a KmzDownload object with specific options" do
9
10
  expect(download).to be_an described_class
10
11
  options = download.instance_variable_get(:@options)
11
- expect(options[:content_type]).to eq 'application/vnd.google-earth.kmz'
12
- expect(options[:request_params][:layers]).to eq 'stanford-test'
13
- expect(options[:request_params][:bbox]).to eq '-180.0, -90.0, 180.0, 90.0'
12
+ expect(options[:content_type]).to eq "application/vnd.google-earth.kmz"
13
+ expect(options[:request_params][:layers]).to eq "stanford-test"
14
+ expect(options[:request_params][:bbox]).to eq "-180.0, -90.0, 180.0, 90.0"
14
15
  end
15
- it 'merges custom options' do
16
+ it "merges custom options" do
16
17
  download = described_class.new(document, timeout: 33)
17
18
  options = download.instance_variable_get(:@options)
18
19
  expect(options[:timeout]).to eq 33
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  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.GEOMETRY => 'ENVELOPE(-180, 180, 90, -90)') }
6
+ 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
7
  let(:download) { described_class.new(document) }
7
- describe '#initialize' do
8
- it 'initializes as a ShapefileDownload object with specific options' do
8
+ describe "#initialize" do
9
+ it "initializes as a ShapefileDownload object with specific options" do
9
10
  expect(download).to be_an described_class
10
11
  options = download.instance_variable_get(:@options)
11
- expect(options[:content_type]).to eq 'application/zip'
12
- expect(options[:request_params][:typeName]).to eq 'stanford-test'
12
+ expect(options[:content_type]).to eq "application/zip"
13
+ expect(options[:request_params][:typeName]).to eq "stanford-test"
13
14
  end
14
- it 'merges custom options' do
15
+ it "merges custom options" do
15
16
  download = described_class.new(document, timeout: 33)
16
17
  options = download.instance_variable_get(:@options)
17
18
  expect(options[:timeout]).to eq 33
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  describe Geoblacklight::Download do
5
6
  subject(:download) { described_class.new(document, options) }
@@ -7,78 +8,78 @@ describe Geoblacklight::Download do
7
8
  let(:faraday_connection) { instance_double(Faraday::Connection) }
8
9
  let(:faraday_response) { instance_double(Faraday::Response) }
9
10
  let(:references_field) { Settings.FIELDS.REFERENCES }
10
- let(:document) { SolrDocument.new("#{Settings.FIELDS.ID}": 'test', references_field => { 'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://www.example.com/wms' }.to_json) }
11
- let(:options) { { type: 'shapefile', extension: 'zip', service_type: 'wms', content_type: 'application/zip' } }
11
+ let(:document) { SolrDocument.new(:"#{Settings.FIELDS.ID}" => "test", references_field => {"http://www.opengis.net/def/serviceType/ogc/wms" => "http://www.example.com/wms"}.to_json) }
12
+ let(:options) { {type: "shapefile", extension: "zip", service_type: "wms", content_type: "application/zip"} }
12
13
 
13
- describe '#initialize' do
14
- it 'initializes as a Download object' do
14
+ describe "#initialize" do
15
+ it "initializes as a Download object" do
15
16
  expect(download).to be_a described_class
16
17
  end
17
18
  end
18
19
 
19
- describe '#downloadable?' do
20
+ describe "#downloadable?" do
20
21
  before do
21
22
  allow(document).to receive(:downloadable?).and_return(true)
22
23
  end
23
- it 'determines whether or not the resource can be downloaded' do
24
+ it "determines whether or not the resource can be downloaded" do
24
25
  expect(download.downloadable?).to be true
25
26
  end
26
27
  end
27
28
 
28
- describe '#file_name' do
29
- it 'gives the file name with path and extension' do
30
- expect(download.file_name).to eq 'test-shapefile.zip'
29
+ describe "#file_name" do
30
+ it "gives the file name with path and extension" do
31
+ expect(download.file_name).to eq "test-shapefile.zip"
31
32
  end
32
33
  end
33
- describe '#file_path' do
34
- it 'returns the path with name and extension' do
35
- expect(download.class.file_path).to eq Rails.root.join('tmp', 'cache', 'downloads')
34
+ describe "#file_path" do
35
+ it "returns the path with name and extension" do
36
+ expect(download.class.file_path).to eq Rails.root.join("tmp", "cache", "downloads")
36
37
  end
37
- it 'is configurable' do
38
- expect(Settings).to receive(:DOWNLOAD_PATH).and_return('configured/path')
39
- expect(download.class.file_path).to eq 'configured/path'
38
+ it "is configurable" do
39
+ expect(Settings).to receive(:DOWNLOAD_PATH).and_return("configured/path")
40
+ expect(download.class.file_path).to eq "configured/path"
40
41
  end
41
42
  end
42
- describe '#download_exists?' do
43
- it 'returns false if file does not exist' do
43
+ describe "#download_exists?" do
44
+ it "returns false if file does not exist" do
44
45
  expect(File).to receive(:file?).and_return(false)
45
46
  expect(download.download_exists?).to be_falsey
46
47
  end
47
- it 'returns true if file does not exist' do
48
+ it "returns true if file does not exist" do
48
49
  expect(File).to receive(:file?).and_return(true)
49
50
  expect(download.download_exists?).to be_truthy
50
51
  end
51
52
  end
52
- describe '#get' do
53
+ describe "#get" do
53
54
  before do
54
55
  allow(File).to receive(:file?).and_return(true)
55
56
  end
56
57
 
57
- it 'returns filename if download exists' do
58
+ it "returns filename if download exists" do
58
59
  expect(download.get).to eq download.file_name
59
60
  end
60
61
 
61
- context 'when the file has not already been downloaded' do
62
+ context "when the file has not already been downloaded" do
62
63
  let(:connection) { instance_double(Faraday::Connection) }
63
64
  let(:response) { instance_double(Faraday::Response) }
64
65
 
65
66
  before do
66
67
  allow(File).to receive(:file?).and_return(false)
67
- allow(connection).to receive(:get).and_return(object: 'file')
68
+ allow(connection).to receive(:get).and_return(object: "file")
68
69
  allow(Faraday).to receive(:new).and_return(connection)
69
70
  end
70
71
 
71
- it 'calls create_download_file if it does not exist' do
72
- allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", 'wb').and_return('')
72
+ it "calls create_download_file if it does not exist" do
73
+ allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", "wb").and_return("")
73
74
  allow(File).to receive(:rename)
74
75
 
75
- expect(download.get).to eq 'test-shapefile.zip'
76
+ expect(download.get).to eq "test-shapefile.zip"
76
77
  end
77
78
  end
78
79
  end
79
- describe '#create_download_file' do
80
+ describe "#create_download_file" do
80
81
  let(:file) { instance_double(File) }
81
- let(:shapefile) { OpenStruct.new(headers: { 'content-type' => 'application/zip' }) }
82
+ let(:shapefile) { OpenStruct.new(headers: {"content-type" => "application/zip"}) }
82
83
  let(:connection) { instance_double(Faraday::Connection) }
83
84
  let(:response) { instance_double(Faraday::Response) }
84
85
 
@@ -88,43 +89,43 @@ describe Geoblacklight::Download do
88
89
  allow(connection).to receive(:get).and_return(shapefile)
89
90
  end
90
91
 
91
- it 'creates the file, write it, and then rename from tmp if everything is ok' do
92
- allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", 'wb').and_yield(file).and_return('')
92
+ it "creates the file, write it, and then rename from tmp if everything is ok" do
93
+ allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", "wb").and_yield(file).and_return("")
93
94
  allow(File).to receive(:rename)
94
95
 
95
96
  expect(download.create_download_file).to eq download.file_name
96
97
  end
97
98
 
98
- context 'when the file received is not of the type requested' do
99
- let(:bad_file) { OpenStruct.new(headers: { 'content-type' => 'bad/file' }) }
99
+ context "when the file received is not of the type requested" do
100
+ let(:bad_file) { OpenStruct.new(headers: {"content-type" => "bad/file"}) }
100
101
 
101
102
  before do
102
103
  allow(connection).to receive(:get).and_return(bad_file)
103
104
  end
104
105
 
105
- it 'creates the file in fs and delete it if the content headers are not correct' do
106
+ it "creates the file in fs and delete it if the content headers are not correct" do
106
107
  allow(File).to receive(:delete).with("#{download.file_path_and_name}.tmp").and_return(nil)
107
108
 
108
- expect { download.create_download_file }.to raise_error(Geoblacklight::Exceptions::ExternalDownloadFailed, 'Wrong download type')
109
+ expect { download.create_download_file }.to raise_error(Geoblacklight::Exceptions::ExternalDownloadFailed, "Wrong download type")
109
110
  end
110
111
  end
111
112
 
112
- context 'when the MIME type has more information encoded' do
113
- let(:geojson) { OpenStruct.new(headers: { 'content-type' => 'application/json;charset=utf-8' }) }
113
+ context "when the MIME type has more information encoded" do
114
+ let(:geojson) { OpenStruct.new(headers: {"content-type" => "application/json;charset=utf-8"}) }
114
115
 
115
116
  before do
116
117
  allow(connection).to receive(:get).and_return(geojson)
117
118
  end
118
119
 
119
- it 'accepts response MIME type that is more complex than requested' do
120
- allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", 'wb').and_return('')
120
+ it "accepts response MIME type that is more complex than requested" do
121
+ allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", "wb").and_return("")
121
122
  allow(File).to receive(:rename)
122
123
 
123
124
  expect(download.create_download_file).to eq download.file_name
124
125
  end
125
126
  end
126
127
  end
127
- describe '#initiate_download' do
128
+ describe "#initiate_download" do
128
129
  let(:faraday_request) { instance_double(Faraday::Request) }
129
130
  let(:faraday_request_options) { OpenStruct.new(timeout: nil, open_timeout: nil) }
130
131
 
@@ -133,46 +134,46 @@ describe Geoblacklight::Download do
133
134
  allow(faraday_request).to receive(:options).and_return(faraday_request_options)
134
135
  end
135
136
 
136
- it 'request download from server' do
137
+ it "request download from server" do
137
138
  allow(faraday_connection).to receive(:get).and_yield(faraday_request).and_return(faraday_response)
138
- allow(Faraday).to receive(:new).with(url: 'http://www.example.com/wms').and_return(faraday_connection)
139
+ allow(Faraday).to receive(:new).with(url: "http://www.example.com/wms").and_return(faraday_connection)
139
140
 
140
141
  expect(download.initiate_download).to eq faraday_response
141
142
  end
142
143
 
143
- it 'raises Geoblacklight::Exceptions::ExternalDownloadFailed with a connection failure' do
144
- expect(faraday_connection).to receive(:url_prefix).and_return 'http://www.example.com/wms'
145
- expect(faraday_connection).to receive(:get).and_raise(Faraday::ConnectionFailed.new('Failed'))
146
- expect(Faraday).to receive(:new).with(url: 'http://www.example.com/wms').and_return(faraday_connection)
144
+ it "raises Geoblacklight::Exceptions::ExternalDownloadFailed with a connection failure" do
145
+ expect(faraday_connection).to receive(:url_prefix).and_return "http://www.example.com/wms"
146
+ expect(faraday_connection).to receive(:get).and_raise(Faraday::ConnectionFailed.new("Failed"))
147
+ expect(Faraday).to receive(:new).with(url: "http://www.example.com/wms").and_return(faraday_connection)
147
148
  expect { download.initiate_download }.to raise_error(Geoblacklight::Exceptions::ExternalDownloadFailed)
148
149
  end
149
150
 
150
- it 'raises Geoblacklight::Exceptions::ExternalDownloadFailed with a connection timout' do
151
- expect(faraday_connection).to receive(:url_prefix).and_return 'http://www.example.com/wms'
151
+ it "raises Geoblacklight::Exceptions::ExternalDownloadFailed with a connection timout" do
152
+ expect(faraday_connection).to receive(:url_prefix).and_return "http://www.example.com/wms"
152
153
  expect(faraday_connection).to receive(:get).and_raise(Faraday::TimeoutError)
153
- expect(Faraday).to receive(:new).with(url: 'http://www.example.com/wms').and_return(faraday_connection)
154
+ expect(Faraday).to receive(:new).with(url: "http://www.example.com/wms").and_return(faraday_connection)
154
155
  expect { download.initiate_download }.to raise_error(Geoblacklight::Exceptions::ExternalDownloadFailed)
155
156
  end
156
157
  end
157
- describe '#url_with_params' do
158
+ describe "#url_with_params" do
158
159
  let(:options) do
159
160
  {
160
- service_type: 'wms',
161
+ service_type: "wms",
161
162
  request_params: {
162
- service: 'wfs',
163
- version: '2.0.0',
164
- request: 'GetFeature',
165
- srsName: 'EPSG:4326',
166
- outputformat: 'SHAPE-ZIP',
167
- typeName: ''
163
+ service: "wfs",
164
+ version: "2.0.0",
165
+ request: "GetFeature",
166
+ srsName: "EPSG:4326",
167
+ outputformat: "SHAPE-ZIP",
168
+ typeName: ""
168
169
  }
169
170
  }
170
171
  end
171
172
 
172
- it 'creates a download url with params' do
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='
173
+ it "creates a download url with params" do
174
+ expect(download.url_with_params).to eq "http://www.example.com/wms/?ser" \
175
+ "vice=wfs&version=2.0.0&request=GetFeature&srsName=EPSG%3A4326&output" \
176
+ "format=SHAPE-ZIP&typeName="
176
177
  end
177
178
  end
178
179
  end
@@ -1,58 +1,59 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  describe Geoblacklight::Geometry do
5
- let(:wkt_geom) { 'MULTIPOLYGON(((-180 81.66, -180 -12.93, -168.35 -12.93, -168.35 81.66, -180 81.66)), ((180 81.66, 25 81.66, 25 -12.93, 180 -12.93, 180 81.66)))' }
6
- let(:envelope_geom) { 'ENVELOPE(25, -168.35, 81.66, -12.93)' }
7
- let(:invalid_geom) { 'INVALID' }
8
- let(:non_polygon_geom) { 'ENVELOPE(130, 130, 33, 33)' }
6
+ let(:wkt_geom) { "MULTIPOLYGON(((-180 81.66, -180 -12.93, -168.35 -12.93, -168.35 81.66, -180 81.66)), ((180 81.66, 25 81.66, 25 -12.93, 180 -12.93, 180 81.66)))" }
7
+ let(:envelope_geom) { "ENVELOPE(25, -168.35, 81.66, -12.93)" }
8
+ let(:invalid_geom) { "INVALID" }
9
+ let(:non_polygon_geom) { "ENVELOPE(130, 130, 33, 33)" }
9
10
 
10
- describe '#geojson' do
11
- context 'with standard WKT geometry' do
12
- it 'returns geojson' do
13
- expect(described_class.new(wkt_geom).geojson).to include('MultiPolygon', 'coordinates', '[[[[-180.0,81.66]')
11
+ describe "#geojson" do
12
+ context "with standard WKT geometry" do
13
+ it "returns geojson" do
14
+ expect(described_class.new(wkt_geom).geojson).to include("MultiPolygon", "coordinates", "[[[[-180.0,81.66]")
14
15
  end
15
16
  end
16
17
 
17
- context 'with envelope syntax geometry' do
18
- it 'returns geojson' do
19
- expect(described_class.new(envelope_geom).geojson).to include('Polygon', 'coordinates', '[[[25.0,81.66]')
18
+ context "with envelope syntax geometry" do
19
+ it "returns geojson" do
20
+ expect(described_class.new(envelope_geom).geojson).to include("Polygon", "coordinates", "[[[25.0,81.66]")
20
21
  end
21
22
  end
22
23
 
23
- context 'with an invalid geometry' do
24
- it 'returns a default GeoJSON extent' do
25
- expect(described_class.new(invalid_geom).geojson).to include('coordinates', '-180.0,90.0')
24
+ context "with an invalid geometry" do
25
+ it "returns a default GeoJSON extent" do
26
+ expect(described_class.new(invalid_geom).geojson).to include("coordinates", "-180.0,90.0")
26
27
  end
27
28
  end
28
29
 
29
- context 'with a non-polygon geometry' do
30
+ context "with a non-polygon geometry" do
30
31
  before do
31
32
  allow(RGeo::GeoJSON).to receive(:encode).and_raise(RGeo::Error::InvalidGeometry)
32
33
  end
33
34
 
34
- it 'returns a default GeoJSON extent' do
35
- expect(described_class.new(non_polygon_geom).geojson).to include('coordinates', '-180.0,90.0')
35
+ it "returns a default GeoJSON extent" do
36
+ expect(described_class.new(non_polygon_geom).geojson).to include("coordinates", "-180.0,90.0")
36
37
  end
37
38
  end
38
39
  end
39
40
 
40
- describe '#bounding_box' do
41
- context 'with standard WKT geometry' do
42
- it 'returns a bounding_box' do
43
- expect(described_class.new(wkt_geom).bounding_box).to eq '-180.0, -12.93, 180.0, 81.66'
41
+ describe "#bounding_box" do
42
+ context "with standard WKT geometry" do
43
+ it "returns a bounding_box" do
44
+ expect(described_class.new(wkt_geom).bounding_box).to eq "-180.0, -12.93, 180.0, 81.66"
44
45
  end
45
46
  end
46
47
 
47
- context 'with envelope syntax geometry' do
48
- it 'returns a bounding_box' do
49
- expect(described_class.new(envelope_geom).bounding_box).to eq '-168.35, -12.93, 25.0, 81.66'
48
+ context "with envelope syntax geometry" do
49
+ it "returns a bounding_box" do
50
+ expect(described_class.new(envelope_geom).bounding_box).to eq "-168.35, -12.93, 25.0, 81.66"
50
51
  end
51
52
  end
52
53
 
53
- context 'with an invalid geometry' do
54
- it 'returns a default GeoJSON extent' do
55
- expect(described_class.new(invalid_geom).bounding_box).to include('coordinates', '-180.0,90.0')
54
+ context "with an invalid geometry" do
55
+ it "returns a default GeoJSON extent" do
56
+ expect(described_class.new(invalid_geom).bounding_box).to include("coordinates", "-180.0,90.0")
56
57
  end
57
58
  end
58
59
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  describe Geoblacklight::ItemViewer do
5
6
  let(:document) { SolrDocument.new(document_attributes) }
@@ -7,70 +8,70 @@ describe Geoblacklight::ItemViewer do
7
8
  let(:references) { document.references }
8
9
  let(:references_field) { Settings.FIELDS.REFERENCES }
9
10
  let(:item_viewer) { described_class.new(references) }
10
- describe 'viewer_preference' do
11
- describe 'for no references' do
12
- it 'returns nil' do
11
+ describe "viewer_preference" do
12
+ describe "for no references" do
13
+ it "returns nil" do
13
14
  expect(item_viewer.viewer_preference).to be_nil
14
15
  end
15
16
  end
16
- describe 'for wms reference' do
17
+ describe "for wms reference" do
17
18
  let(:document_attributes) do
18
19
  {
19
20
  references_field => {
20
- 'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://www.example.com/wms',
21
- 'http://iiif.io/api/image' => 'http://www.example.com/iiif'
21
+ "http://www.opengis.net/def/serviceType/ogc/wms" => "http://www.example.com/wms",
22
+ "http://iiif.io/api/image" => "http://www.example.com/iiif"
22
23
  }.to_json
23
24
  }
24
25
  end
25
- it 'wms if wms is present' do
26
- expect(item_viewer.viewer_preference).to eq wms: 'http://www.example.com/wms'
26
+ it "wms if wms is present" do
27
+ expect(item_viewer.viewer_preference).to eq wms: "http://www.example.com/wms"
27
28
  end
28
29
  end
29
- describe 'for tms reference' do
30
+ describe "for tms reference" do
30
31
  let(:document_attributes) do
31
32
  {
32
33
  references_field => {
33
- 'https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification' => 'http://www.example.com/tms'
34
+ "https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification" => "http://www.example.com/tms"
34
35
  }.to_json
35
36
  }
36
37
  end
37
- it 'tms if tms is present' do
38
- expect(item_viewer.viewer_preference).to eq tms: 'http://www.example.com/tms'
38
+ it "tms if tms is present" do
39
+ expect(item_viewer.viewer_preference).to eq tms: "http://www.example.com/tms"
39
40
  end
40
41
  end
41
- describe 'for iiif only reference' do
42
+ describe "for iiif only reference" do
42
43
  let(:document_attributes) do
43
44
  {
44
45
  references_field => {
45
- 'http://iiif.io/api/image' => 'http://www.example.com/iiif'
46
+ "http://iiif.io/api/image" => "http://www.example.com/iiif"
46
47
  }.to_json
47
48
  }
48
49
  end
49
- it 'returns iiif' do
50
- expect(item_viewer.viewer_preference).to eq iiif: 'http://www.example.com/iiif'
50
+ it "returns iiif" do
51
+ expect(item_viewer.viewer_preference).to eq iiif: "http://www.example.com/iiif"
51
52
  end
52
53
  end
53
- describe 'for tiled map layer reference' do
54
+ describe "for tiled map layer reference" do
54
55
  let(:document_attributes) do
55
56
  {
56
57
  references_field => {
57
- 'urn:x-esri:serviceType:ArcGIS#TiledMapLayer' => 'http://www.example.com/MapServer'
58
+ "urn:x-esri:serviceType:ArcGIS#TiledMapLayer" => "http://www.example.com/MapServer"
58
59
  }.to_json
59
60
  }
60
61
  end
61
- it 'returns mapservice' do
62
- expect(item_viewer.viewer_preference).to eq tiled_map_layer: 'http://www.example.com/MapServer'
62
+ it "returns mapservice" do
63
+ expect(item_viewer.viewer_preference).to eq tiled_map_layer: "http://www.example.com/MapServer"
63
64
  end
64
65
  end
65
- context 'index map' do
66
+ context "index map" do
66
67
  let(:document_attributes) do
67
68
  {
68
69
  references_field => {
69
- 'https://openindexmaps.org' => 'http://www.example.com/index_map'
70
+ "https://openindexmaps.org" => "http://www.example.com/index_map"
70
71
  }.to_json
71
72
  }
72
73
  end
73
- it { expect(item_viewer.viewer_preference).to eq index_map: 'http://www.example.com/index_map' }
74
+ it { expect(item_viewer.viewer_preference).to eq index_map: "http://www.example.com/index_map" }
74
75
  end
75
76
  end
76
77
  end