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,261 +1,262 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe GeoblacklightHelper, type: :helper do
|
5
6
|
include BlacklightHelper
|
6
7
|
include ActionView::Helpers::UrlHelper
|
7
8
|
include ActionView::Helpers::TranslationHelper
|
8
9
|
|
9
|
-
describe
|
10
|
-
it
|
10
|
+
describe "#geoblacklight_icon" do
|
11
|
+
it "supports in use cases" do
|
11
12
|
{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
"Paper map" => "paper-map",
|
14
|
+
"Michigan State" => "michigan-state",
|
15
|
+
"CD ROM" => "cd-rom",
|
16
|
+
"Lewis & Clark" => "lewis-clark"
|
16
17
|
}.each_key do |key|
|
17
18
|
html = Capybara.string(geoblacklight_icon(key))
|
18
19
|
expect(html).to have_xpath "//*[local-name() = 'svg']"
|
19
20
|
end
|
20
21
|
end
|
21
|
-
it
|
22
|
+
it "handles nil values" do
|
22
23
|
html = Capybara.string(geoblacklight_icon(nil))
|
23
|
-
expect(html).to have_css
|
24
|
+
expect(html).to have_css ".icon-missing"
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
describe
|
28
|
-
it
|
29
|
-
expect(proper_case_format(
|
28
|
+
describe "#proper_case_format" do
|
29
|
+
it "returns a properly cased format" do
|
30
|
+
expect(proper_case_format("GEOJSON")).to eq "GeoJSON"
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
describe
|
34
|
-
it
|
35
|
-
expect(download_text(
|
34
|
+
describe "#download_text" do
|
35
|
+
it "returns download text concatenated with proper case format" do
|
36
|
+
expect(download_text("GEOJSON")).to eq "Original GeoJSON"
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
describe
|
40
|
-
it
|
41
|
-
expect(download_text(
|
40
|
+
describe "#download_text" do
|
41
|
+
it "returns download text concatenated with proper case format" do
|
42
|
+
expect(download_text("GEOJSON")).to eq "Original GeoJSON"
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
describe
|
46
|
-
let(:label) {
|
47
|
-
let(:id) {
|
48
|
-
let(:url) {
|
46
|
+
describe "#download_link_file" do
|
47
|
+
let(:label) { "Test Link Text" }
|
48
|
+
let(:id) { "test-id" }
|
49
|
+
let(:url) { "http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip" }
|
49
50
|
|
50
|
-
it
|
51
|
+
it "generates a link to download the original file" do
|
51
52
|
expect(download_link_file(label, id, url)).to eq '<a contentUrl="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip" data-download="trigger" data-download-type="direct" data-download-id="test-id" href="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip">Test Link Text</a>'
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
describe
|
56
|
-
let(:text) {
|
56
|
+
describe "#download_link_hgl" do
|
57
|
+
let(:text) { "Test Link Text" }
|
57
58
|
let(:document) { instance_double(SolrDocument) }
|
58
59
|
|
59
60
|
before do
|
60
|
-
allow(document).to receive(:id).and_return(
|
61
|
-
allow(document).to receive(:to_s).and_return(
|
61
|
+
allow(document).to receive(:id).and_return("test-id")
|
62
|
+
allow(document).to receive(:to_s).and_return("test-id")
|
62
63
|
end
|
63
64
|
|
64
|
-
it
|
65
|
+
it "generates a link to the HGL route" do
|
65
66
|
expect(download_link_hgl(text, document)).to eq '<a data-blacklight-modal="trigger" data-download="trigger" data-download-type="harvard-hgl" data-download-id="test-id" href="/download/hgl/test-id">Test Link Text</a>'
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
69
|
-
describe
|
70
|
+
describe "#download_link_iiif" do
|
70
71
|
let(:references_field) { Settings.FIELDS.REFERENCES }
|
71
72
|
let(:document_attributes) do
|
72
73
|
{
|
73
74
|
references_field => {
|
74
|
-
|
75
|
+
"http://iiif.io/api/image" => "https://example.edu/image/info.json"
|
75
76
|
}.to_json
|
76
77
|
}
|
77
78
|
end
|
78
79
|
let(:document) { SolrDocument.new(document_attributes) }
|
79
80
|
|
80
81
|
before do
|
81
|
-
allow_any_instance_of(Geoblacklight::Reference).to receive(:to_hash).and_return(iiif:
|
82
|
+
allow_any_instance_of(Geoblacklight::Reference).to receive(:to_hash).and_return(iiif: "https://example.edu/image/info.json")
|
82
83
|
end
|
83
84
|
|
84
|
-
it
|
85
|
+
it "generates a link to download the JPG file from the IIIF server" do
|
85
86
|
assign(:document, document)
|
86
87
|
expect(helper.download_link_iiif).to eq '<a contentUrl="https://example.edu/image/full/full/0/default.jpg" data-download="trigger" href="https://example.edu/image/full/full/0/default.jpg">Original JPG</a>'
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
|
-
describe
|
91
|
-
let(:download_type) {
|
91
|
+
describe "#download_link_generated" do
|
92
|
+
let(:download_type) { "SHAPEFILE" }
|
92
93
|
let(:document) { instance_double(SolrDocument) }
|
93
94
|
|
94
95
|
before do
|
95
|
-
allow(document).to receive(:id).and_return(
|
96
|
-
allow(document).to receive(:to_s).and_return(
|
96
|
+
allow(document).to receive(:id).and_return("test-id")
|
97
|
+
allow(document).to receive(:to_s).and_return("test-id")
|
97
98
|
end
|
98
99
|
|
99
|
-
it
|
100
|
+
it "generates a link to download the JPG file from the IIIF server" do
|
100
101
|
# Stub I18n to ensure the link can be customized via `export_` labels.
|
101
102
|
allow(helper).to receive(:t).and_call_original
|
102
|
-
allow(helper).to receive(:t).with(
|
103
|
+
allow(helper).to receive(:t).with("geoblacklight.download.export_shapefile_link").and_return("Shapefile Export Customization")
|
103
104
|
expect(helper.download_link_generated(download_type, document)).to eq '<a data-download-path="/download/test-id?type=SHAPEFILE" data-download="trigger" data-download-type="SHAPEFILE" data-download-id="test-id" href="">Export Shapefile Export Customization</a>'
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
107
|
-
describe
|
108
|
+
describe "#geoblacklight_basemap" do
|
108
109
|
let(:blacklight_config) { double }
|
109
|
-
it
|
110
|
+
it "without configuration" do
|
110
111
|
expect(blacklight_config).to receive(:basemap_provider).and_return(nil)
|
111
|
-
expect(geoblacklight_basemap).to eq
|
112
|
+
expect(geoblacklight_basemap).to eq "positron"
|
112
113
|
end
|
113
|
-
it
|
114
|
-
expect(blacklight_config).to receive(:basemap_provider).and_return(
|
115
|
-
expect(geoblacklight_basemap).to eq
|
114
|
+
it "with custom configuration" do
|
115
|
+
expect(blacklight_config).to receive(:basemap_provider).and_return("positron")
|
116
|
+
expect(geoblacklight_basemap).to eq "positron"
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
119
|
-
describe
|
120
|
+
describe "#iiif_jpg_url" do
|
120
121
|
let(:document) { SolrDocument.new(document_attributes) }
|
121
122
|
let(:references_field) { Settings.FIELDS.REFERENCES }
|
122
123
|
let(:document_attributes) do
|
123
124
|
{
|
124
125
|
references_field => {
|
125
|
-
|
126
|
+
"http://iiif.io/api/image" => "https://example.edu/image/info.json"
|
126
127
|
}.to_json
|
127
128
|
}
|
128
129
|
end
|
129
130
|
|
130
|
-
it
|
131
|
+
it "returns JPG download URL when given URL to a IIIF info.json" do
|
131
132
|
assign(:document, document)
|
132
|
-
expect(helper.iiif_jpg_url).to eq
|
133
|
+
expect(helper.iiif_jpg_url).to eq "https://example.edu/image/full/full/0/default.jpg"
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
136
|
-
describe
|
137
|
+
describe "#snippit" do
|
137
138
|
let(:document) { SolrDocument.new(document_attributes) }
|
138
139
|
let(:references_field) { Settings.FIELDS.REFERENCES }
|
139
|
-
context
|
140
|
+
context "as a String" do
|
140
141
|
let(:document_attributes) do
|
141
142
|
{
|
142
|
-
value:
|
143
|
-
|
144
|
-
|
143
|
+
value: "This is a really long string that should get truncated when it gets rendered" \
|
144
|
+
"in the index view to give a brief description of the contents of a particular document" \
|
145
|
+
"indexed into Solr"
|
145
146
|
}
|
146
147
|
end
|
147
|
-
it
|
148
|
+
it "truncates longer strings to 150 characters" do
|
148
149
|
expect(helper.snippit(document).length).to eq 150
|
149
150
|
end
|
150
|
-
it
|
151
|
-
expect(helper.snippit(document)[-3
|
151
|
+
it "truncated string ends with ..." do
|
152
|
+
expect(helper.snippit(document)[-3..]).to eq "..."
|
152
153
|
end
|
153
154
|
end
|
154
|
-
context
|
155
|
+
context "as an Array" do
|
155
156
|
let(:document_attributes) do
|
156
157
|
{
|
157
|
-
value: [
|
158
|
-
|
159
|
-
|
158
|
+
value: ["This is a really long string that should get truncated when it gets rendered" \
|
159
|
+
"in the index view to give a brief description of the contents of a particular document" \
|
160
|
+
"indexed into Solr"]
|
160
161
|
}
|
161
162
|
end
|
162
|
-
it
|
163
|
+
it "truncates longer strings to 150 characters" do
|
163
164
|
expect(helper.snippit(document).length).to eq 150
|
164
165
|
end
|
165
|
-
it
|
166
|
-
expect(helper.snippit(document)[-3
|
166
|
+
it "truncated string ends with ..." do
|
167
|
+
expect(helper.snippit(document)[-3..]).to eq "..."
|
167
168
|
end
|
168
169
|
end
|
169
|
-
context
|
170
|
+
context "as a multivalued Array" do
|
170
171
|
let(:document_attributes) do
|
171
172
|
{
|
172
173
|
value: %w[short description]
|
173
174
|
}
|
174
175
|
end
|
175
|
-
it
|
176
|
-
expect(helper.snippit(document)).to eq
|
176
|
+
it "uses both values" do
|
177
|
+
expect(helper.snippit(document)).to eq "short description"
|
177
178
|
end
|
178
|
-
it
|
179
|
-
expect(helper.snippit(document)[-3
|
179
|
+
it "does not truncate" do
|
180
|
+
expect(helper.snippit(document)[-3..]).not_to eq "..."
|
180
181
|
end
|
181
182
|
end
|
182
183
|
end
|
183
184
|
|
184
|
-
describe
|
185
|
-
let(:reference) { instance_double(Geoblacklight::Reference, type:
|
186
|
-
it
|
185
|
+
describe "#render_web_services" do
|
186
|
+
let(:reference) { instance_double(Geoblacklight::Reference, type: "wms") }
|
187
|
+
it "with a reference to a defined partial" do
|
187
188
|
expect(helper).to receive(:render)
|
188
|
-
.with(partial:
|
189
|
+
.with(partial: "web_services_wms", locals: {reference: reference})
|
189
190
|
helper.render_web_services(reference)
|
190
191
|
end
|
191
|
-
context
|
192
|
-
let(:reference) { instance_double(Geoblacklight::Reference, type:
|
192
|
+
context "when the partial is missing" do
|
193
|
+
let(:reference) { instance_double(Geoblacklight::Reference, type: "iiif") }
|
193
194
|
|
194
|
-
it
|
195
|
+
it "with a reference to a missing partial" do
|
195
196
|
expect(helper).to receive(:render)
|
196
|
-
.with(partial:
|
197
|
-
.and_raise ActionView::MissingTemplate.new({},
|
197
|
+
.with(partial: "web_services_iiif", locals: {reference: reference})
|
198
|
+
.and_raise ActionView::MissingTemplate.new({}, "", "", "", "")
|
198
199
|
expect(helper).to receive(:render)
|
199
|
-
.with(partial:
|
200
|
+
.with(partial: "web_services_default", locals: {reference: reference})
|
200
201
|
helper.render_web_services(reference)
|
201
202
|
end
|
202
203
|
end
|
203
204
|
end
|
204
205
|
|
205
|
-
describe
|
206
|
-
it
|
206
|
+
describe "#leaflet_options" do
|
207
|
+
it "returns a hash of options for leaflet" do
|
207
208
|
expect(leaflet_options[:VIEWERS][:WMS][:CONTROLS]).to eq(%w[Opacity Fullscreen])
|
208
209
|
end
|
209
210
|
end
|
210
211
|
|
211
|
-
describe
|
212
|
-
context
|
212
|
+
describe "#render_value_as_truncate_abstract" do
|
213
|
+
context "with multiple values" do
|
213
214
|
let(:document) { SolrDocument.new(value: %w[short description]) }
|
214
|
-
it
|
215
|
+
it "wraps in correct DIV class" do
|
215
216
|
expect(helper.render_value_as_truncate_abstract(document)).to eq '<div class="truncate-abstract">short description</div>'
|
216
217
|
end
|
217
218
|
end
|
218
219
|
end
|
219
220
|
|
220
|
-
describe
|
221
|
+
describe "#render_transformed_metadata" do
|
221
222
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Base) }
|
222
|
-
context
|
223
|
+
context "with valid XML data" do
|
223
224
|
before do
|
224
|
-
allow(metadata).to receive(:transform).and_return(
|
225
|
+
allow(metadata).to receive(:transform).and_return("<div>test</div>")
|
225
226
|
end
|
226
227
|
|
227
|
-
it
|
228
|
+
it "renders the partial with metadata content" do
|
228
229
|
expect(helper).to receive(:render)
|
229
|
-
.with(partial:
|
230
|
+
.with(partial: "catalog/metadata/content", locals: {content: "<div>test</div>"})
|
230
231
|
helper.render_transformed_metadata(metadata)
|
231
232
|
end
|
232
233
|
end
|
233
234
|
|
234
|
-
context
|
235
|
+
context "with valid XML data without an HTML transform" do
|
235
236
|
before do
|
236
237
|
allow(metadata).to receive(:transform).and_raise(Geoblacklight::MetadataTransformer::TransformError)
|
237
|
-
allow(metadata).to receive(:to_xml).and_return(
|
238
|
+
allow(metadata).to receive(:to_xml).and_return("<data></data>")
|
238
239
|
end
|
239
240
|
|
240
|
-
it
|
241
|
-
expect(helper).to receive(:render).with(partial:
|
241
|
+
it "renders the partial with metadata content" do
|
242
|
+
expect(helper).to receive(:render).with(partial: "catalog/metadata/markup", locals: {content: "<data></data>"})
|
242
243
|
helper.render_transformed_metadata(metadata)
|
243
244
|
end
|
244
245
|
end
|
245
246
|
|
246
|
-
context
|
247
|
+
context "without XML data" do
|
247
248
|
before do
|
248
249
|
allow(metadata).to receive(:transform).and_raise(Geoblacklight::MetadataTransformer::ParseError)
|
249
250
|
end
|
250
251
|
|
251
|
-
it
|
252
|
-
expect(helper).to receive(:render).with(partial:
|
252
|
+
it "renders the partial with metadata content" do
|
253
|
+
expect(helper).to receive(:render).with(partial: "catalog/metadata/missing")
|
253
254
|
helper.render_transformed_metadata(metadata)
|
254
255
|
end
|
255
256
|
end
|
256
257
|
end
|
257
258
|
|
258
|
-
describe
|
259
|
+
describe "#first_metadata?" do
|
259
260
|
let(:metadata) { instance_double(Geoblacklight::Metadata::Base) }
|
260
261
|
let(:references) { instance_double(Geoblacklight::References) }
|
261
262
|
let(:document) { instance_double(SolrDocument) }
|
@@ -263,96 +264,96 @@ describe GeoblacklightHelper, type: :helper do
|
|
263
264
|
before do
|
264
265
|
allow(document).to receive(:references).and_return(references)
|
265
266
|
allow(references).to receive(:shown_metadata).and_return([metadata])
|
266
|
-
allow(metadata).to receive(:type).and_return(
|
267
|
+
allow(metadata).to receive(:type).and_return("fgdc")
|
267
268
|
end
|
268
269
|
|
269
|
-
it
|
270
|
+
it "confirms that a metadata resource is the first item reference" do
|
270
271
|
expect(helper.first_metadata?(document, metadata)).to be true
|
271
272
|
end
|
272
273
|
end
|
273
274
|
|
274
|
-
describe
|
275
|
-
let(:feature) {
|
276
|
-
let(:translation_key) {
|
275
|
+
describe "#show_help_text?" do
|
276
|
+
let(:feature) { "viewer_protocol" }
|
277
|
+
let(:translation_key) { "wms" }
|
277
278
|
|
278
|
-
it
|
279
|
+
it "confirms help text is available" do
|
279
280
|
expect(helper.show_help_text?(feature, translation_key)).to be true
|
280
281
|
end
|
281
282
|
end
|
282
283
|
|
283
|
-
describe
|
284
|
-
let(:feature) {
|
285
|
-
let(:translation_key) {
|
284
|
+
describe "#render_help_text_entry" do
|
285
|
+
let(:feature) { "viewer_protocol" }
|
286
|
+
let(:translation_key) { "wms" }
|
286
287
|
|
287
|
-
context
|
288
|
-
it
|
288
|
+
context "valid entry" do
|
289
|
+
it "renders help text entry for the wms viewer protocol" do
|
289
290
|
expect(helper.render_help_text_entry(feature, translation_key)).to eq '<h3 class="help-text viewer_protocol h6"><a data-toggle="popover" data-title="Web Map Service (WMS)" data-content="A Web Map Service displays a geospatial dataset as map images.">Web Map Service (WMS)</a></h3>'
|
290
291
|
end
|
291
292
|
end
|
292
293
|
|
293
|
-
context
|
294
|
-
it
|
295
|
-
expect(helper.render_help_text_entry(
|
294
|
+
context "invalid entry" do
|
295
|
+
it "renders an empty span" do
|
296
|
+
expect(helper.render_help_text_entry("foo", "bar")).to eq '<span class="help-text translation-missing"></span>'
|
296
297
|
end
|
297
298
|
end
|
298
299
|
end
|
299
300
|
|
300
|
-
describe
|
301
|
-
context
|
301
|
+
describe "#relations_icon" do
|
302
|
+
context "when configured to use the geometry type" do
|
302
303
|
before do
|
303
304
|
allow(Settings).to receive(:USE_GEOM_FOR_RELATIONS_ICON).and_return(true)
|
304
305
|
end
|
305
306
|
|
306
|
-
it
|
307
|
-
html = Capybara.string(helper.relations_icon({
|
308
|
-
expect(html.title.strip).to eq
|
307
|
+
it "renders a goemetry type as the icon" do
|
308
|
+
html = Capybara.string(helper.relations_icon({Settings.FIELDS.GEOM_TYPE => "polygon"}, "leaf"))
|
309
|
+
expect(html.title.strip).to eq "Polygon"
|
309
310
|
end
|
310
311
|
|
311
|
-
it
|
312
|
-
html = Capybara.string(helper.relations_icon({
|
313
|
-
expect(html).to have_css(
|
312
|
+
it "has the svg_tooltip class so that the Bootstrap tooltip is applied" do
|
313
|
+
html = Capybara.string(helper.relations_icon({Settings.FIELDS.GEOM_TYPE => "polygon"}, "leaf"))
|
314
|
+
expect(html).to have_css(".blacklight-icons.svg_tooltip")
|
314
315
|
end
|
315
316
|
end
|
316
317
|
|
317
|
-
context
|
318
|
+
context "when not confiugred to use the geometry type" do
|
318
319
|
before do
|
319
320
|
allow(Settings).to receive(:USE_GEOM_FOR_RELATIONS_ICON).and_return(false)
|
320
321
|
end
|
321
322
|
|
322
|
-
it
|
323
|
-
html = Capybara.string(helper.relations_icon({
|
324
|
-
expect(html.title.strip).to eq
|
323
|
+
it "renders the provided icon" do
|
324
|
+
html = Capybara.string(helper.relations_icon({Settings.FIELDS.GEOM_TYPE => "polygon"}, "leaf"))
|
325
|
+
expect(html.title.strip).to eq "Leaf"
|
325
326
|
end
|
326
327
|
|
327
|
-
it
|
328
|
-
html = Capybara.string(helper.relations_icon({
|
329
|
-
expect(html).not_to have_css(
|
328
|
+
it "does not have the svg_tooltip class" do
|
329
|
+
html = Capybara.string(helper.relations_icon({Settings.FIELDS.GEOM_TYPE => "polygon"}, "leaf"))
|
330
|
+
expect(html).not_to have_css(".blacklight-icons.svg_tooltip")
|
330
331
|
end
|
331
332
|
end
|
332
333
|
end
|
333
334
|
|
334
|
-
describe
|
335
|
-
context
|
336
|
-
let(:controller_name) {
|
335
|
+
describe "#results_js_map_selector" do
|
336
|
+
context "viewing bookmarks" do
|
337
|
+
let(:controller_name) { "bookmarks" }
|
337
338
|
|
338
|
-
it
|
339
|
-
expect(results_js_map_selector(controller_name)).to eq
|
339
|
+
it "returns bookmarks data-map selector" do
|
340
|
+
expect(results_js_map_selector(controller_name)).to eq "bookmarks"
|
340
341
|
end
|
341
342
|
end
|
342
343
|
|
343
|
-
context
|
344
|
-
let(:controller_name) {
|
344
|
+
context "viewing catalog results" do
|
345
|
+
let(:controller_name) { "catalog" }
|
345
346
|
|
346
|
-
it
|
347
|
-
expect(results_js_map_selector(controller_name)).to eq
|
347
|
+
it "returns index data-map selector" do
|
348
|
+
expect(results_js_map_selector(controller_name)).to eq "index"
|
348
349
|
end
|
349
350
|
end
|
350
351
|
|
351
|
-
context
|
352
|
-
let(:controller_name) {
|
352
|
+
context "calling outside of intended scope" do
|
353
|
+
let(:controller_name) { "outside" }
|
353
354
|
|
354
|
-
it
|
355
|
-
expect(results_js_map_selector(controller_name)).to eq
|
355
|
+
it "returns default data-map value" do
|
356
|
+
expect(results_js_map_selector(controller_name)).to eq "index"
|
356
357
|
end
|
357
358
|
end
|
358
359
|
end
|
@@ -1,28 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::BoundingBox do
|
5
|
-
describe
|
6
|
-
it
|
7
|
-
expect(described_class.new(
|
6
|
+
describe "#initialize" do
|
7
|
+
it "handles multiple input types as arguments" do
|
8
|
+
expect(described_class.new("1", "1", "1", "1")).to be_an described_class
|
8
9
|
expect(described_class.new(1, 2, 3, 3)).to be_an described_class
|
9
10
|
expect(described_class.new(1.1, 2.1, 3.1, 3.1)).to be_an described_class
|
10
11
|
end
|
11
12
|
end
|
12
|
-
describe
|
13
|
+
describe "#to_envelope" do
|
13
14
|
let(:example_box) { described_class.new(-160, -80, 120, 70) }
|
14
|
-
it
|
15
|
-
expect(example_box.to_envelope).to eq
|
15
|
+
it "creates an envelope syntax version of the bounding box" do
|
16
|
+
expect(example_box.to_envelope).to eq "ENVELOPE(-160, 120, 70, -80)"
|
16
17
|
end
|
17
18
|
end
|
18
|
-
describe
|
19
|
-
let(:example_box) { described_class.from_rectangle(
|
20
|
-
it
|
19
|
+
describe "#from_rectangle" do
|
20
|
+
let(:example_box) { described_class.from_rectangle("-160 -80 120 70") }
|
21
|
+
it "parses and creates a Geoblacklight::BoundingBox from a Solr lat-lon" do
|
21
22
|
expect(example_box).to be_an described_class
|
22
|
-
expect(example_box.to_envelope).to eq
|
23
|
+
expect(example_box.to_envelope).to eq "ENVELOPE(-160, 120, 70, -80)"
|
23
24
|
end
|
24
|
-
it
|
25
|
-
expect { described_class.from_rectangle(
|
25
|
+
it "checks for valididity" do
|
26
|
+
expect { described_class.from_rectangle("-160 -80 120") }.to raise_error Geoblacklight::Exceptions::WrongBoundingBoxFormat
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::DocumentPresenter do
|
5
6
|
# Please see https://github.com/projectblacklight/blacklight/blob/v6.15.0/spec/presenters/index_presenter_spec.rb#L4
|
6
7
|
subject { presenter }
|
7
|
-
let(:request_context) { double(document_index_view_type:
|
8
|
+
let(:request_context) { double(document_index_view_type: "list") }
|
8
9
|
let(:blacklight_config) do
|
9
10
|
Blacklight::Configuration.new.configure do |config|
|
10
|
-
config.add_index_field
|
11
|
-
config.add_index_field
|
12
|
-
config.add_index_field
|
13
|
-
config.add_index_field
|
11
|
+
config.add_index_field "gbl_wxsIdentifier_s"
|
12
|
+
config.add_index_field "index_display"
|
13
|
+
config.add_index_field "period"
|
14
|
+
config.add_index_field "multi_display"
|
14
15
|
end
|
15
16
|
end
|
16
17
|
let(:solr_fields) { Settings.FIELDS }
|
@@ -21,41 +22,41 @@ describe Geoblacklight::DocumentPresenter do
|
|
21
22
|
let(:document) do
|
22
23
|
SolrDocument.new(
|
23
24
|
id: 1,
|
24
|
-
gbl_wxsIdentifier_s:
|
25
|
-
non_index_field:
|
26
|
-
period:
|
25
|
+
gbl_wxsIdentifier_s: "druid:abc123",
|
26
|
+
non_index_field: "do not render",
|
27
|
+
period: "Ends with period.",
|
27
28
|
multi_display: %w[blue blah]
|
28
29
|
)
|
29
30
|
end
|
30
31
|
|
31
|
-
describe
|
32
|
+
describe "#index_fields_display" do
|
32
33
|
let(:rendered_index_text) { subject.index_fields_display }
|
33
|
-
let(:multi_valued_text) { document[
|
34
|
-
let(:combined_fields) { document[
|
34
|
+
let(:multi_valued_text) { document["multi_display"].join(" and ") }
|
35
|
+
let(:combined_fields) { document["gbl_wxsIdentifier_s"] + ". " + document["period"] }
|
35
36
|
|
36
|
-
context
|
37
|
-
it
|
37
|
+
context "with multi-valued field" do
|
38
|
+
it "each value is separated by comma" do
|
38
39
|
expect(rendered_index_text).to include(multi_valued_text)
|
39
40
|
end
|
40
41
|
end
|
41
|
-
context
|
42
|
-
it
|
43
|
-
expect(rendered_index_text).not_to include(document[
|
42
|
+
context "with document fields not configured as index field" do
|
43
|
+
it "does not render" do
|
44
|
+
expect(rendered_index_text).not_to include(document["non_index_field"])
|
44
45
|
end
|
45
46
|
end
|
46
|
-
context
|
47
|
-
it
|
47
|
+
context "with multiple document index fields present" do
|
48
|
+
it "separates fields by period followed by a space" do
|
48
49
|
expect(rendered_index_text).to include(combined_fields)
|
49
50
|
end
|
50
|
-
context
|
51
|
-
it
|
52
|
-
expect(rendered_index_text).to include(document[
|
51
|
+
context "with index field ending in period" do
|
52
|
+
it "renders only 1 period" do
|
53
|
+
expect(rendered_index_text).to include(document["period"] + " ")
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
56
|
-
context
|
57
|
-
it
|
58
|
-
expect(rendered_index_text).not_to include(
|
57
|
+
context "with document empty configured index field" do
|
58
|
+
it "does not render a period followed by a space" do
|
59
|
+
expect(rendered_index_text).not_to include(". .")
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|