geoblacklight 6.0.0.pre.beta.1 → 6.0.0.pre.beta.3

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +14 -3
  3. data/app/assets/stylesheets/geoblacklight/record.css +1 -2
  4. data/app/assets/stylesheets/geoblacklight/search.css +3 -4
  5. data/app/assets/stylesheets/geoblacklight.css +0 -1
  6. data/app/components/geoblacklight/document/download_link_component.html.erb +1 -1
  7. data/app/components/geoblacklight/document/download_links_component.html.erb +1 -1
  8. data/app/components/geoblacklight/document/download_links_component.rb +1 -1
  9. data/app/components/geoblacklight/document/preview_component.html.erb +1 -1
  10. data/app/components/geoblacklight/document/preview_component.rb +45 -0
  11. data/app/components/geoblacklight/iiif_drag_drop_component.html.erb +1 -1
  12. data/app/components/geoblacklight/iiif_drag_drop_component.rb +1 -1
  13. data/app/components/geoblacklight/login_link_component.html.erb +1 -1
  14. data/app/components/geoblacklight/login_link_component.rb +17 -1
  15. data/app/components/geoblacklight/metadata_description_markdown_component.rb +1 -1
  16. data/app/components/geoblacklight/relations/relation_component.html.erb +2 -4
  17. data/app/components/geoblacklight/relations/relation_component.rb +0 -4
  18. data/app/components/geoblacklight/search_result_component.html.erb +2 -4
  19. data/app/components/geoblacklight/search_result_component.rb +0 -3
  20. data/app/components/geoblacklight/static_map_component.rb +2 -3
  21. data/app/controllers/relations_controller.rb +2 -0
  22. data/app/controllers/viewer_record_controller.rb +2 -0
  23. data/app/helpers/geoblacklight_helper.rb +5 -19
  24. data/app/javascript/geoblacklight/controllers/overview_map_controller.js +4 -3
  25. data/app/javascript/geoblacklight/core.js +0 -2
  26. data/app/javascript/geoblacklight/initializers/field_truncation.js +1 -4
  27. data/app/models/concerns/geoblacklight/bbox_filter_field.rb +0 -13
  28. data/app/models/concerns/geoblacklight/solr_document/preview.rb +58 -0
  29. data/app/models/concerns/geoblacklight/solr_document.rb +20 -23
  30. data/app/views/catalog/_document_split.html.erb +1 -1
  31. data/config/importmap.rb +5 -6
  32. data/geoblacklight.gemspec +1 -1
  33. data/lib/generators/geoblacklight/install_generator.rb +3 -6
  34. data/lib/generators/geoblacklight/templates/assets/customizations.css +13 -4
  35. data/lib/generators/geoblacklight/templates/catalog_controller.rb +4 -6
  36. data/lib/generators/geoblacklight/templates/settings.yml +1 -25
  37. data/lib/geoblacklight/configuration/settings_builder.rb +0 -2
  38. data/lib/geoblacklight/configuration.rb +1 -19
  39. data/lib/geoblacklight/constants.rb +1 -0
  40. data/lib/geoblacklight/references.rb +0 -9
  41. data/lib/geoblacklight/version.rb +1 -1
  42. data/lib/geoblacklight.rb +0 -1
  43. data/spec/components/geoblacklight/citation_component_spec.rb +2 -2
  44. data/spec/components/geoblacklight/{item_map_viewer_component_spec.rb → document/preview_component_spec.rb} +37 -1
  45. data/spec/components/geoblacklight/document/sidebar_component_spec.rb +1 -1
  46. data/spec/components/geoblacklight/document_component_spec.rb +1 -1
  47. data/spec/components/geoblacklight/download_links_component_spec.rb +1 -1
  48. data/spec/components/geoblacklight/iiif_drag_drop_component_spec.rb +7 -7
  49. data/spec/components/geoblacklight/login_link_component_spec.rb +20 -12
  50. data/spec/components/geoblacklight/relations/relation_component_spec.rb +3 -11
  51. data/spec/components/geoblacklight/search_result_component_spec.rb +4 -12
  52. data/spec/components/geoblacklight/static_map_component_spec.rb +19 -10
  53. data/spec/factories/user.rb +6 -1
  54. data/spec/features/axe_spec.rb +1 -0
  55. data/spec/features/restricted_viewer_spec.rb +1 -3
  56. data/spec/features/search_results_map_spec.rb +13 -0
  57. data/spec/features/search_spec.rb +1 -1
  58. data/spec/features/sign_in_spec.rb +26 -0
  59. data/spec/features/truncated_metadata_spec.rb +0 -5
  60. data/spec/fixtures/solr_documents/README.md +63 -57
  61. data/spec/fixtures/solr_documents/b1g_iiif_manifest.json +1 -1
  62. data/spec/fixtures/solr_documents/baruch_documentation_download.json +1 -0
  63. data/spec/fixtures/solr_documents/bbox-spans-180.json +3 -3
  64. data/spec/fixtures/solr_documents/bluemarble.json +28 -0
  65. data/spec/fixtures/solr_documents/complex-geom.json +3 -3
  66. data/spec/fixtures/solr_documents/cornell-roads-fgdc.json +19 -0
  67. data/spec/fixtures/solr_documents/dalian.json +38 -0
  68. data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +1 -1
  69. data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +2 -2
  70. data/spec/fixtures/solr_documents/metadata_no_provider.json +0 -1
  71. data/spec/fixtures/solr_documents/modis-ndvi.json +36 -0
  72. data/spec/fixtures/solr_documents/panama.json +37 -0
  73. data/spec/fixtures/solr_documents/public_cog_princeton.json +0 -2
  74. data/spec/fixtures/solr_documents/stanford-geojson.json +39 -0
  75. data/spec/fixtures/solr_documents/usgs-htmc-index-ca-24000.json +36 -0
  76. data/spec/fixtures/solr_documents/usgs-tnm-index-dem1.json +28 -0
  77. data/spec/helpers/geoblacklight_helper_spec.rb +0 -32
  78. data/spec/lib/geoblacklight/references_spec.rb +8 -14
  79. data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +0 -24
  80. data/spec/models/concerns/geoblacklight/solr_document_spec.rb +30 -23
  81. data/spec/requests/bookmarks_spec.rb +1 -0
  82. data/spec/requests/catalog_search_spec.rb +1 -1
  83. data/spec/requests/catalog_show_spec.rb +2 -2
  84. data/spec/requests/index_view_spec.rb +6 -6
  85. data/spec/requests/metadata_spec.rb +1 -1
  86. data/spec/requests/missing_metadata_spec.rb +13 -13
  87. data/spec/requests/search_results_spec.rb +4 -3
  88. data/spec/requests/viewer_record_spec.rb +1 -3
  89. data/spec/requests/viewer_requests_spec.rb +3 -5
  90. data/spec/spec_helper.rb +11 -1
  91. data/spec/support/authentication.rb +37 -0
  92. data/spec/support/features/session_helpers.rb +15 -13
  93. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  94. data/template.rb +1 -1
  95. metadata +17 -26
  96. data/app/assets/stylesheets/geoblacklight/index_maps.css +0 -29
  97. data/app/components/geoblacklight/item_map_viewer_component.html.erb +0 -1
  98. data/app/components/geoblacklight/item_map_viewer_component.rb +0 -52
  99. data/app/controllers/wms_controller.rb +0 -17
  100. data/app/javascript/geoblacklight/initializers/tooltips.js +0 -51
  101. data/app/models/concerns/geoblacklight/solr_document/inspection.rb +0 -17
  102. data/lib/geoblacklight/geometry.rb +0 -86
  103. data/lib/geoblacklight/item_viewer.rb +0 -84
  104. data/lib/geoblacklight/routes/wms.rb +0 -15
  105. data/lib/geoblacklight/wms_layer/feature_info_response.rb +0 -37
  106. data/lib/geoblacklight/wms_layer.rb +0 -34
  107. data/spec/controllers/wms_controller_spec.rb +0 -34
  108. data/spec/fixtures/solr_documents/no_locn_geometry.json +0 -17
  109. data/spec/fixtures/solr_documents/no_spatial.json +0 -28
  110. data/spec/javascripts/metadata_download_button_spec.js +0 -17
  111. data/spec/lib/geoblacklight/geometry_spec.rb +0 -60
  112. data/spec/lib/geoblacklight/item_viewer_spec.rb +0 -77
  113. data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +0 -54
  114. data/spec/lib/geoblacklight/wms_layer_spec.rb +0 -115
  115. data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +0 -19
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe WmsController, type: :controller do
6
- let(:wms_layer) { instance_double(Geoblacklight::WmsLayer) }
7
- let(:feature_info) { {values: ["fid", "layer:example"]} }
8
- let(:params) do
9
- {"format" => "json", "URL" => "http://www.example.com/", "LAYERS" => "layer:example",
10
- "BBOX" => "-74, 40, -68, 43", "WIDTH" => "500", "HEIGHT" => "400",
11
- "QUERY_LAYERS" => "layer:example", "X" => "277", "Y" => "195"}
12
- end
13
-
14
- before do
15
- allow(Geoblacklight::WmsLayer).to receive(:new).and_return(wms_layer)
16
- allow(wms_layer).to receive(:feature_info).and_return(feature_info)
17
- end
18
-
19
- describe "#handle" do
20
- it "returns feature info as json" do
21
- get :handle, params: params
22
- expect(response.body).to eq(feature_info.to_json)
23
- end
24
- end
25
-
26
- describe "#wms_params" do
27
- let(:wms_params) { controller.instance_eval { wms_params } }
28
-
29
- it "returns only permitted params" do
30
- get :handle, params: params
31
- expect(wms_params.to_h).to eq(params)
32
- end
33
- end
34
- end
@@ -1,17 +0,0 @@
1
- {
2
- "dct_title_s": "University of Minnesota Digital Conservancy DRUM",
3
- "dct_alternative_sm": ["no_locn_geometry"],
4
- "dct_description_sm": [
5
- "This is a collection level record without spatial coordinates or a Geometry Type (GBL Metadata 1.0). ",
6
- "DRUM is a publicly available collection of digital research data generated by University of Minnesota researchers, students, and staff. Anyone can search and download the data housed in the repository, instantly or by request."
7
- ],
8
- "dct_publisher_sm": ["University of Minnesota Digital Conservancy"],
9
- "schema_provider_s": "University of Minnesota",
10
- "gbl_resourceClass_sm": ["Collections"],
11
- "dcat_keyword_sm": ["GBL Fixture records"],
12
- "dct_accessRights_s": "Public",
13
- "dct_references_s": "{\"http://schema.org/url\":\"https://conservancy.umn.edu/handle/11299/166578\"}",
14
- "id": "05d-03-noGeomType",
15
- "gbl_mdModified_dt": "2021-06-11T18:36:48Z",
16
- "gbl_mdVersion_s": "Aardvark"
17
- }
@@ -1,28 +0,0 @@
1
- {
2
- "dct_title_s": "ASTER Global Emissivity Dataset 1-kilometer V003 - AG1KM",
3
- "dct_alternative_sm": ["no_spatial"],
4
- "dct_description_sm": [
5
- "File without geometry type or locn_geometry (will cause error). ",
6
- "The Advanced Spaceborne Thermal Emission and Reflection radiometer Global Emissivity Database (ASTER GED) was developed by the National Aeronautics and Space Administration's (NASA) Jet Propulsion Laboratory (JPL), California Institute of Technology. The North America portion of this collection was formerly called the North American ASTER Land Surface Emissivity Database (NAALSED) - a seasonal dataset consisting of mean summer (J-A-S) and winter (J-F-M) products. ASTER GED products are output on 1degree x 1 degree grids at 100-meter or 1-kilometer spatial resolution (nominal) and include the mean emissivity and standard deviation for all 5 ASTER thermal infrared bands, mean land surface temperature (LST) and standard deviation, a re-sampled ASTER GDEM (not included in the North America Winter products), land-water mask, mean Normalized Difference Vegetation Index (NDVI) and standard deviation, latitude, longitude, and observation count. Additional ASTER GED product information is available at https://lpdaac.usgs.gov/products/community_products_table. Product tiles are available in HDF and binary format and may be downloaded via HTTP by visiting the following data clients: NASA Reverb (http://reverb.echo.nasa.gov), LP DAAC Data Pool (http://e4ftl01.cr.usgs.gov/ASTT/), or EarthExplorer (http://earthexplorer.usgs.gov)."
7
- ],
8
- "schema_provider_s": "U.S. Geological Survey, Department of the Interior",
9
- "gbl_resourceClass_sm": ["Imagery"],
10
- "dct_subject_sm": [
11
- "Land surface temperature",
12
- "U.S. Geological survey (USGS)",
13
- "Earth observing system",
14
- "Land processes distributed active archive center (LPDAAC)",
15
- "Aster",
16
- "Normalized difference vegetation index",
17
- "Terra",
18
- "Image map",
19
- "Emissivity"
20
- ],
21
- "dcat_keyword_sm": ["GBL Fixture records"],
22
- "dct_accessRights_s": "Public",
23
- "dct_references_s": "{}",
24
- "id": "aster-global-emissivity-dataset-1-kilometer-v003-ag1kmcad20",
25
- "dct_identifier_sm": ["c0515c4e-97dc-4fff-82cb-f65144482631"],
26
- "gbl_mdModified_dt": "2021-06-01T22:14:16Z",
27
- "gbl_mdVersion_s": "Aardvark"
28
- }
@@ -1,17 +0,0 @@
1
- const MetadataDownloadButton = require("../../app/assets/javascripts/geoblacklight/modules/metadata_download_button")
2
-
3
- describe("MetadataDownloadButton", function () {
4
- describe("initialize", function () {
5
- beforeEach(() => {
6
- document.body.innerHTML =
7
- '<button id="foo" data-ref-endpoint="http://testdomain" data-ref-download="#bar">test element</button><a href="http://testdomain" id="bar">another test element</a>'
8
- })
9
-
10
- it("creates a new instance and sets the download button @href value", function () {
11
- var button = new MetadataDownloadButton("#foo")
12
- expect(button.$el.attr("id")).toBe("foo")
13
- expect(button.$download.attr("id")).toBe("bar")
14
- expect(button.$download.attr("href")).toBe("http://testdomain")
15
- })
16
- })
17
- })
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Geoblacklight::Geometry do
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)" }
10
-
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]")
15
- end
16
- end
17
-
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]")
21
- end
22
- end
23
-
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")
27
- end
28
- end
29
-
30
- context "with a non-polygon geometry" do
31
- before do
32
- allow(RGeo::GeoJSON).to receive(:encode).and_raise(RGeo::Error::InvalidGeometry)
33
- end
34
-
35
- it "returns a default GeoJSON extent" do
36
- expect(described_class.new(non_polygon_geom).geojson).to include("coordinates", "-180.0,90.0")
37
- end
38
- end
39
- end
40
-
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"
45
- end
46
- end
47
-
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"
51
- end
52
- end
53
-
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")
57
- end
58
- end
59
- end
60
- end
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Geoblacklight::ItemViewer do
6
- let(:document) { SolrDocument.new(document_attributes) }
7
- let(:document_attributes) { {} }
8
- let(:references) { document.references }
9
- let(:references_field) { Geoblacklight.configuration.fields.references }
10
- let(:item_viewer) { described_class.new(references) }
11
- describe "viewer_preference" do
12
- describe "for no references" do
13
- it "returns nil" do
14
- expect(item_viewer.viewer_preference).to be_nil
15
- end
16
- end
17
- describe "for wms reference" do
18
- let(:document_attributes) do
19
- {
20
- references_field => {
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"
23
- }.to_json
24
- }
25
- end
26
- it "wms if wms is present" do
27
- expect(item_viewer.viewer_preference).to eq wms: "http://www.example.com/wms"
28
- end
29
- end
30
- describe "for tms reference" do
31
- let(:document_attributes) do
32
- {
33
- references_field => {
34
- "https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification" => "http://www.example.com/tms"
35
- }.to_json
36
- }
37
- end
38
- it "tms if tms is present" do
39
- expect(item_viewer.viewer_preference).to eq tms: "http://www.example.com/tms"
40
- end
41
- end
42
- describe "for iiif only reference" do
43
- let(:document_attributes) do
44
- {
45
- references_field => {
46
- "http://iiif.io/api/image" => "http://www.example.com/iiif"
47
- }.to_json
48
- }
49
- end
50
- it "returns iiif" do
51
- expect(item_viewer.viewer_preference).to eq iiif: "http://www.example.com/iiif"
52
- end
53
- end
54
- describe "for tiled map layer reference" do
55
- let(:document_attributes) do
56
- {
57
- references_field => {
58
- "urn:x-esri:serviceType:ArcGIS#TiledMapLayer" => "http://www.example.com/MapServer"
59
- }.to_json
60
- }
61
- end
62
- it "returns mapservice" do
63
- expect(item_viewer.viewer_preference).to eq tiled_map_layer: "http://www.example.com/MapServer"
64
- end
65
- end
66
- context "index map" do
67
- let(:document_attributes) do
68
- {
69
- references_field => {
70
- "https://openindexmaps.org" => "http://www.example.com/index_map"
71
- }.to_json
72
- }
73
- end
74
- it { expect(item_viewer.viewer_preference).to eq index_map: "http://www.example.com/index_map" }
75
- end
76
- end
77
- 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
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- RSpec.describe Geoblacklight::SolrDocument::Inspection do
6
- subject { SolrDocument.new }
7
-
8
- describe "#inspectable?" do
9
- it "returns true for wms viewer protocol" do
10
- expect(subject).to receive(:viewer_protocol).and_return("wms")
11
- expect(subject.inspectable?).to be_truthy
12
- end
13
-
14
- it "returns false for iiif viewer protocol" do
15
- expect(subject).to receive(:viewer_protocol).and_return("iiif")
16
- expect(subject.inspectable?).to be_falsy
17
- end
18
- end
19
- end