geoblacklight 4.0.0 → 4.1.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +23 -8
- data/.gitignore +3 -0
- data/.standard.yml +1 -0
- data/Gemfile +13 -11
- data/README.md +1 -1
- data/Rakefile +42 -50
- data/app/assets/images/blacklight/american-geographical-society-library-uwm-libraries.svg +26 -0
- data/app/assets/images/blacklight/arizona.svg +4 -0
- data/app/assets/images/blacklight/circle-info-solid.svg +1 -0
- data/app/assets/images/blacklight/fire-solid.svg +1 -0
- data/app/assets/images/blacklight/lightbulb-solid.svg +1 -0
- data/app/assets/images/blacklight/nebraska.svg +4 -0
- data/app/assets/images/blacklight/rutgers.svg +5 -0
- data/app/assets/images/blacklight/triangle-exclamation-solid.svg +1 -0
- data/app/assets/javascripts/geoblacklight/basemaps.js +1 -1
- data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +8 -0
- data/app/components/geoblacklight/display_note_component.html.erb +1 -0
- data/app/components/geoblacklight/display_note_component.rb +47 -0
- data/app/components/geoblacklight/icon_facet_item_component.rb +2 -2
- data/app/controllers/download_controller.rb +36 -37
- data/app/controllers/relation_controller.rb +1 -0
- data/app/controllers/wms_controller.rb +1 -0
- data/app/helpers/arcgis_helper.rb +2 -1
- data/app/helpers/blacklight_helper.rb +2 -1
- data/app/helpers/carto_helper.rb +3 -2
- data/app/helpers/geoblacklight/geoblacklight_helper_behavior.rb +2 -1
- data/app/helpers/geoblacklight_helper.rb +47 -36
- data/app/models/concerns/geoblacklight/bbox_filter_query.rb +1 -1
- data/app/models/concerns/geoblacklight/solr_document/arcgis.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document/carto.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document/citation.rb +3 -2
- data/app/models/concerns/geoblacklight/solr_document/finder.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document/inspection.rb +1 -0
- data/app/models/concerns/geoblacklight/solr_document.rb +17 -9
- data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +2 -1
- data/app/presenters/geoblacklight/document_presenter.rb +3 -2
- data/app/views/catalog/_citation.html.erb +35 -10
- data/app/views/catalog/_show_default_display_note.html.erb +7 -0
- data/app/views/catalog/_show_sidebar.html.erb +1 -0
- data/app/views/catalog/_show_sidebar_static_map.html.erb +10 -0
- data/app/views/relation/index.json.jbuilder +1 -1
- data/config/initializers/new_gbl_settings_defaults_4.1.yml +104 -0
- data/config/initializers/rails_config.rb +5 -1
- data/config/locales/geoblacklight.en.yml +18 -10
- data/geoblacklight.gemspec +36 -40
- data/lib/generators/geoblacklight/assets_generator.rb +15 -15
- data/lib/generators/geoblacklight/install_generator.rb +24 -23
- data/lib/generators/geoblacklight/templates/catalog_controller.rb +66 -71
- data/lib/generators/geoblacklight/templates/settings.gbl_v1.yml +2 -2
- data/lib/generators/geoblacklight/templates/settings.yml +76 -24
- data/lib/geoblacklight/bounding_box.rb +1 -0
- data/lib/geoblacklight/constants.rb +26 -25
- data/lib/geoblacklight/download/geojson_download.rb +10 -9
- data/lib/geoblacklight/download/geotiff_download.rb +6 -5
- data/lib/geoblacklight/download/hgl_download.rb +4 -3
- data/lib/geoblacklight/download/kmz_download.rb +11 -10
- data/lib/geoblacklight/download/shapefile_download.rb +10 -9
- data/lib/geoblacklight/download.rb +12 -11
- data/lib/geoblacklight/engine.rb +10 -9
- data/lib/geoblacklight/exceptions.rb +3 -0
- data/lib/geoblacklight/faraday_middleware/follow_redirects.rb +14 -11
- data/lib/geoblacklight/geometry.rb +6 -5
- data/lib/geoblacklight/item_viewer.rb +4 -3
- data/lib/geoblacklight/metadata/base.rb +4 -3
- data/lib/geoblacklight/metadata/fgdc.rb +1 -0
- data/lib/geoblacklight/metadata/html.rb +5 -4
- data/lib/geoblacklight/metadata/iso19139.rb +1 -0
- data/lib/geoblacklight/metadata.rb +1 -0
- data/lib/geoblacklight/metadata_transformer/base.rb +5 -4
- data/lib/geoblacklight/metadata_transformer/fgdc.rb +1 -0
- data/lib/geoblacklight/metadata_transformer/iso19139.rb +1 -0
- data/lib/geoblacklight/metadata_transformer.rb +6 -2
- data/lib/geoblacklight/reference.rb +3 -2
- data/lib/geoblacklight/references.rb +12 -7
- data/lib/geoblacklight/relation/ancestors.rb +4 -3
- data/lib/geoblacklight/relation/descendants.rb +4 -3
- data/lib/geoblacklight/relation/relation_response.rb +3 -2
- data/lib/geoblacklight/routes/downloadable.rb +3 -2
- data/lib/geoblacklight/routes/exportable.rb +4 -3
- data/lib/geoblacklight/routes/wms.rb +2 -1
- data/lib/geoblacklight/routes.rb +4 -3
- data/lib/geoblacklight/version.rb +2 -1
- data/lib/geoblacklight/view_helper_override.rb +3 -2
- data/lib/geoblacklight/wms_layer/feature_info_response.rb +5 -4
- data/lib/geoblacklight/wms_layer.rb +4 -3
- data/lib/geoblacklight.rb +32 -31
- data/lib/tasks/geoblacklight.rake +45 -44
- data/schema/geoblacklight-schema-aardvark.json +6 -0
- data/spec/components/geoblacklight/display_note_component_spec.rb +27 -0
- data/spec/components/geoblacklight/homepage_feature_facet_component_spec.rb +11 -10
- data/spec/components/geoblacklight/icon_facet_item_component_spec.rb +8 -7
- data/spec/config/initializers/rails_config_spec.rb +10 -9
- data/spec/controllers/catalog_controller_spec.rb +27 -26
- data/spec/controllers/download_controller_spec.rb +50 -49
- data/spec/controllers/relation_controller_spec.rb +5 -4
- data/spec/controllers/wms_controller_spec.rb +10 -9
- data/spec/factories/user.rb +3 -2
- data/spec/features/bookmarks_spec.rb +7 -6
- data/spec/features/citations_spec.rb +12 -0
- data/spec/features/configurable_basemap_spec.rb +12 -11
- data/spec/features/data_dictionary_download_spec.rb +11 -10
- data/spec/features/download_layer_spec.rb +64 -63
- data/spec/features/empty_search_spec.rb +6 -5
- data/spec/features/esri_viewer_spec.rb +33 -32
- data/spec/features/exports_spec.rb +18 -17
- data/spec/features/full_screen_controll_spec.rb +8 -8
- data/spec/features/help_text_spec.rb +6 -5
- data/spec/features/home_page_spec.rb +30 -29
- data/spec/features/iiif_viewer_spec.rb +6 -5
- data/spec/features/index_map_spec.rb +17 -16
- data/spec/features/layer_inspection_spec.rb +8 -7
- data/spec/features/layer_opacity_spec.rb +15 -14
- data/spec/features/layer_preview_spec.rb +11 -10
- data/spec/features/layer_with_no_references_spec.rb +5 -4
- data/spec/features/linkified_attribute_table_spec.rb +8 -7
- data/spec/features/metadata_panel_spec.rb +32 -31
- data/spec/features/missing_metadata_spec.rb +18 -17
- data/spec/features/multiple_downloads_spec.rb +11 -10
- data/spec/features/oembed_spec.rb +6 -5
- data/spec/features/relations_spec.rb +51 -26
- data/spec/features/saved_searches_spec.rb +7 -6
- data/spec/features/search_bar_spec.rb +9 -8
- data/spec/features/search_results_complex_geometry_spec.rb +12 -11
- data/spec/features/search_results_icons_spec.rb +10 -9
- data/spec/features/search_results_map_spec.rb +21 -20
- data/spec/features/search_results_overlap_ratio_spec.rb +17 -16
- data/spec/features/search_spec.rb +19 -18
- data/spec/features/show_page_download_spec.rb +15 -14
- data/spec/features/show_page_metadata_spec.rb +9 -8
- data/spec/features/show_page_sidebar_static_map_spec.rb +21 -0
- data/spec/features/sms_spec.rb +12 -11
- data/spec/features/split_view.html.erb_spec.rb +56 -55
- data/spec/features/suppressed_records_spec.rb +10 -9
- data/spec/features/tilejson_spec.rb +12 -9
- data/spec/features/tms_spec.rb +6 -5
- data/spec/features/web_services_modal_spec.rb +39 -38
- data/spec/features/wmts_spec.rb +20 -17
- data/spec/features/xyz_spec.rb +6 -5
- data/spec/fixtures/manifests/tilejson.json +1 -1
- data/spec/fixtures/manifests/wmts-single.xml +5 -5
- data/spec/fixtures/solr_documents/actual-papermap1.json +1 -1
- data/spec/fixtures/solr_documents/actual-point1.json +1 -1
- data/spec/fixtures/solr_documents/actual-polygon1.json +1 -1
- data/spec/fixtures/solr_documents/actual-raster1.json +1 -1
- data/spec/fixtures/solr_documents/baruch_ancestor1.json +1 -1
- data/spec/fixtures/solr_documents/baruch_ancestor2.json +1 -1
- data/spec/fixtures/solr_documents/baruch_documentation_download.json +2 -2
- data/spec/fixtures/solr_documents/cornell_html_metadata.json +1 -1
- data/spec/fixtures/solr_documents/display-note.json +52 -0
- data/spec/fixtures/solr_documents/esri-dynamic-layer-all-layers.json +1 -1
- data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-feature-layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-image-map-layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +1 -1
- data/spec/fixtures/solr_documents/esri-wms-layer.json +1 -1
- data/spec/fixtures/solr_documents/harvard_raster.json +1 -1
- data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +1 -1
- data/spec/fixtures/solr_documents/index-map-polygon-no-downloadurl.json +1 -1
- data/spec/fixtures/solr_documents/index-map-polygon.json +1 -1
- data/spec/fixtures/solr_documents/index-map-stanford.json +1 -1
- data/spec/fixtures/solr_documents/index_map_point.json +1 -1
- data/spec/fixtures/solr_documents/princeton-parent.json +1 -1
- data/spec/fixtures/solr_documents/public_direct_download.json +1 -1
- data/spec/fixtures/solr_documents/public_iiif_princeton.json +1 -1
- data/spec/fixtures/solr_documents/restricted-line.json +1 -1
- data/spec/fixtures/solr_documents/tilejson.json +3 -3
- data/spec/fixtures/solr_documents/umn_metro_result1.json +2 -2
- data/spec/fixtures/solr_documents/umn_state_result1.json +1 -1
- data/spec/fixtures/solr_documents/umn_state_result2.json +1 -1
- data/spec/fixtures/solr_documents/uva_slug_colon.json +1 -1
- data/spec/fixtures/solr_documents/wmts-multiple.json +1 -1
- data/spec/fixtures/solr_documents/wmts-single-layer.json +7 -7
- data/spec/fixtures/solr_documents/xyz.json +3 -3
- data/spec/helpers/arcgis_helper_spec.rb +8 -7
- data/spec/helpers/carto_helper_spec.rb +6 -5
- data/spec/helpers/geoblacklight/geoblacklight_helper_behavior_spec.rb +10 -15
- data/spec/helpers/geoblacklight_helper_spec.rb +139 -138
- data/spec/lib/geoblacklight/bounding_box_spec.rb +14 -13
- data/spec/lib/geoblacklight/document_presenter_spec.rb +26 -25
- data/spec/lib/geoblacklight/download/geojson_download_spec.rb +8 -7
- data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +8 -7
- data/spec/lib/geoblacklight/download/hgl_download_spec.rb +16 -15
- data/spec/lib/geoblacklight/download/kmz_download_spec.rb +9 -8
- data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +8 -7
- data/spec/lib/geoblacklight/download_spec.rb +61 -60
- data/spec/lib/geoblacklight/geometry_spec.rb +29 -28
- data/spec/lib/geoblacklight/item_viewer_spec.rb +25 -24
- data/spec/lib/geoblacklight/metadata/base_spec.rb +44 -43
- data/spec/lib/geoblacklight/metadata/html_spec.rb +7 -6
- data/spec/lib/geoblacklight/metadata_spec.rb +15 -14
- data/spec/lib/geoblacklight/metadata_transformer/base_spec.rb +13 -12
- data/spec/lib/geoblacklight/metadata_transformer/fgdc_spec.rb +8 -7
- data/spec/lib/geoblacklight/metadata_transformer/iso19139_spec.rb +8 -7
- data/spec/lib/geoblacklight/metadata_transformer_spec.rb +15 -14
- data/spec/lib/geoblacklight/reference_spec.rb +28 -27
- data/spec/lib/geoblacklight/references_spec.rb +89 -76
- data/spec/lib/geoblacklight/relation/ancestors_spec.rb +17 -16
- data/spec/lib/geoblacklight/relation/descendants_spec.rb +17 -16
- data/spec/lib/geoblacklight/relation/relation_response_spec.rb +29 -28
- data/spec/lib/geoblacklight/view_helper_override_spec.rb +14 -13
- data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +19 -18
- data/spec/lib/geoblacklight/wms_layer_spec.rb +31 -30
- data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +31 -31
- data/spec/models/concerns/geoblacklight/bbox_filter_query_spec.rb +32 -32
- data/spec/models/concerns/geoblacklight/solr_document/carto_spec.rb +16 -15
- data/spec/models/concerns/geoblacklight/solr_document/citation_spec.rb +7 -6
- data/spec/models/concerns/geoblacklight/solr_document/finder_spec.rb +16 -17
- data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +7 -6
- data/spec/models/concerns/geoblacklight/solr_document_spec.rb +121 -107
- data/spec/models/concerns/geoblacklight/suppressed_records_search_behavior_spec.rb +8 -7
- data/spec/presenters/geoblacklight/bbox_item_presenter_spec.rb +10 -10
- data/spec/routing/catalog_routing_spec.rb +4 -3
- data/spec/spec_helper.rb +35 -38
- data/spec/support/backport_test_helpers.rb +6 -5
- data/spec/support/features/session_helpers.rb +8 -7
- data/spec/support/features.rb +2 -1
- data/spec/support/fixtures.rb +2 -1
- data/spec/tasks/geoblacklight_spec.rb +10 -9
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +16 -15
- data/spec/views/catalog/_document_split.html.erb_spec.rb +3 -2
- data/spec/views/catalog/_index_split.html.erb_spec.rb +3 -2
- data/spec/views/catalog/_results_pagination.html.erb_spec.rb +5 -4
- data/spec/views/catalog/_show_downloads.html.erb_spec.rb +11 -10
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +13 -12
- data/template.rb +9 -8
- metadata +40 -216
- data/.gitmodules +0 -0
- data/.rubocop.yml +0 -111
- data/.rubocop_todo.yml +0 -437
- data/config/initializers/new_gbl_settings_defaults_3_4.yml +0 -6
- /data/app/assets/images/blacklight/{berkeley.svg → university-of-california-berkeley.svg} +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::Metadata::Base do
|
5
6
|
subject(:metadata) { described_class.new(reference) }
|
@@ -7,22 +8,22 @@ describe Geoblacklight::Metadata::Base do
|
|
7
8
|
let(:connection) { instance_double(Faraday::Connection) }
|
8
9
|
let(:response) { instance_double(Faraday::Response) }
|
9
10
|
let(:reference) do
|
10
|
-
Geoblacklight::Reference.new([
|
11
|
+
Geoblacklight::Reference.new(["http://www.loc.gov/mods/v3", "http://purl.stanford.edu/cg357zz0321.mods"])
|
11
12
|
end
|
12
13
|
|
13
14
|
before do
|
14
|
-
allow(Faraday).to receive(:new).with(url:
|
15
|
+
allow(Faraday).to receive(:new).with(url: "http://purl.stanford.edu/cg357zz0321.mods").and_return(connection)
|
15
16
|
end
|
16
17
|
|
17
|
-
describe
|
18
|
-
context
|
18
|
+
describe "#document" do
|
19
|
+
context "with valid XML data at an endpoint URL" do
|
19
20
|
before do
|
20
21
|
allow(response).to receive(:status).and_return(200)
|
21
|
-
allow(response).to receive(:body).and_return(
|
22
|
+
allow(response).to receive(:body).and_return("<test>data</test>")
|
22
23
|
allow(connection).to receive(:get).and_return(response)
|
23
24
|
end
|
24
25
|
|
25
|
-
it
|
26
|
+
it "returns an XML Document containing the payload from an endpoint url" do
|
26
27
|
expect(metadata.document).to be_a Nokogiri::XML::Document
|
27
28
|
end
|
28
29
|
end
|
@@ -30,100 +31,100 @@ describe Geoblacklight::Metadata::Base do
|
|
30
31
|
context "when there's a redirect" do
|
31
32
|
before do
|
32
33
|
allow(Faraday).to receive(:new).and_call_original
|
33
|
-
WebMock.disable_net_connect!(allow_localhost: true, allow:
|
34
|
-
stub_request(:get,
|
35
|
-
stub_request(:get,
|
34
|
+
WebMock.disable_net_connect!(allow_localhost: true, allow: "chromedriver.storage.googleapis.com")
|
35
|
+
stub_request(:get, "http://purl.stanford.edu/cg357zz0321.mods").to_return(status: 301, headers: {location: "https://purl.stanford.edu/cg357zz0321.mods"})
|
36
|
+
stub_request(:get, "https://purl.stanford.edu/cg357zz0321.mods").to_return(status: 200, headers: {"content-type" => "application/xml"}, body: "<test>data</test>")
|
36
37
|
end
|
37
38
|
|
38
39
|
after do
|
39
40
|
WebMock.allow_net_connect!(net_http_connect_on_start: true)
|
40
41
|
end
|
41
42
|
|
42
|
-
it
|
43
|
+
it "follows the redirect" do
|
43
44
|
expect(metadata.document).to be_a Nokogiri::XML::Document
|
44
|
-
expect(metadata.document.text).to eq
|
45
|
+
expect(metadata.document.text).to eq "data"
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
context
|
49
|
+
context "when attempts to connect to an endpoint URL fail" do
|
49
50
|
subject { metadata.document }
|
50
51
|
|
51
52
|
before do
|
52
|
-
allow(connection).to receive(:get).and_raise(Faraday::ConnectionFailed,
|
53
|
+
allow(connection).to receive(:get).and_raise(Faraday::ConnectionFailed, "test connection failures")
|
53
54
|
end
|
54
55
|
|
55
|
-
it
|
56
|
+
it "returns nil when a connection error" do
|
56
57
|
expect(subject).to be_a Nokogiri::XML::Document
|
57
58
|
expect(subject.children.empty?).to be true
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
|
-
context
|
63
|
+
context "when attempts to connect to an endpoint URL raise an OpenSSL error" do
|
63
64
|
subject { metadata.document }
|
64
65
|
|
65
66
|
before do
|
66
67
|
expect(Geoblacklight.logger).to receive(:error).with(/dh key too small/)
|
67
|
-
allow(connection).to receive(:get).and_raise(OpenSSL::SSL::SSLError,
|
68
|
+
allow(connection).to receive(:get).and_raise(OpenSSL::SSL::SSLError, "dh key too small")
|
68
69
|
end
|
69
70
|
|
70
|
-
it
|
71
|
+
it "returns nil when a connection error" do
|
71
72
|
expect(subject).to be_a Nokogiri::XML::Document
|
72
73
|
expect(subject.children.empty?).to be true
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
|
-
describe
|
77
|
+
describe "#blank?" do
|
77
78
|
before do
|
78
|
-
allow(Faraday).to receive(:new).with(url:
|
79
|
+
allow(Faraday).to receive(:new).with(url: "http://purl.stanford.edu/cg357zz0321.mods").and_return(connection)
|
79
80
|
end
|
80
81
|
|
81
|
-
context
|
82
|
+
context "with valid XML data at an endpoint URL" do
|
82
83
|
before do
|
83
84
|
allow(response).to receive(:status).and_return(200)
|
84
|
-
allow(response).to receive(:body).and_return(
|
85
|
+
allow(response).to receive(:body).and_return("<test>data</test>")
|
85
86
|
allow(connection).to receive(:get).and_return(response)
|
86
87
|
end
|
87
88
|
|
88
|
-
it
|
89
|
+
it "returns false" do
|
89
90
|
expect(metadata.blank?).to be false
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
|
-
context
|
94
|
+
context "when attempts to connect to an endpoint URL fail" do
|
94
95
|
before do
|
95
|
-
allow(connection).to receive(:get).and_raise(Faraday::ConnectionFailed,
|
96
|
+
allow(connection).to receive(:get).and_raise(Faraday::ConnectionFailed, "test connection failures")
|
96
97
|
end
|
97
98
|
|
98
|
-
it
|
99
|
+
it "returns true" do
|
99
100
|
expect(metadata.blank?).to be true
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
|
-
describe
|
105
|
+
describe "#endpoint" do
|
105
106
|
before do
|
106
|
-
allow(Faraday).to receive(:new).with(url:
|
107
|
+
allow(Faraday).to receive(:new).with(url: "http://purl.stanford.edu/cg357zz0321.mods").and_return(connection)
|
107
108
|
allow(response).to receive(:status).and_return(200)
|
108
|
-
allow(response).to receive(:body).and_return(
|
109
|
+
allow(response).to receive(:body).and_return("<test>data</test>")
|
109
110
|
allow(connection).to receive(:get).and_return(response)
|
110
111
|
end
|
111
112
|
|
112
|
-
it
|
113
|
-
expect(metadata.endpoint).to eq
|
113
|
+
it "returns the URI" do
|
114
|
+
expect(metadata.endpoint).to eq "http://purl.stanford.edu/cg357zz0321.mods"
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
|
-
describe
|
118
|
-
let(:ns) {
|
119
|
-
let(:url) {
|
118
|
+
describe "#to_html" do
|
119
|
+
let(:ns) { "http://www.opengis.net/cat/csw/csdgm" }
|
120
|
+
let(:url) { "https://raw.githubusercontent.com/OpenGeoMetadata/edu.tufts/master/165/242/110/132/fgdc.xml" }
|
120
121
|
let(:reference) do
|
121
122
|
Geoblacklight::Reference.new([ns, url])
|
122
123
|
end
|
123
124
|
let(:connection) { instance_double(Faraday::Connection) }
|
124
125
|
let(:response) { instance_double(Faraday::Response) }
|
125
126
|
let(:geocombine_metadata) { instance_double(GeoCombine::Iso19139) }
|
126
|
-
let(:html) {
|
127
|
+
let(:html) { "<!DOCTYPE html><html></html>" }
|
127
128
|
let(:status) { 200 }
|
128
129
|
|
129
130
|
before do
|
@@ -137,22 +138,22 @@ describe Geoblacklight::Metadata::Base do
|
|
137
138
|
allow(response).to receive(:body).and_return('<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE metadata SYSTEM "http://www.fgdc.gov/metadata/fgdc-std-001-1998.dtd"><metadata></metadata>')
|
138
139
|
end
|
139
140
|
|
140
|
-
it
|
141
|
+
it "retrieves the metadata and transforms it into the HTML" do
|
141
142
|
allow(geocombine_metadata).to receive(:to_html).and_return(html)
|
142
143
|
allow(connection).to receive(:get).and_return(response)
|
143
144
|
|
144
145
|
expect(metadata.to_html).to eq html
|
145
146
|
end
|
146
147
|
|
147
|
-
context
|
148
|
+
context "when the metadata resource cannot be found" do
|
148
149
|
let(:status) { 404 }
|
149
150
|
|
150
151
|
before do
|
151
152
|
allow(Geoblacklight.logger).to receive(:error).with("Could not reach #{url}")
|
152
153
|
end
|
153
154
|
|
154
|
-
it
|
155
|
-
allow(geocombine_metadata).to receive(:to_html).and_return(
|
155
|
+
it "logs an error and returns an empty String" do
|
156
|
+
allow(geocombine_metadata).to receive(:to_html).and_return("")
|
156
157
|
allow(connection).to receive(:get).and_return(response)
|
157
158
|
|
158
159
|
expect(Geoblacklight.logger).to receive(:error)
|
@@ -160,14 +161,14 @@ describe Geoblacklight::Metadata::Base do
|
|
160
161
|
end
|
161
162
|
end
|
162
163
|
|
163
|
-
context
|
164
|
+
context "when requesting the metadata resource times out" do
|
164
165
|
before do
|
165
|
-
allow(geocombine_metadata).to receive(:to_html).and_return(
|
166
|
+
allow(geocombine_metadata).to receive(:to_html).and_return("")
|
166
167
|
allow(connection).to receive(:get).and_raise(Faraday::TimeoutError)
|
167
|
-
allow(Geoblacklight.logger).to receive(:error).with(
|
168
|
+
allow(Geoblacklight.logger).to receive(:error).with("#<Faraday::TimeoutError #<Faraday::TimeoutError: timeout>>")
|
168
169
|
end
|
169
170
|
|
170
|
-
it
|
171
|
+
it "logs an error and returns an empty String" do
|
171
172
|
expect(Geoblacklight.logger).to receive(:error)
|
172
173
|
expect(metadata.to_html).to be_empty
|
173
174
|
end
|
@@ -1,19 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::Metadata::Html do
|
5
|
-
let(:url) {
|
6
|
+
let(:url) { "https://s3.amazonaws.com/cugir-data/00/77/41/fgdc.html" }
|
6
7
|
let(:metadata) do
|
7
8
|
described_class.new(
|
8
9
|
Geoblacklight::Reference.new(
|
9
|
-
[
|
10
|
+
["http://www.w3.org/1999/xhtml", url]
|
10
11
|
)
|
11
12
|
)
|
12
13
|
end
|
13
14
|
|
14
|
-
describe
|
15
|
-
it
|
16
|
-
expect(metadata.transform).to include(
|
15
|
+
describe "#transform" do
|
16
|
+
it "renders an iframe with the html endpoint" do
|
17
|
+
expect(metadata.transform).to include("iframe", url)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -1,41 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::Metadata do
|
5
|
-
describe
|
6
|
+
describe ".instance" do
|
6
7
|
let(:reference) { instance_double(Geoblacklight::Reference) }
|
7
|
-
context
|
8
|
+
context "with an FGDC metadata reference" do
|
8
9
|
before do
|
9
|
-
allow(reference).to receive(:type).and_return(
|
10
|
+
allow(reference).to receive(:type).and_return("fgdc")
|
10
11
|
end
|
11
|
-
it
|
12
|
+
it "constructs an Geoblacklight::Metadata::Fgdc instance" do
|
12
13
|
expect(described_class.instance(reference)).to be_a Geoblacklight::Metadata::Fgdc
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
context
|
17
|
+
context "with an ISO19139 metadata reference" do
|
17
18
|
before do
|
18
|
-
allow(reference).to receive(:type).and_return(
|
19
|
+
allow(reference).to receive(:type).and_return("iso19139")
|
19
20
|
end
|
20
|
-
it
|
21
|
+
it "constructs an Geoblacklight::Metadata::Iso19139 instance" do
|
21
22
|
expect(described_class.instance(reference)).to be_a Geoblacklight::Metadata::Iso19139
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
context
|
26
|
+
context "with an html metadata reference" do
|
26
27
|
before do
|
27
|
-
allow(reference).to receive(:type).and_return(
|
28
|
+
allow(reference).to receive(:type).and_return("html")
|
28
29
|
end
|
29
|
-
it
|
30
|
+
it "constructs an Geoblacklight::Metadata::Html instance" do
|
30
31
|
expect(described_class.instance(reference)).to be_a Geoblacklight::Metadata::Html
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
context
|
35
|
+
context "with another metadata reference" do
|
35
36
|
before do
|
36
|
-
allow(reference).to receive(:type).and_return(
|
37
|
+
allow(reference).to receive(:type).and_return("unsupported")
|
37
38
|
end
|
38
|
-
it
|
39
|
+
it "constructs an Geoblacklight::Metadata::Base instance" do
|
39
40
|
expect(described_class.instance(reference)).to be_a Geoblacklight::Metadata::Base
|
40
41
|
end
|
41
42
|
end
|
@@ -1,35 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::MetadataTransformer::Base do
|
5
|
-
describe
|
6
|
-
it
|
6
|
+
describe ".new" do
|
7
|
+
it "raises an error for empty XML" do
|
7
8
|
expect { described_class.new(nil) }.to raise_error Geoblacklight::MetadataTransformer::EmptyMetadataError
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
11
|
-
context
|
12
|
+
context "with metadata types without XSL Stylesheets" do
|
12
13
|
subject { described_class.new(metadata) }
|
13
14
|
let(:metadata) { instance_double(GeoCombine::Metadata) }
|
14
|
-
describe
|
15
|
+
describe "#transform" do
|
15
16
|
before do
|
16
|
-
allow(metadata).to receive(:to_html).and_raise(NoMethodError,
|
17
|
+
allow(metadata).to receive(:to_html).and_raise(NoMethodError, "undefined method `to_html'")
|
17
18
|
end
|
18
|
-
it
|
19
|
+
it "raises a transform error" do
|
19
20
|
expect { subject.transform }.to raise_error Geoblacklight::MetadataTransformer::TransformError, /undefined method `to_html'/
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
context
|
25
|
+
context "with metadata types with XSL Stylesheets but invalid HTML" do
|
25
26
|
subject { described_class.new(metadata) }
|
26
27
|
let(:metadata) { instance_double(GeoCombine::Metadata) }
|
27
|
-
describe
|
28
|
+
describe "#transform" do
|
28
29
|
before do
|
29
|
-
allow(metadata).to receive(:to_html).and_return(
|
30
|
+
allow(metadata).to receive(:to_html).and_return("<invalid-html></invalid-html>")
|
30
31
|
end
|
31
|
-
it
|
32
|
-
expect { subject.transform }.to raise_error Geoblacklight::MetadataTransformer::TransformError,
|
32
|
+
it "raises a transform error" do
|
33
|
+
expect { subject.transform }.to raise_error Geoblacklight::MetadataTransformer::TransformError, "Failed to extract the <body> child elements from the transformed metadata"
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
@@ -1,24 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::MetadataTransformer::Fgdc do
|
5
6
|
subject do
|
6
7
|
described_class.new(metadata)
|
7
8
|
end
|
8
|
-
let(:fgdc_html) { File.read(Rails.root.join(
|
9
|
+
let(:fgdc_html) { File.read(Rails.root.join("spec", "fixtures", "metadata", "fgdc.html")) }
|
9
10
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Fgdc) }
|
10
11
|
|
11
|
-
describe
|
12
|
+
describe "#transform" do
|
12
13
|
before do
|
13
14
|
allow(metadata).to receive(:blank?).and_return(false)
|
14
15
|
allow(metadata).to receive(:to_html).and_return(fgdc_html)
|
15
16
|
end
|
16
17
|
|
17
|
-
it
|
18
|
+
it "transforms FGDC Documents in the XML into the HTML" do
|
18
19
|
transformed = Nokogiri::XML.fragment(subject.transform)
|
19
|
-
expect(transformed.at_xpath(
|
20
|
-
expect(transformed.at_xpath(
|
21
|
-
expect(transformed.at_xpath(
|
20
|
+
expect(transformed.at_xpath(".//h1").text.strip).to eq("Custom Link Sample")
|
21
|
+
expect(transformed.at_xpath(".//div/dl/dd/dl/dd/dl/dt").text).to eq("Originator")
|
22
|
+
expect(transformed.at_xpath(".//div/dl/dd/dl/dd/dl/dd").text.strip).to eq("Esri")
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,24 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::MetadataTransformer::Iso19139 do
|
5
6
|
subject do
|
6
7
|
described_class.new(metadata)
|
7
8
|
end
|
8
|
-
let(:iso_html) { File.read(Rails.root.join(
|
9
|
+
let(:iso_html) { File.read(Rails.root.join("spec", "fixtures", "metadata", "iso.html")) }
|
9
10
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Iso19139) }
|
10
11
|
|
11
|
-
describe
|
12
|
+
describe "#transform" do
|
12
13
|
before do
|
13
14
|
expect(metadata).to receive(:blank?).and_return(false)
|
14
15
|
expect(metadata).to receive(:to_html).and_return(iso_html)
|
15
16
|
end
|
16
17
|
|
17
|
-
it
|
18
|
+
it "transforms ISO19139 Documents in the XML into the HTML" do
|
18
19
|
transformed = Nokogiri::XML.fragment(subject.transform)
|
19
|
-
expect(transformed.at_xpath(
|
20
|
-
expect(transformed.at_xpath(
|
21
|
-
expect(transformed.at_xpath(
|
20
|
+
expect(transformed.at_xpath(".//h1").text.strip).to eq("Abandoned Mine Land Inventory Polygons: Pennsylvania, 2016")
|
21
|
+
expect(transformed.at_xpath("(.//div)[1]/dl/dd/dl/dd/dl/dt").text).to eq("Title")
|
22
|
+
expect(transformed.at_xpath("(.//div)[1]/dl/dd/dl/dd/dl/dd").text.strip).to eq("Abandoned Mine Land Inventory Polygons: Pennsylvania, 2016")
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::MetadataTransformer do
|
5
6
|
let(:klass) { instance_double(Class) }
|
@@ -8,60 +9,60 @@ describe Geoblacklight::MetadataTransformer do
|
|
8
9
|
allow(metadata).to receive(:class).and_return(klass)
|
9
10
|
end
|
10
11
|
|
11
|
-
describe
|
12
|
-
context
|
12
|
+
describe ".instance" do
|
13
|
+
context "with FGDC metadata" do
|
13
14
|
subject do
|
14
15
|
described_class.instance(metadata)
|
15
16
|
end
|
16
17
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Fgdc) }
|
17
18
|
|
18
19
|
before do
|
19
|
-
allow(klass).to receive(:name).and_return(
|
20
|
+
allow(klass).to receive(:name).and_return("Geoblacklight::Metadata::Fgdc")
|
20
21
|
end
|
21
22
|
|
22
|
-
it
|
23
|
+
it "initializes a Fgdc Object" do
|
23
24
|
expect(subject).to be_a Geoblacklight::MetadataTransformer::Fgdc
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
context
|
28
|
+
context "with ISO19139 metadata" do
|
28
29
|
subject do
|
29
30
|
described_class.instance(metadata)
|
30
31
|
end
|
31
32
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Iso19139) }
|
32
33
|
|
33
34
|
before do
|
34
|
-
allow(klass).to receive(:name).and_return(
|
35
|
+
allow(klass).to receive(:name).and_return("Geoblacklight::Metadata::Iso19139")
|
35
36
|
end
|
36
37
|
|
37
|
-
it
|
38
|
+
it "initializes a Iso19139 Object" do
|
38
39
|
expect(subject).to be_a Geoblacklight::MetadataTransformer::Iso19139
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
context
|
43
|
+
context "without a metadata type" do
|
43
44
|
subject do
|
44
45
|
described_class.instance(metadata)
|
45
46
|
end
|
46
47
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Base) }
|
47
48
|
|
48
49
|
before do
|
49
|
-
allow(klass).to receive(:name).and_return(
|
50
|
+
allow(klass).to receive(:name).and_return("Geoblacklight::Metadata::Base")
|
50
51
|
end
|
51
52
|
|
52
|
-
it
|
53
|
+
it "defaults to the BaseTransformer Class" do
|
53
54
|
expect(subject).to be_a Geoblacklight::MetadataTransformer::Base
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
|
-
context
|
58
|
+
context "with an invalid metadata type" do
|
58
59
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Base) }
|
59
60
|
|
60
61
|
before do
|
61
|
-
allow(klass).to receive(:name).and_return(
|
62
|
+
allow(klass).to receive(:name).and_return("Geoblacklight::Metadata::Invalid")
|
62
63
|
end
|
63
64
|
|
64
|
-
it
|
65
|
+
it "raises a TypeError" do
|
65
66
|
expect { described_class.instance(metadata) }.to \
|
66
67
|
raise_error Geoblacklight::MetadataTransformer::TypeError, /Metadata type .+ is not supported/
|
67
68
|
end
|
@@ -1,64 +1,65 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::Reference do
|
5
6
|
let(:typical_reference) do
|
6
|
-
described_class.new([
|
7
|
+
described_class.new(["http://www.opengis.net/def/serviceType/ogc/wms", "http://hgl.harvard.edu:8080/geoserver/wms"])
|
7
8
|
end
|
8
9
|
let(:blank_reference) do
|
9
10
|
described_class.new([])
|
10
11
|
end
|
11
|
-
describe
|
12
|
-
it
|
13
|
-
expect(typical_reference.instance_variable_get(:@reference)).to eq [
|
12
|
+
describe "#initialize" do
|
13
|
+
it "instance variable reference is set" do
|
14
|
+
expect(typical_reference.instance_variable_get(:@reference)).to eq ["http://www.opengis.net/def/serviceType/ogc/wms", "http://hgl.harvard.edu:8080/geoserver/wms"]
|
14
15
|
end
|
15
16
|
end
|
16
|
-
describe
|
17
|
-
it
|
18
|
-
expect(typical_reference.endpoint).to eq
|
17
|
+
describe "#endpoint" do
|
18
|
+
it "returns the endpoint url for a reference" do
|
19
|
+
expect(typical_reference.endpoint).to eq "http://hgl.harvard.edu:8080/geoserver/wms"
|
19
20
|
end
|
20
|
-
it
|
21
|
+
it "returns nil for a blank reference" do
|
21
22
|
expect(blank_reference.endpoint).to be_nil
|
22
23
|
end
|
23
24
|
end
|
24
|
-
describe
|
25
|
-
it
|
25
|
+
describe "#type" do
|
26
|
+
it "looks up a constant using the uri" do
|
26
27
|
expect(typical_reference.type).to eq :wms
|
27
28
|
expect(blank_reference.type).to be_nil
|
28
29
|
end
|
29
30
|
end
|
30
|
-
describe
|
31
|
-
it
|
32
|
-
expect(typical_reference.to_hash).to eq wms:
|
31
|
+
describe "#to_hash" do
|
32
|
+
it "creates a hash using type and endpoint" do
|
33
|
+
expect(typical_reference.to_hash).to eq wms: "http://hgl.harvard.edu:8080/geoserver/wms"
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
describe
|
37
|
-
context
|
37
|
+
describe "reference" do
|
38
|
+
context "key has one trailing slash" do
|
38
39
|
let(:iso19139_reference) do
|
39
|
-
described_class.new([
|
40
|
+
described_class.new(["http://www.isotc211.org/schemas/2005/gmd/", "https://raw.githubusercontent.com/OpenGeoMetadata/edu.stanford.purl/master/cg/357/zz/0321/iso19139.xml"])
|
40
41
|
end
|
41
42
|
|
42
|
-
it
|
43
|
-
expect(iso19139_reference.send(:uri)).to eq
|
43
|
+
it "removes the trailing slash" do
|
44
|
+
expect(iso19139_reference.send(:uri)).to eq "http://www.isotc211.org/schemas/2005/gmd"
|
44
45
|
end
|
45
46
|
end
|
46
|
-
context
|
47
|
+
context "key does not have trailing slashes" do
|
47
48
|
let(:iso19139_reference) do
|
48
|
-
described_class.new([
|
49
|
+
described_class.new(["http://www.isotc211.org/schemas/2005/gmd", "https://raw.githubusercontent.com/OpenGeoMetadata/edu.stanford.purl/master/cg/357/zz/0321/iso19139.xml"])
|
49
50
|
end
|
50
51
|
|
51
|
-
it
|
52
|
-
expect(iso19139_reference.send(:uri)).to eq
|
52
|
+
it "will return the key" do
|
53
|
+
expect(iso19139_reference.send(:uri)).to eq "http://www.isotc211.org/schemas/2005/gmd"
|
53
54
|
end
|
54
55
|
end
|
55
|
-
context
|
56
|
+
context "key has trailing slashes" do
|
56
57
|
let(:fgdc_reference) do
|
57
|
-
described_class.new([
|
58
|
+
described_class.new(["http://www.opengis.net/cat/csw/csdgm////", "https://raw.githubusercontent.com/OpenGeoMetadata/edu.harvard/master/217/121/227/77/fgdc.xml"])
|
58
59
|
end
|
59
60
|
|
60
|
-
it
|
61
|
-
expect(fgdc_reference.send(:uri)).to eq
|
61
|
+
it "removes the trailing slashes" do
|
62
|
+
expect(fgdc_reference.send(:uri)).to eq "http://www.opengis.net/cat/csw/csdgm"
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|