geoblacklight 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +21 -6
- data/.solr_wrapper +1 -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/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 +44 -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/_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.yml +74 -22
- 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 +12 -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 +11 -6
- 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/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 +9 -8
- data/spec/features/tms_spec.rb +6 -5
- data/spec/features/web_services_modal_spec.rb +37 -36
- data/spec/features/wmts_spec.rb +16 -15
- data/spec/features/xyz_spec.rb +6 -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 +2 -2
- 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 +6 -6
- 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 +34 -33
- 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 +29 -212
- 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
@@ -1,17 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::GeojsonDownload do
|
5
|
-
let(:document) { SolrDocument.new(Settings.FIELDS.ID =>
|
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
|
8
|
-
it
|
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
|
12
|
-
expect(options[:request_params][:typeName]).to eq
|
12
|
+
expect(options[:content_type]).to eq "application/json"
|
13
|
+
expect(options[:request_params][:typeName]).to eq "stanford-test"
|
13
14
|
end
|
14
|
-
it
|
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
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::GeotiffDownload do
|
5
|
-
let(:document) { SolrDocument.new(Settings.FIELDS.ID =>
|
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
|
8
|
-
it
|
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
|
12
|
-
expect(options[:request_params][:layers]).to eq
|
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
|
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
|
-
|
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 =>
|
8
|
-
let(:options) {
|
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
|
11
|
-
it
|
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][
|
15
|
-
expect(options[:request_params][
|
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
|
18
|
-
download = described_class.new(document,
|
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
|
25
|
+
describe "#get" do
|
25
26
|
let(:references_field) { Settings.FIELDS.REFERENCES }
|
26
27
|
let(:references_values) do
|
27
28
|
{
|
28
|
-
|
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
|
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(
|
44
|
-
let(:endpoint) {
|
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
|
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
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::KmzDownload do
|
5
|
-
let(:document) { SolrDocument.new(Settings.FIELDS.ID =>
|
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
|
8
|
-
it
|
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
|
12
|
-
expect(options[:request_params][:layers]).to eq
|
13
|
-
expect(options[:request_params][:bbox]).to eq
|
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
|
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
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::ShapefileDownload do
|
5
|
-
let(:document) { SolrDocument.new(Settings.FIELDS.ID =>
|
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
|
8
|
-
it
|
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
|
12
|
-
expect(options[:request_params][:typeName]).to eq
|
12
|
+
expect(options[:content_type]).to eq "application/zip"
|
13
|
+
expect(options[:request_params][:typeName]).to eq "stanford-test"
|
13
14
|
end
|
14
|
-
it
|
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
|
-
|
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}"
|
11
|
-
let(:options) { {
|
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
|
14
|
-
it
|
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
|
20
|
+
describe "#downloadable?" do
|
20
21
|
before do
|
21
22
|
allow(document).to receive(:downloadable?).and_return(true)
|
22
23
|
end
|
23
|
-
it
|
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
|
29
|
-
it
|
30
|
-
expect(download.file_name).to eq
|
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
|
34
|
-
it
|
35
|
-
expect(download.class.file_path).to eq Rails.root.join(
|
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
|
38
|
-
expect(Settings).to receive(:DOWNLOAD_PATH).and_return(
|
39
|
-
expect(download.class.file_path).to eq
|
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
|
43
|
-
it
|
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
|
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
|
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
|
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
|
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:
|
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
|
72
|
-
allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp",
|
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
|
76
|
+
expect(download.get).to eq "test-shapefile.zip"
|
76
77
|
end
|
77
78
|
end
|
78
79
|
end
|
79
|
-
describe
|
80
|
+
describe "#create_download_file" do
|
80
81
|
let(:file) { instance_double(File) }
|
81
|
-
let(:shapefile) { OpenStruct.new(headers: {
|
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
|
92
|
-
allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp",
|
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
|
99
|
-
let(:bad_file) { OpenStruct.new(headers: {
|
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
|
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,
|
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
|
113
|
-
let(:geojson) { OpenStruct.new(headers: {
|
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
|
120
|
-
allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp",
|
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
|
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
|
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:
|
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
|
144
|
-
expect(faraday_connection).to receive(:url_prefix).and_return
|
145
|
-
expect(faraday_connection).to receive(:get).and_raise(Faraday::ConnectionFailed.new(
|
146
|
-
expect(Faraday).to receive(:new).with(url:
|
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
|
151
|
-
expect(faraday_connection).to receive(:url_prefix).and_return
|
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:
|
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
|
158
|
+
describe "#url_with_params" do
|
158
159
|
let(:options) do
|
159
160
|
{
|
160
|
-
service_type:
|
161
|
+
service_type: "wms",
|
161
162
|
request_params: {
|
162
|
-
service:
|
163
|
-
version:
|
164
|
-
request:
|
165
|
-
srsName:
|
166
|
-
outputformat:
|
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
|
173
|
-
expect(download.url_with_params).to eq
|
174
|
-
|
175
|
-
|
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
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::Geometry do
|
5
|
-
let(:wkt_geom) {
|
6
|
-
let(:envelope_geom) {
|
7
|
-
let(:invalid_geom) {
|
8
|
-
let(:non_polygon_geom) {
|
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
|
11
|
-
context
|
12
|
-
it
|
13
|
-
expect(described_class.new(wkt_geom).geojson).to include(
|
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
|
18
|
-
it
|
19
|
-
expect(described_class.new(envelope_geom).geojson).to include(
|
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
|
24
|
-
it
|
25
|
-
expect(described_class.new(invalid_geom).geojson).to include(
|
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
|
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
|
35
|
-
expect(described_class.new(non_polygon_geom).geojson).to include(
|
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
|
41
|
-
context
|
42
|
-
it
|
43
|
-
expect(described_class.new(wkt_geom).bounding_box).to eq
|
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
|
48
|
-
it
|
49
|
-
expect(described_class.new(envelope_geom).bounding_box).to eq
|
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
|
54
|
-
it
|
55
|
-
expect(described_class.new(invalid_geom).bounding_box).to include(
|
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
|
-
|
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
|
11
|
-
describe
|
12
|
-
it
|
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
|
17
|
+
describe "for wms reference" do
|
17
18
|
let(:document_attributes) do
|
18
19
|
{
|
19
20
|
references_field => {
|
20
|
-
|
21
|
-
|
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
|
26
|
-
expect(item_viewer.viewer_preference).to eq 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
|
30
|
+
describe "for tms reference" do
|
30
31
|
let(:document_attributes) do
|
31
32
|
{
|
32
33
|
references_field => {
|
33
|
-
|
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
|
38
|
-
expect(item_viewer.viewer_preference).to eq 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
|
42
|
+
describe "for iiif only reference" do
|
42
43
|
let(:document_attributes) do
|
43
44
|
{
|
44
45
|
references_field => {
|
45
|
-
|
46
|
+
"http://iiif.io/api/image" => "http://www.example.com/iiif"
|
46
47
|
}.to_json
|
47
48
|
}
|
48
49
|
end
|
49
|
-
it
|
50
|
-
expect(item_viewer.viewer_preference).to eq 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
|
54
|
+
describe "for tiled map layer reference" do
|
54
55
|
let(:document_attributes) do
|
55
56
|
{
|
56
57
|
references_field => {
|
57
|
-
|
58
|
+
"urn:x-esri:serviceType:ArcGIS#TiledMapLayer" => "http://www.example.com/MapServer"
|
58
59
|
}.to_json
|
59
60
|
}
|
60
61
|
end
|
61
|
-
it
|
62
|
-
expect(item_viewer.viewer_preference).to eq tiled_map_layer:
|
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
|
66
|
+
context "index map" do
|
66
67
|
let(:document_attributes) do
|
67
68
|
{
|
68
69
|
references_field => {
|
69
|
-
|
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:
|
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
|