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,62 +1,63 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::WmsLayer do
|
5
6
|
let(:wms_layer) { described_class.new(params) }
|
6
|
-
let(:rails_4_params) { {
|
7
|
+
let(:rails_4_params) { {"URL" => "http://www.example.com/", "X" => "277"} }
|
7
8
|
let(:rails_5_params) { instance_double(ActionController::Parameters) }
|
8
9
|
|
9
10
|
before do
|
10
|
-
allow(rails_5_params).to receive(:to_h).and_return(
|
11
|
+
allow(rails_5_params).to receive(:to_h).and_return("URL" => "http://www.example.com/", "X" => "277")
|
11
12
|
end
|
12
13
|
|
13
|
-
describe
|
14
|
+
describe "#initialize" do
|
14
15
|
let(:params) { rails_4_params }
|
15
16
|
|
16
|
-
it
|
17
|
+
it "initializes as a WmsLayer object" do
|
17
18
|
expect(wms_layer).to be_an described_class
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
describe
|
22
|
-
context
|
22
|
+
describe "#url" do
|
23
|
+
context "when running on rails 4" do
|
23
24
|
let(:params) { rails_4_params }
|
24
25
|
|
25
|
-
it
|
26
|
-
expect(wms_layer.url).to eq(
|
26
|
+
it "returns the correct URL parameter" do
|
27
|
+
expect(wms_layer.url).to eq("http://www.example.com/")
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
context
|
31
|
+
context "when running on rails 5" do
|
31
32
|
let(:params) { rails_5_params }
|
32
33
|
|
33
|
-
it
|
34
|
-
expect(wms_layer.url).to eq(
|
34
|
+
it "returns the correct URL parameter" do
|
35
|
+
expect(wms_layer.url).to eq("http://www.example.com/")
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
describe
|
40
|
-
context
|
40
|
+
describe "#search_params" do
|
41
|
+
context "when running on rails 4" do
|
41
42
|
let(:params) { rails_4_params }
|
42
43
|
|
43
|
-
it
|
44
|
+
it "returns all params except URL plus default params" do
|
44
45
|
expect(wms_layer.search_params.length).to eq 8
|
45
|
-
expect(wms_layer.search_params).not_to include
|
46
|
+
expect(wms_layer.search_params).not_to include "URL" => "http://www.example.com/"
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
context
|
50
|
+
context "when running on rails 5" do
|
50
51
|
let(:params) { rails_5_params }
|
51
52
|
|
52
|
-
it
|
53
|
+
it "returns all params except URL plus default params" do
|
53
54
|
expect(wms_layer.search_params.length).to eq 8
|
54
|
-
expect(wms_layer.search_params).not_to include
|
55
|
+
expect(wms_layer.search_params).not_to include "URL" => "http://www.example.com/"
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
|
-
describe
|
60
|
+
describe "#request_response" do
|
60
61
|
subject(:wms_layer) { described_class.new(params) }
|
61
62
|
let(:params) { rails_4_params }
|
62
63
|
let(:connection) { instance_double(Faraday::Connection) }
|
@@ -66,34 +67,34 @@ describe Geoblacklight::WmsLayer do
|
|
66
67
|
allow(Faraday).to receive(:new).and_return(connection)
|
67
68
|
end
|
68
69
|
|
69
|
-
it
|
70
|
+
it "returns a Faraday object" do
|
70
71
|
allow(connection).to receive(:get).and_return(response)
|
71
72
|
expect(wms_layer.request_response).to eq(response)
|
72
73
|
end
|
73
74
|
|
74
|
-
context
|
75
|
+
context "when the HTTP connection fails" do
|
75
76
|
before do
|
76
|
-
allow(Geoblacklight.logger).to receive(:error).with(
|
77
|
-
allow(connection).to receive(:get).and_raise(Faraday::ConnectionFailed.new(StandardError.new(
|
77
|
+
allow(Geoblacklight.logger).to receive(:error).with("#<Faraday::ConnectionFailed wrapped=#<StandardError: test connection error>>")
|
78
|
+
allow(connection).to receive(:get).and_raise(Faraday::ConnectionFailed.new(StandardError.new("test connection error")))
|
78
79
|
end
|
79
80
|
|
80
|
-
it
|
81
|
+
it "logs the Faraday error" do
|
81
82
|
expect(Geoblacklight.logger).to receive(:error).exactly(3).times
|
82
83
|
expect(wms_layer.request_response).to be_a Hash
|
83
|
-
expect(wms_layer.request_response).to include(error:
|
84
|
+
expect(wms_layer.request_response).to include(error: "#<Faraday::ConnectionFailed wrapped=#<StandardError: test connection error>>")
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
context
|
88
|
+
context "when the HTTP connection times out" do
|
88
89
|
before do
|
89
|
-
allow(Geoblacklight.logger).to receive(:error).with(
|
90
|
+
allow(Geoblacklight.logger).to receive(:error).with("#<Faraday::TimeoutError #<Faraday::TimeoutError: timeout>>")
|
90
91
|
allow(connection).to receive(:get).and_raise(Faraday::TimeoutError)
|
91
92
|
end
|
92
93
|
|
93
|
-
it
|
94
|
+
it "logs the Faraday error" do
|
94
95
|
expect(Geoblacklight.logger).to receive(:error).exactly(3).times
|
95
96
|
expect(wms_layer.request_response).to be_a Hash
|
96
|
-
expect(wms_layer.request_response).to include(error:
|
97
|
+
expect(wms_layer.request_response).to include(error: "#<Faraday::TimeoutError #<Faraday::TimeoutError: timeout>>")
|
97
98
|
end
|
98
99
|
end
|
99
100
|
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
RSpec.describe Geoblacklight::BboxFilterField do
|
6
|
-
subject(:filter) { search_state.filter(
|
6
|
+
subject(:filter) { search_state.filter("bbox") }
|
7
7
|
|
8
|
-
let(:bbox_value) {
|
8
|
+
let(:bbox_value) { "140.143709 -65.487905 160.793791 86.107541" }
|
9
9
|
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, blacklight_config, controller) }
|
10
10
|
let(:params) { {} }
|
11
11
|
let(:blacklight_config) do
|
12
12
|
Blacklight::Configuration.new.configure do |config|
|
13
|
-
config.add_facet_field
|
13
|
+
config.add_facet_field "bbox", filter_class: described_class
|
14
14
|
end
|
15
15
|
end
|
16
|
-
let(:facet_config) { blacklight_config.facet_fields[
|
16
|
+
let(:facet_config) { blacklight_config.facet_fields["bbox"] }
|
17
17
|
let(:controller) { double }
|
18
18
|
|
19
|
-
describe
|
20
|
-
context
|
21
|
-
it
|
19
|
+
describe "#add" do
|
20
|
+
context "with a ordinary parameter" do
|
21
|
+
it "adds the parameter to the facets" do
|
22
22
|
new_state = filter.add(bbox_value)
|
23
23
|
|
24
24
|
expect(new_state.params).to include bbox: bbox_value
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context
|
29
|
-
it
|
28
|
+
context "with a bounding box" do
|
29
|
+
it "adds the parameter to the bbox parameter" do
|
30
30
|
new_state = filter.add(Geoblacklight::BoundingBox.from_rectangle(bbox_value))
|
31
31
|
|
32
32
|
expect(new_state.params).to include bbox: bbox_value
|
@@ -34,61 +34,61 @@ RSpec.describe Geoblacklight::BboxFilterField do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
context
|
38
|
-
let(:params) { {
|
37
|
+
context "with some existing data" do
|
38
|
+
let(:params) { {bbox: bbox_value} }
|
39
39
|
|
40
|
-
describe
|
41
|
-
let(:bbox_replacement) {
|
42
|
-
it
|
40
|
+
describe "#add" do
|
41
|
+
let(:bbox_replacement) { "100.143709 -70.487905 100.793791 96.107541" }
|
42
|
+
it "replaces the existing range" do
|
43
43
|
new_state = filter.add(Geoblacklight::BoundingBox.from_rectangle(bbox_replacement))
|
44
44
|
|
45
45
|
expect(new_state.params).to include bbox: bbox_replacement
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe
|
50
|
-
it
|
49
|
+
describe "#remove" do
|
50
|
+
it "removes the existing bbox" do
|
51
51
|
new_state = filter.remove(Geoblacklight::BoundingBox.from_rectangle(bbox_value))
|
52
52
|
|
53
53
|
expect(new_state.params[:bbox]).to be_nil
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe
|
58
|
-
it
|
57
|
+
describe "#values" do
|
58
|
+
it "converts the parameters to a Geoblacklight::BoundingBox" do
|
59
59
|
expect(filter.values.first).to be_a(Geoblacklight::BoundingBox).and(have_attributes(to_param: bbox_value))
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
describe
|
64
|
-
it
|
63
|
+
describe "#needs_normalization?" do
|
64
|
+
it "returns false for the expected keyed representation of the bounding box" do
|
65
65
|
expect(filter.needs_normalization?(search_state.params)).to be false
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
context
|
69
|
+
context "when array param represented by facebook as a Hash" do
|
70
70
|
let(:filter) { described_class.new(facet_config, search_state) }
|
71
|
-
let(:params) { {
|
71
|
+
let(:params) { {bbox: {"0" => bbox_value}} }
|
72
72
|
|
73
|
-
describe
|
74
|
-
it
|
73
|
+
describe "#normalize" do
|
74
|
+
it "converts the parameters to a list" do
|
75
75
|
expect(filter.normalize(search_state.params[:bbox])).to eql [bbox_value]
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
80
|
-
it
|
79
|
+
describe "#needs_normalization?" do
|
80
|
+
it "returns true for the hash-as-array keyed representation of the bounding box" do
|
81
81
|
expect(filter.needs_normalization?(search_state.params[:bbox])).to be true
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
context
|
88
|
-
let(:params) { {
|
87
|
+
context "with a malformed bbox" do
|
88
|
+
let(:params) { {bbox: "totally-not-a-bbox"} }
|
89
89
|
|
90
|
-
it
|
91
|
-
filter = search_state.filter(
|
90
|
+
it "excludes it from the values" do
|
91
|
+
filter = search_state.filter("bbox")
|
92
92
|
|
93
93
|
expect(filter.values).to be_empty
|
94
94
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
RSpec.describe Geoblacklight::BboxFilterQuery do
|
6
6
|
# Subject
|
@@ -12,94 +12,94 @@ RSpec.describe Geoblacklight::BboxFilterQuery do
|
|
12
12
|
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, blacklight_config) }
|
13
13
|
|
14
14
|
let(:params) do
|
15
|
-
{
|
15
|
+
{bbox: "-180 -80 120 80"}
|
16
16
|
end
|
17
17
|
|
18
18
|
let(:blacklight_config) do
|
19
19
|
Blacklight::Configuration.new.configure do |config|
|
20
|
-
config.add_facet_field
|
20
|
+
config.add_facet_field "bbox", filter_class: Geoblacklight::BboxFilterField
|
21
21
|
end
|
22
22
|
end
|
23
|
-
let(:facet_config) { blacklight_config.facet_fields[
|
23
|
+
let(:facet_config) { blacklight_config.facet_fields["bbox"] }
|
24
24
|
|
25
25
|
# Filter
|
26
26
|
let(:filter) { Geoblacklight::BboxFilterField.new(facet_config, search_state) }
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
28
|
+
describe "#initialize" do
|
29
|
+
it "initializes as a BboxFilterQuery object" do
|
30
30
|
expect(bbox_filter_query).to be_a described_class
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
it
|
36
|
-
expect(bbox_filter_query.envelope_bounds).to eq(
|
34
|
+
describe "#envelope_bounds" do
|
35
|
+
it "returns an BoundingBox envelope" do
|
36
|
+
expect(bbox_filter_query.envelope_bounds).to eq("ENVELOPE(-180, 120, 80, -80)")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
41
|
-
context
|
40
|
+
describe "#boost" do
|
41
|
+
context "without an explicit boost" do
|
42
42
|
before do
|
43
43
|
facet_config.within_boost = nil
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
47
|
-
expect(bbox_filter_query.boost).to eq(
|
46
|
+
it "returns an default boost value" do
|
47
|
+
expect(bbox_filter_query.boost).to eq("^10")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
context
|
51
|
+
context "with an explicit boost" do
|
52
52
|
before do
|
53
53
|
facet_config.within_boost = 99
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
57
|
-
expect(bbox_filter_query.boost).to eq(
|
56
|
+
it "applies boost based on configured Settings.BBOX_WITHIN_BOOST" do
|
57
|
+
expect(bbox_filter_query.boost).to eq("^99")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
describe
|
63
|
-
it
|
64
|
-
expect(bbox_filter_query.relevancy_boost[:bq].to_s).to include(
|
62
|
+
describe "#relevancy_boost" do
|
63
|
+
it "returns a relevancy_boost" do
|
64
|
+
expect(bbox_filter_query.relevancy_boost[:bq].to_s).to include("IsWithin")
|
65
65
|
end
|
66
66
|
|
67
|
-
context
|
67
|
+
context "with overlap boost" do
|
68
68
|
before do
|
69
69
|
facet_config.overlap_boost = 2
|
70
70
|
end
|
71
71
|
|
72
|
-
it
|
73
|
-
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include(
|
72
|
+
it "applies overlapRatio when Settings.OVERLAP_RATIO_BOOST is configured" do
|
73
|
+
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include("$overlap^2")
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
context
|
77
|
+
context "without an overlap boost" do
|
78
78
|
before do
|
79
79
|
facet_config.overlap_boost = nil
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
82
|
+
it "does not apply overlapRatio when Settings.OVERLAP_RATIO_BOOST not configured" do
|
83
83
|
expect(bbox_filter_query.relevancy_boost).not_to have_key(:overlap)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
context
|
87
|
+
context "when local boost parameter is present" do
|
88
88
|
before do
|
89
|
-
solr_params[:bf] = [
|
89
|
+
solr_params[:bf] = ["local_boost^5"]
|
90
90
|
facet_config.overlap_boost = 2
|
91
91
|
end
|
92
92
|
|
93
|
-
it
|
94
|
-
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include(
|
95
|
-
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include(
|
93
|
+
it "appends overlap and includes the local boost" do
|
94
|
+
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include("$overlap^2")
|
95
|
+
expect(bbox_filter_query.relevancy_boost[:bf].to_s).to include("local_boost^5")
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
describe
|
101
|
-
it
|
102
|
-
expect(bbox_filter_query.intersects_filter).to include(
|
100
|
+
describe "#intersects_filter" do
|
101
|
+
it "returns an Intersects query" do
|
102
|
+
expect(bbox_filter_query.intersects_filter).to include("Intersects")
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -1,42 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
class MyDocument
|
6
|
+
extend Blacklight::Solr::Document
|
7
|
+
include Geoblacklight::SolrDocument::Carto
|
8
|
+
end
|
3
9
|
|
4
10
|
describe Geoblacklight::SolrDocument::Carto do
|
5
11
|
let(:document) { MyDocument.new }
|
6
12
|
let(:geojson_download) { instance_double(Geoblacklight::GeojsonDownload) }
|
7
13
|
|
8
14
|
before do
|
9
|
-
class MyDocument
|
10
|
-
extend Blacklight::Solr::Document
|
11
|
-
include Geoblacklight::SolrDocument::Carto
|
12
|
-
end
|
13
|
-
|
14
15
|
allow(Geoblacklight::GeojsonDownload).to receive(:new).and_return(geojson_download)
|
15
16
|
end
|
16
17
|
|
17
|
-
describe
|
18
|
-
it
|
18
|
+
describe "#carto_reference" do
|
19
|
+
it "returns nil for restricted documents" do
|
19
20
|
expect(document).to receive(:public?).and_return(false)
|
20
21
|
expect(document.carto_reference).to be_nil
|
21
22
|
end
|
22
|
-
it
|
23
|
+
it "returns nil for no download_types" do
|
23
24
|
expect(document).to receive(:public?).and_return(true)
|
24
25
|
expect(document).to receive(:download_types).and_return(nil)
|
25
26
|
expect(document.carto_reference).to be_nil
|
26
27
|
end
|
27
|
-
it
|
28
|
+
it "returns nil with no :geojson download type" do
|
28
29
|
expect(document).to receive(:public?).and_return(true)
|
29
|
-
expect(document).to receive(:download_types).and_return(geotiff:
|
30
|
+
expect(document).to receive(:download_types).and_return(geotiff: "geotiff")
|
30
31
|
expect(document.carto_reference).to be_nil
|
31
32
|
end
|
32
|
-
it
|
33
|
+
it "Creates and returns a GeojsonDownload url" do
|
33
34
|
expect(document).to receive(:public?).and_return(true)
|
34
35
|
expect(document).to receive(:download_types)
|
35
|
-
.and_return(geojson: {
|
36
|
+
.and_return(geojson: {"stuff" => "stuff"})
|
36
37
|
expect(geojson_download)
|
37
38
|
.to receive(:url_with_params)
|
38
|
-
.and_return(
|
39
|
-
expect(document.carto_reference).to eq
|
39
|
+
.and_return("http://www.example.com/geojsonDownload")
|
40
|
+
expect(document.carto_reference).to eq "http://www.example.com/geojsonDownload"
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::SolrDocument::Citation do
|
5
|
-
describe
|
6
|
-
let(:fixture) { JSON.parse(read_fixture(
|
6
|
+
describe "#geoblacklight_citation" do
|
7
|
+
let(:fixture) { JSON.parse(read_fixture("solr_documents/restricted-line.json")) }
|
7
8
|
let(:document) { SolrDocument.new(fixture) }
|
8
9
|
|
9
|
-
it
|
10
|
-
expect(document.geoblacklight_citation(
|
11
|
-
.to eq
|
10
|
+
it "creates a citation" do
|
11
|
+
expect(document.geoblacklight_citation("http://example.com"))
|
12
|
+
.to eq "United States. National Oceanic and Atmospheric Administration. Circuit Rider Productions. (2002). 10 Meter Contours: Russian River Basin, California. [Shapefile]. Circuit Rider Productions. Retrieved from http://example.com"
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -1,40 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
class MyDocument
|
6
|
+
extend Blacklight::Solr::Document
|
7
|
+
include Geoblacklight::SolrDocument::Finder
|
8
|
+
end
|
3
9
|
|
4
10
|
describe Geoblacklight::SolrDocument::Finder do
|
5
11
|
let(:document_klass) { MyDocument }
|
6
12
|
|
7
|
-
|
8
|
-
|
9
|
-
extend Blacklight::Solr::Document
|
10
|
-
include Geoblacklight::SolrDocument::Finder
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#find' do
|
15
|
-
let(:documents) { ['first', 'second'] }
|
13
|
+
describe "#find" do
|
14
|
+
let(:documents) { ["first", "second"] }
|
16
15
|
let(:response) { instance_double(Blacklight::Solr::Response) }
|
17
16
|
|
18
17
|
before do
|
19
18
|
allow(response).to receive(:documents).and_return(documents)
|
20
|
-
allow_any_instance_of(Blacklight::Solr::Repository).to receive(:find).with(
|
19
|
+
allow_any_instance_of(Blacklight::Solr::Repository).to receive(:find).with("search param").and_return(response)
|
21
20
|
end
|
22
21
|
|
23
|
-
it
|
24
|
-
expect(document_klass.find(
|
22
|
+
it "calls index and returns first document" do
|
23
|
+
expect(document_klass.find("search param")).to eq "first"
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
|
-
describe
|
29
|
-
it
|
27
|
+
describe "#index" do
|
28
|
+
it "creates and returns a Blacklight::Solr::Repository" do
|
30
29
|
expect(document_klass.index).to be_a Blacklight::Solr::Repository
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
describe
|
33
|
+
describe ".blacklight_solr" do
|
35
34
|
let(:document) { document_klass.new }
|
36
35
|
|
37
|
-
it
|
36
|
+
it "accesses the connection to the Solr index" do
|
38
37
|
expect(document.blacklight_solr).to be_a RSolr::Client
|
39
38
|
end
|
40
39
|
end
|
@@ -1,17 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::SolrDocument::Inspection do
|
5
6
|
subject { SolrDocument.new }
|
6
7
|
|
7
|
-
describe
|
8
|
-
it
|
9
|
-
expect(subject).to receive(:viewer_protocol).and_return(
|
8
|
+
describe "#inspectable?" do
|
9
|
+
it "returns true for wms viewer protocol" do
|
10
|
+
expect(subject).to receive(:viewer_protocol).and_return("wms")
|
10
11
|
expect(subject.inspectable?).to be_truthy
|
11
12
|
end
|
12
13
|
|
13
|
-
it
|
14
|
-
expect(subject).to receive(:viewer_protocol).and_return(
|
14
|
+
it "returns false for iiif viewer protocol" do
|
15
|
+
expect(subject).to receive(:viewer_protocol).and_return("iiif")
|
15
16
|
expect(subject.inspectable?).to be_falsy
|
16
17
|
end
|
17
18
|
end
|