geoblacklight 6.0.0.pre.alpha.7 → 6.0.0.pre.beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +14 -3
  3. data/README.md +2 -2
  4. data/Rakefile +1 -17
  5. data/app/assets/images/geoblacklight/logo-dark.svg +31 -0
  6. data/app/assets/images/geoblacklight/logo.svg +10 -10
  7. data/app/assets/stylesheets/geoblacklight/global.css +44 -7
  8. data/app/assets/stylesheets/geoblacklight/index_maps.css +0 -7
  9. data/app/assets/stylesheets/geoblacklight/record.css +33 -9
  10. data/app/assets/stylesheets/geoblacklight/search.css +66 -17
  11. data/app/assets/stylesheets/geoblacklight/viewers.css +18 -111
  12. data/app/assets/stylesheets/geoblacklight.css +0 -5
  13. data/app/components/blacklight/icons/georeferenced_component.rb +23 -0
  14. data/app/components/geoblacklight/document/download_link_component.html.erb +1 -1
  15. data/app/components/geoblacklight/document/preview_component.html.erb +0 -2
  16. data/app/components/geoblacklight/document_component.html.erb +0 -4
  17. data/app/components/geoblacklight/facets/bbox_field_component.html.erb +2 -1
  18. data/app/components/geoblacklight/georeferenced_header_badge_component.rb +16 -0
  19. data/app/components/geoblacklight/header_badge_component.html.erb +4 -2
  20. data/app/components/geoblacklight/header_badge_component.rb +1 -1
  21. data/app/components/geoblacklight/header_badges_component.html.erb +5 -0
  22. data/app/components/geoblacklight/header_badges_component.rb +34 -0
  23. data/app/components/geoblacklight/iiif_drag_drop_component.html.erb +1 -1
  24. data/app/components/geoblacklight/item_map_viewer_component.html.erb +0 -58
  25. data/app/components/geoblacklight/item_map_viewer_component.rb +19 -70
  26. data/app/components/geoblacklight/locator_map_component.rb +31 -0
  27. data/app/components/geoblacklight/login_link_component.html.erb +1 -1
  28. data/app/components/geoblacklight/login_link_component.rb +17 -1
  29. data/app/components/geoblacklight/metadata_description_markdown_component.rb +3 -9
  30. data/app/components/geoblacklight/overview_map_component.html.erb +2 -0
  31. data/app/components/geoblacklight/overview_map_component.rb +86 -0
  32. data/app/components/geoblacklight/relations/relation_component.html.erb +12 -0
  33. data/app/components/geoblacklight/relations/relation_component.rb +30 -0
  34. data/app/components/geoblacklight/relations/relations_component.html.erb +15 -0
  35. data/app/components/geoblacklight/relations/relations_component.rb +59 -0
  36. data/app/components/geoblacklight/resource_header_badge_component.rb +1 -1
  37. data/app/components/geoblacklight/search_result_component.html.erb +14 -33
  38. data/app/components/geoblacklight/search_result_component.rb +2 -14
  39. data/app/components/geoblacklight/static_map_component.rb +3 -14
  40. data/app/components/geoblacklight/truncatable_metadata_field_layout_component.html.erb +7 -0
  41. data/app/components/geoblacklight/truncatable_metadata_field_layout_component.rb +45 -0
  42. data/app/controllers/{relation_controller.rb → relations_controller.rb} +4 -2
  43. data/app/controllers/viewer_record_controller.rb +28 -0
  44. data/app/helpers/geoblacklight_helper.rb +57 -6
  45. data/app/javascript/geoblacklight/controllers/overview_map_controller.js +143 -0
  46. data/app/javascript/geoblacklight/core.js +8 -10
  47. data/app/javascript/geoblacklight/index.js +9 -12
  48. data/app/javascript/geoblacklight/initializers/field_truncation.js +62 -0
  49. data/app/javascript/geoblacklight/initializers/metadata_download.js +3 -8
  50. data/app/javascript/geoblacklight/initializers/truncation.js +7 -3
  51. data/app/javascript/geoblacklight/initializers/viewer_requests.js +61 -0
  52. data/app/javascript/geoblacklight/initializers/viewer_theme.js +28 -0
  53. data/app/models/concerns/geoblacklight/solr_document/thumbnail.rb +38 -0
  54. data/app/models/concerns/geoblacklight/solr_document.rb +2 -0
  55. data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +1 -1
  56. data/app/views/catalog/_document_split.html.erb +10 -10
  57. data/app/views/catalog/_home_text.html.erb +1 -1
  58. data/app/views/catalog/metadata.html.erb +1 -1
  59. data/app/views/{relation → relations}/index.html.erb +1 -1
  60. data/app/views/relations/index.json.jbuilder +9 -0
  61. data/config/importmap.rb +8 -8
  62. data/config/locales/geoblacklight.en.yml +48 -99
  63. data/geoblacklight.gemspec +3 -3
  64. data/lib/generators/geoblacklight/assets_generator.rb +2 -2
  65. data/lib/generators/geoblacklight/install_generator.rb +3 -6
  66. data/lib/generators/geoblacklight/templates/assets/customizations.css +5 -1
  67. data/lib/generators/geoblacklight/templates/catalog_controller.rb +17 -27
  68. data/lib/generators/geoblacklight/templates/settings.yml +15 -95
  69. data/lib/geoblacklight/configuration/display_note_shown_config.rb +3 -0
  70. data/lib/geoblacklight/configuration/relationship_config.rb +7 -1
  71. data/lib/geoblacklight/configuration/relationships_config.rb +15 -15
  72. data/lib/geoblacklight/configuration/settings_attributes.rb +85 -0
  73. data/lib/geoblacklight/configuration/settings_builder.rb +3 -14
  74. data/lib/geoblacklight/configuration.rb +23 -62
  75. data/lib/geoblacklight/exceptions.rb +4 -0
  76. data/lib/geoblacklight/reference.rb +0 -2
  77. data/lib/geoblacklight/references.rb +17 -5
  78. data/lib/geoblacklight/relations/ancestors.rb +12 -0
  79. data/lib/geoblacklight/relations/descendants.rb +11 -0
  80. data/lib/geoblacklight/relations/query.rb +39 -0
  81. data/lib/geoblacklight/{relation → relations}/relation_response.rb +5 -4
  82. data/lib/geoblacklight/routes/exportable.rb +2 -1
  83. data/lib/geoblacklight/version.rb +1 -1
  84. data/lib/geoblacklight/viewer_record.rb +39 -0
  85. data/lib/geoblacklight.rb +1 -1
  86. data/lib/tasks/geoblacklight.rake +1 -17
  87. data/lib/tasks/solr.rb +37 -0
  88. data/schema/readme.md +1 -1
  89. data/script/wait-for-solr +36 -0
  90. data/solr/conf/solrconfig.xml +10 -16
  91. data/spec/components/geoblacklight/document/sidebar_component_spec.rb +3 -3
  92. data/spec/components/geoblacklight/document_component_spec.rb +8 -34
  93. data/spec/components/geoblacklight/{header_icons_component_spec.rb → header_badges_component_spec.rb} +20 -2
  94. data/spec/components/geoblacklight/item_map_viewer_component_spec.rb +65 -15
  95. data/spec/components/geoblacklight/locator_map_component_spec.rb +54 -0
  96. data/spec/components/geoblacklight/login_link_component_spec.rb +20 -12
  97. data/spec/components/geoblacklight/metadata_description_markdown_component_spec.rb +1 -6
  98. data/spec/components/geoblacklight/overview_map_component_spec.rb +136 -0
  99. data/spec/components/geoblacklight/relations/relation_component_spec.rb +98 -0
  100. data/spec/components/geoblacklight/relations/relations_component_spec.rb +146 -0
  101. data/spec/components/geoblacklight/search_result_component_spec.rb +66 -39
  102. data/spec/components/geoblacklight/static_map_component_spec.rb +8 -2
  103. data/spec/components/geoblacklight/truncatable_metadata_field_layout_component_spec.rb +83 -0
  104. data/spec/controllers/catalog_controller_spec.rb +22 -7
  105. data/spec/controllers/{relation_controller_spec.rb → relations_controller_spec.rb} +1 -1
  106. data/spec/factories/user.rb +6 -1
  107. data/spec/features/axe_spec.rb +5 -3
  108. data/spec/features/home_page_spec.rb +8 -7
  109. data/spec/features/index_view_spec.rb +6 -20
  110. data/spec/features/layer_preview_spec.rb +4 -11
  111. data/spec/features/locator_map_spec.rb +31 -0
  112. data/spec/features/relations_spec.rb +22 -11
  113. data/spec/features/restricted_viewer_spec.rb +14 -0
  114. data/spec/features/search_results_map_spec.rb +89 -13
  115. data/spec/features/search_spec.rb +6 -2
  116. data/spec/features/sign_in_spec.rb +26 -0
  117. data/spec/features/tilejson_spec.rb +1 -3
  118. data/spec/features/tms_spec.rb +2 -2
  119. data/spec/features/truncated_metadata_spec.rb +77 -0
  120. data/spec/features/viewer_requests_spec.rb +40 -0
  121. data/spec/features/viewer_theme_spec.rb +51 -0
  122. data/spec/features/wmts_spec.rb +6 -6
  123. data/spec/features/xyz_spec.rb +3 -3
  124. data/spec/fixtures/solr_documents/README.md +18 -14
  125. data/spec/fixtures/solr_documents/actual-polygon1.json +22 -18
  126. data/spec/fixtures/solr_documents/b1g_wabash_child_15.json +14 -15
  127. data/spec/fixtures/solr_documents/b1g_wabash_child_16.json +14 -15
  128. data/spec/fixtures/solr_documents/b1g_wabash_child_17.json +14 -15
  129. data/spec/fixtures/solr_documents/b1g_wabash_child_18.json +14 -15
  130. data/spec/fixtures/solr_documents/b1g_wabash_parent.json +14 -15
  131. data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +2 -2
  132. data/spec/fixtures/solr_documents/esri-feature-layer.json +1 -1
  133. data/spec/fixtures/solr_documents/esri-image-map-layer.json +20 -20
  134. data/spec/fixtures/solr_documents/esri-wms-layer.json +22 -24
  135. data/spec/fixtures/solr_documents/index_map_point.json +3 -3
  136. data/spec/fixtures/solr_documents/public_polygon.json +28 -0
  137. data/spec/helpers/geoblacklight_helper_spec.rb +103 -25
  138. data/spec/lib/geoblacklight/bounding_box_spec.rb +16 -0
  139. data/spec/lib/geoblacklight/configuration/relationships_config_spec.rb +121 -0
  140. data/spec/lib/geoblacklight/configuration/settings_attributes_spec.rb +113 -0
  141. data/spec/lib/geoblacklight/configuration/settings_builder_spec.rb +33 -4
  142. data/spec/lib/geoblacklight/references_spec.rb +35 -0
  143. data/spec/lib/geoblacklight/{relation → relations}/ancestors_spec.rb +17 -6
  144. data/spec/lib/geoblacklight/{relation → relations}/descendants_spec.rb +14 -7
  145. data/spec/lib/geoblacklight/{relation → relations}/relation_response_spec.rb +31 -17
  146. data/spec/lib/geoblacklight/viewer_record_spec.rb +69 -0
  147. data/spec/models/concerns/geoblacklight/solr_document/thumbnail_spec.rb +149 -0
  148. data/spec/models/concerns/geoblacklight/solr_document_spec.rb +1 -1
  149. data/spec/requests/bookmarks_spec.rb +2 -1
  150. data/spec/requests/catalog_show_spec.rb +24 -2
  151. data/spec/requests/index_view_spec.rb +50 -2
  152. data/spec/requests/missing_metadata_spec.rb +1 -1
  153. data/spec/requests/relations_spec.rb +9 -2
  154. data/spec/requests/search_results_spec.rb +6 -6
  155. data/spec/requests/viewer_record_spec.rb +37 -0
  156. data/spec/requests/viewer_requests_spec.rb +52 -0
  157. data/spec/solr_config_spec.rb +41 -0
  158. data/spec/solr_fixtures_spec.rb +23 -0
  159. data/spec/spec_helper.rb +13 -3
  160. data/spec/support/authentication.rb +37 -0
  161. data/spec/support/features/map_helpers.rb +68 -0
  162. data/spec/support/features/session_helpers.rb +18 -13
  163. data/spec/support/features/viewer_helpers.rb +20 -0
  164. data/spec/support/features.rb +4 -0
  165. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  166. data/template.rb +1 -1
  167. metadata +72 -84
  168. data/app/components/geoblacklight/accordion_component.html.erb +0 -16
  169. data/app/components/geoblacklight/accordion_component.rb +0 -15
  170. data/app/components/geoblacklight/attribute_table_component.html.erb +0 -15
  171. data/app/components/geoblacklight/attribute_table_component.rb +0 -17
  172. data/app/components/geoblacklight/header_icons_component.html.erb +0 -3
  173. data/app/components/geoblacklight/header_icons_component.rb +0 -27
  174. data/app/components/geoblacklight/index_map_inspect_component.html.erb +0 -12
  175. data/app/components/geoblacklight/index_map_inspect_component.rb +0 -15
  176. data/app/components/geoblacklight/index_map_legend_component.html.erb +0 -14
  177. data/app/components/geoblacklight/index_map_legend_component.rb +0 -24
  178. data/app/components/geoblacklight/location_leaflet_map_component.rb +0 -68
  179. data/app/components/geoblacklight/relations_component.html.erb +0 -23
  180. data/app/components/geoblacklight/relations_component.rb +0 -25
  181. data/app/components/geoblacklight/viewer_help_text_component.html.erb +0 -1
  182. data/app/components/geoblacklight/viewer_help_text_component.rb +0 -46
  183. data/app/controllers/wms_controller.rb +0 -17
  184. data/app/javascript/geoblacklight/controllers/leaflet_viewer_controller.js +0 -240
  185. data/app/javascript/geoblacklight/controllers/openlayers_viewer_controller.js +0 -74
  186. data/app/javascript/geoblacklight/controllers/search_results_controller.js +0 -50
  187. data/app/javascript/geoblacklight/initializers/popovers.js +0 -11
  188. data/app/javascript/geoblacklight/initializers/tooltips.js +0 -51
  189. data/app/javascript/geoblacklight/leaflet/basemaps.js +0 -73
  190. data/app/javascript/geoblacklight/leaflet/constants.js +0 -18
  191. data/app/javascript/geoblacklight/leaflet/controls/geosearch.js +0 -168
  192. data/app/javascript/geoblacklight/leaflet/controls/layer_opacity.js +0 -121
  193. data/app/javascript/geoblacklight/leaflet/controls/sidebar.js +0 -49
  194. data/app/javascript/geoblacklight/leaflet/controls/sleep.js +0 -101
  195. data/app/javascript/geoblacklight/leaflet/inspection.js +0 -210
  196. data/app/javascript/geoblacklight/leaflet/layer_index_map.js +0 -128
  197. data/app/javascript/geoblacklight/leaflet/layer_wmts.js +0 -57
  198. data/app/javascript/geoblacklight/leaflet/layers.js +0 -146
  199. data/app/javascript/geoblacklight/leaflet/utils.js +0 -83
  200. data/app/javascript/geoblacklight/openlayers/basemaps.js +0 -55
  201. data/app/javascript/geoblacklight/openlayers/inspection.js +0 -42
  202. data/app/javascript/geoblacklight/openlayers/layers.js +0 -44
  203. data/app/views/relation/index.json.jbuilder +0 -8
  204. data/lib/geoblacklight/configuration/layer_config.rb +0 -28
  205. data/lib/geoblacklight/configuration/leaflet_config.rb +0 -73
  206. data/lib/geoblacklight/configuration/leaflet_layers_config.rb +0 -33
  207. data/lib/geoblacklight/configuration/leaflet_sleep_config.rb +0 -20
  208. data/lib/geoblacklight/relation/ancestors.rb +0 -31
  209. data/lib/geoblacklight/relation/descendants.rb +0 -31
  210. data/lib/geoblacklight/routes/wms.rb +0 -15
  211. data/lib/geoblacklight/wms_layer/feature_info_response.rb +0 -37
  212. data/lib/geoblacklight/wms_layer.rb +0 -34
  213. data/spec/components/geoblacklight/attribute_table_component_spec.rb +0 -36
  214. data/spec/components/geoblacklight/index_map_legend_component_spec.rb +0 -29
  215. data/spec/components/geoblacklight/viewer_help_text_component_spec.rb +0 -27
  216. data/spec/controllers/wms_controller_spec.rb +0 -34
  217. data/spec/features/configurable_basemap_spec.rb +0 -40
  218. data/spec/features/full_screen_control_spec.rb +0 -15
  219. data/spec/features/layer_inspection_spec.rb +0 -12
  220. data/spec/features/layer_opacity_spec.rb +0 -16
  221. data/spec/fixtures/solr_documents/harvard_raster.json +0 -39
  222. data/spec/fixtures/solr_documents/public_polygon_mit.json +0 -23
  223. data/spec/fixtures/solr_documents/uva_slug_colon.json +0 -29
  224. data/spec/javascripts/geoblacklight_spec.js +0 -11
  225. data/spec/lib/geoblacklight/configuration/layer_config_spec.rb +0 -71
  226. data/spec/lib/geoblacklight/configuration/leaflet_config_spec.rb +0 -129
  227. data/spec/lib/geoblacklight/configuration/leaflet_layers_config_spec.rb +0 -63
  228. data/spec/lib/geoblacklight/configuration_spec.rb +0 -48
  229. data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +0 -54
  230. data/spec/lib/geoblacklight/wms_layer_spec.rb +0 -115
  231. /data/app/components/geoblacklight/{location_leaflet_map_component.html.erb → locator_map_component.html.erb} +0 -0
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Geoblacklight::Configuration::LeafletConfig do
6
- subject(:config) { described_class.new }
7
-
8
- describe "#sleep=" do
9
- it "replaces the default sleep config with a LeafletSleepConfig" do
10
- config.sleep = {sleep: false, margin_distance: 50, message: "Wake up!"}
11
-
12
- expect(config.sleep).to be_a(Geoblacklight::Configuration::LeafletSleepConfig)
13
- expect(config.sleep.sleep).to be(false)
14
- expect(config.sleep.margin_distance).to eq(50)
15
- expect(config.sleep.message).to eq("Wake up!")
16
- end
17
-
18
- it "applies LeafletSleepConfig defaults for unspecified attributes" do
19
- config.sleep = {message: "Custom message"}
20
-
21
- expect(config.sleep.message).to eq("Custom message")
22
- expect(config.sleep.sleep).to be(true)
23
- expect(config.sleep.sleeptime).to eq(750)
24
- expect(config.sleep.waketime).to eq(750)
25
- expect(config.sleep.background).to eq("rgba(214, 214, 214, .7)")
26
- end
27
-
28
- it "replaces rather than merges with the previous sleep config" do
29
- config.sleep = {sleep: false}
30
-
31
- expect(config.sleep.sleep).to be(false)
32
- expect(config.sleep.margin_distance).to eq(100)
33
- end
34
-
35
- it "produces a fresh independent object on each assignment" do
36
- original = config.sleep
37
- config.sleep = {sleep: false}
38
-
39
- expect(config.sleep).not_to be(original)
40
- expect(original.sleep).to be(true)
41
- end
42
-
43
- it "accepts an empty hash, falling back entirely to defaults" do
44
- config.sleep = {}
45
-
46
- expect(config.sleep).to be_a(Geoblacklight::Configuration::LeafletSleepConfig)
47
- expect(config.sleep.sleep).to be(true)
48
- expect(config.sleep.message).to eq("Click to Wake")
49
- end
50
-
51
- it "is reflected in #to_h" do
52
- config.sleep = {sleep: false, message: "Hello"}
53
-
54
- expect(config.to_h[:sleep]).to include("sleep" => false, "message" => "Hello")
55
- end
56
- end
57
-
58
- describe "#layers=" do
59
- let(:attributes) do
60
- {
61
- detect_retina: false,
62
- index: {
63
- DEFAULT: {color: "#7FCDBB", sr_color_name: "Green"},
64
- UNAVAILABLE: Geoblacklight::Configuration::LayerConfig.new(
65
- color: "#EDF8B1", sr_color_name: "Yellow"
66
- )
67
- }
68
- }
69
- end
70
-
71
- it "replaces the default layers config with a LeafletLayersConfig" do
72
- config.layers = attributes
73
-
74
- expect(config.layers).to be_a(Geoblacklight::Configuration::LeafletLayersConfig)
75
- expect(config.layers.detect_retina).to be(false)
76
- end
77
-
78
- it "coerces hash entries under index into LayerConfig instances" do
79
- config.layers = attributes
80
-
81
- default = config.layers.index[:DEFAULT]
82
- expect(default).to be_a(Geoblacklight::Configuration::LayerConfig)
83
- expect(default.color).to eq("#7FCDBB")
84
- expect(default.sr_color_name).to eq("Green")
85
- expect(default.weight).to eq(1)
86
- end
87
-
88
- it "preserves existing LayerConfig instances under index" do
89
- config.layers = attributes
90
-
91
- unavailable = config.layers.index[:UNAVAILABLE]
92
- expect(unavailable).to be_a(Geoblacklight::Configuration::LayerConfig)
93
- expect(unavailable.color).to eq("#EDF8B1")
94
- end
95
-
96
- it "replaces rather than merges with the previous layers config" do
97
- config.layers = {index: {DEFAULT: {color: "#000000"}}}
98
-
99
- expect(config.layers.index.keys).to eq([:DEFAULT])
100
- expect(config.layers.index[:SELECTED]).to be_nil
101
- end
102
-
103
- it "produces a fresh independent object on each assignment" do
104
- original = config.layers
105
- config.layers = {index: {}}
106
-
107
- expect(config.layers).not_to be(original)
108
- expect(original.index).to include(:DEFAULT, :UNAVAILABLE, :SELECTED)
109
- end
110
-
111
- it "accepts an empty hash, resulting in an empty index" do
112
- config.layers = {}
113
-
114
- expect(config.layers).to be_a(Geoblacklight::Configuration::LeafletLayersConfig)
115
- expect(config.layers.index).to eq({})
116
- end
117
-
118
- it "is reflected in #to_h" do
119
- config.layers = attributes
120
-
121
- expect(config.to_h[:layers]).to include(
122
- "detect_retina" => false,
123
- "index" => hash_including(
124
- DEFAULT: {color: "#7FCDBB", weight: 1, radius: 4, sr_color_name: "Green"}
125
- )
126
- )
127
- end
128
- end
129
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Geoblacklight::Configuration::LeafletLayersConfig do
6
- subject(:config) { described_class.new(attributes) }
7
-
8
- let(:attributes) do
9
- {
10
- detect_retina: true,
11
- index: {
12
- DEFAULT: {
13
- color: "#7FCDBB",
14
- sr_color_name: "Green"
15
- },
16
- UNAVAILABLE: Geoblacklight::Configuration::LayerConfig.new(
17
- color: "#EDF8B1",
18
- sr_color_name: "Yellow"
19
- )
20
- }
21
- }
22
- end
23
-
24
- describe "initialization" do
25
- it "sets detect_retina attribute" do
26
- expect(config.detect_retina).to be(true)
27
- end
28
-
29
- it "converts hash elements under index to LayerConfig instances" do
30
- expect(config.index[:DEFAULT]).to be_a(Geoblacklight::Configuration::LayerConfig)
31
- expect(config.index[:DEFAULT].color).to eq("#7FCDBB")
32
- expect(config.index[:DEFAULT].weight).to eq(1) # Uses default weight from LayerConfig
33
- end
34
-
35
- it "keeps existing LayerConfig instances under index" do
36
- expect(config.index[:UNAVAILABLE]).to be_a(Geoblacklight::Configuration::LayerConfig)
37
- expect(config.index[:UNAVAILABLE].color).to eq("#EDF8B1")
38
- expect(config.index[:UNAVAILABLE].weight).to eq(1) # Uses default weight from LayerConfig
39
- end
40
- end
41
-
42
- describe "#to_h" do
43
- it "serializes index to a hash of hashes" do
44
- expect(config.to_h).to eq(
45
- "detect_retina" => true,
46
- "index" => {
47
- DEFAULT: {
48
- color: "#7FCDBB",
49
- weight: 1,
50
- radius: 4,
51
- sr_color_name: "Green"
52
- },
53
- UNAVAILABLE: {
54
- color: "#EDF8B1",
55
- weight: 1,
56
- radius: 4,
57
- sr_color_name: "Yellow"
58
- }
59
- }
60
- )
61
- end
62
- end
63
- end
@@ -1,48 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Geoblacklight::Configuration do
4
- subject(:config) { Geoblacklight::Configuration.new }
5
-
6
- describe "#leaflet_options" do
7
- subject(:leaflet_options) { config.leaflet_options }
8
-
9
- it "returns a hash of options for leaflet" do
10
- expect(leaflet_options.layers.index.keys).to eq(%i[DEFAULT UNAVAILABLE SELECTED])
11
- end
12
-
13
- it "uses LayerConfig instances for index configurations" do
14
- expect(leaflet_options.layers.index[:DEFAULT]).to be_a(Geoblacklight::Configuration::LayerConfig)
15
- expect(leaflet_options.layers.index[:DEFAULT].weight).to eq(1)
16
- expect(leaflet_options.layers.index[:DEFAULT].radius).to eq(4)
17
- expect(leaflet_options.layers.index[:DEFAULT].color).to eq("#7FCDBB")
18
- expect(leaflet_options.layers.index[:DEFAULT].sr_color_name).to eq("Green")
19
- end
20
-
21
- it "serializes layers options correctly with LayerConfig defaults" do
22
- layers_hash = leaflet_options.to_h[:layers]
23
- expect(layers_hash).to eq(
24
- "detect_retina" => true,
25
- "index" => {
26
- DEFAULT: {
27
- color: "#7FCDBB",
28
- weight: 1,
29
- radius: 4,
30
- sr_color_name: "Green"
31
- },
32
- UNAVAILABLE: {
33
- color: "#EDF8B1",
34
- weight: 1,
35
- radius: 4,
36
- sr_color_name: "Yellow"
37
- },
38
- SELECTED: {
39
- color: "#2C7FB8",
40
- weight: 1,
41
- radius: 4,
42
- sr_color_name: "Blue"
43
- }
44
- }
45
- )
46
- end
47
- end
48
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Geoblacklight::FeatureInfoResponse do
6
- let(:response) { described_class.new(OpenStruct.new(body: "<html><body><table><th>Header1</th><th>Header2</th><td>value1</td><td>value2</td></body></html>", headers: {"content-type" => "all good"})) }
7
- let(:response_multiple_features) { described_class.new(OpenStruct.new(body: "<html><body><table><th>Header1</th><th>Header2</th><tr><td>value1</td><td>value2</td></tr><tr><td>value3</td><td>value4</td></tr></body></html>", headers: {"content-type" => "all good"})) }
8
- let(:error_response) { described_class.new(error: "bad stuff") }
9
- let(:content_response) { described_class.new(OpenStruct.new(headers: {"content-type" => "text/xml"})) }
10
-
11
- describe "#initialize" do
12
- it "initializes as a FeatureInfoResponse type" do
13
- expect(response).to be_an described_class
14
- end
15
- end
16
-
17
- describe "#error?" do
18
- it "if no error" do
19
- expect(response.error?).to be_falsey
20
- end
21
- it "if error key is present" do
22
- expect(error_response.error?).to be_truthy
23
- end
24
- it "if content-type header is text/xml" do
25
- expect(content_response.error?).to be_truthy
26
- end
27
- end
28
-
29
- describe "#format" do
30
- it "returns a formated response" do
31
- expect(response.format).not_to be_nil
32
- expect(response.format[:features][0][:properties].keys.length).to eq 2
33
- expect(response.format[:features][0][:isHTML]).to be true
34
- expect(response.format[:features][0][:properties]["Header1"]).to eq "value1"
35
- expect(response.format[:features][0][:properties]["Header2"]).to eq "value2"
36
- end
37
- it "returns a formated response when multiple features are retrieved" do
38
- expect(response_multiple_features.format).not_to be_nil
39
- expect(response.format[:features][0][:properties].keys.length).to eq 2
40
- expect(response.format[:features][0][:isHTML]).to be true
41
- expect(response.format[:features][0][:properties]["Header1"]).to eq "value1"
42
- expect(response.format[:features][0][:properties]["Header2"]).to eq "value2"
43
- end
44
- end
45
-
46
- describe "#check" do
47
- it "returns a formated response if no errors" do
48
- expect(response.check).to eq response.format
49
- end
50
- it "returns the unformated response if there are errors" do
51
- expect(error_response.check).to eq error_response.instance_variable_get(:@response)
52
- end
53
- end
54
- end
@@ -1,115 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Geoblacklight::WmsLayer do
6
- let(:wms_layer) { described_class.new(params) }
7
- let(:rails_4_params) { {"URL" => "http://www.example.com/", "X" => "277"} }
8
- let(:rails_5_params) { instance_double(ActionController::Parameters) }
9
-
10
- before do
11
- allow(rails_5_params).to receive(:to_h).and_return("URL" => "http://www.example.com/", "X" => "277")
12
- end
13
-
14
- describe "#initialize" do
15
- let(:params) { rails_4_params }
16
-
17
- it "initializes as a WmsLayer object" do
18
- expect(wms_layer).to be_an described_class
19
- end
20
- end
21
-
22
- describe "#url" do
23
- context "when running on rails 4" do
24
- let(:params) { rails_4_params }
25
-
26
- it "returns the correct URL parameter" do
27
- expect(wms_layer.url).to eq("http://www.example.com/")
28
- end
29
- end
30
-
31
- context "when running on rails 5" do
32
- let(:params) { rails_5_params }
33
-
34
- it "returns the correct URL parameter" do
35
- expect(wms_layer.url).to eq("http://www.example.com/")
36
- end
37
- end
38
- end
39
-
40
- describe "#search_params" do
41
- context "when running on rails 4" do
42
- let(:params) { rails_4_params }
43
-
44
- it "returns all params except URL plus default params" do
45
- expect(wms_layer.search_params.length).to eq 8
46
- expect(wms_layer.search_params).not_to include "URL" => "http://www.example.com/"
47
- end
48
- end
49
-
50
- context "when running on rails 5" do
51
- let(:params) { rails_5_params }
52
-
53
- it "returns all params except URL plus default params" do
54
- expect(wms_layer.search_params.length).to eq 8
55
- expect(wms_layer.search_params).not_to include "URL" => "http://www.example.com/"
56
- end
57
- end
58
- end
59
-
60
- describe "#feature_info" do
61
- let(:response) { instance_double(Geoblacklight::FeatureInfoResponse) }
62
- let(:params) { rails_4_params }
63
-
64
- before do
65
- allow(Geoblacklight::FeatureInfoResponse).to receive(:new).and_return(response)
66
- allow(response).to receive(:check)
67
- end
68
-
69
- it "returns the response from the FeatureInfoResponse object" do
70
- expect(wms_layer.feature_info).to eq(response.check)
71
- end
72
- end
73
-
74
- describe "#request_response" do
75
- subject(:wms_layer) { described_class.new(params) }
76
- let(:params) { rails_4_params }
77
- let(:connection) { instance_double(Faraday::Connection) }
78
- let(:response) { instance_double(Faraday::Response) }
79
-
80
- before do
81
- allow(Faraday).to receive(:new).and_return(connection)
82
- end
83
-
84
- it "returns a Faraday object" do
85
- allow(connection).to receive(:get).and_return(response)
86
- expect(wms_layer.request_response).to eq(response)
87
- end
88
-
89
- context "when the HTTP connection fails" do
90
- before do
91
- allow(Geoblacklight.logger).to receive(:error).with("#<Faraday::ConnectionFailed wrapped=#<StandardError: test connection error>>")
92
- allow(connection).to receive(:get).and_raise(Faraday::ConnectionFailed.new(StandardError.new("test connection error")))
93
- end
94
-
95
- it "logs the Faraday error" do
96
- expect(Geoblacklight.logger).to receive(:error).exactly(3).times
97
- expect(wms_layer.request_response).to be_a Hash
98
- expect(wms_layer.request_response).to include(error: "#<Faraday::ConnectionFailed wrapped=#<StandardError: test connection error>>")
99
- end
100
- end
101
-
102
- context "when the HTTP connection times out" do
103
- before do
104
- allow(Geoblacklight.logger).to receive(:error).with("#<Faraday::TimeoutError #<Faraday::TimeoutError: timeout>>")
105
- allow(connection).to receive(:get).and_raise(Faraday::TimeoutError)
106
- end
107
-
108
- it "logs the Faraday error" do
109
- expect(Geoblacklight.logger).to receive(:error).exactly(3).times
110
- expect(wms_layer.request_response).to be_a Hash
111
- expect(wms_layer.request_response).to include(error: "#<Faraday::TimeoutError #<Faraday::TimeoutError: timeout>>")
112
- end
113
- end
114
- end
115
- end