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,278 +1,292 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::SolrDocument do
|
5
6
|
let(:document) { SolrDocument.new(document_attributes) }
|
6
7
|
let(:rights_field) { Settings.FIELDS.ACCESS_RIGHTS }
|
7
8
|
let(:provider_field) { Settings.FIELDS.PROVIDER }
|
8
9
|
let(:references_field) { Settings.FIELDS.REFERENCES }
|
9
|
-
describe
|
10
|
+
describe "#available?" do
|
10
11
|
let(:document_attributes) { {} }
|
11
|
-
describe
|
12
|
-
it
|
13
|
-
allow(document).to receive(
|
14
|
-
allow(document).to receive(
|
12
|
+
describe "a public document" do
|
13
|
+
it "alwayses be available" do
|
14
|
+
allow(document).to receive("same_institution?").and_return(false)
|
15
|
+
allow(document).to receive("public?").and_return(true)
|
15
16
|
expect(document.available?).to be_truthy
|
16
17
|
end
|
17
18
|
end
|
18
|
-
describe
|
19
|
-
it
|
20
|
-
allow(document).to receive(
|
21
|
-
allow(document).to receive(
|
19
|
+
describe "a restricted document" do
|
20
|
+
it "onlies be available if from same institution" do
|
21
|
+
allow(document).to receive("same_institution?").and_return(true)
|
22
|
+
allow(document).to receive("public?").and_return(false)
|
22
23
|
expect(document.available?).to be_truthy
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
26
|
-
describe
|
27
|
-
describe
|
28
|
-
let(:document_attributes) { {
|
29
|
-
it
|
27
|
+
describe "#public?" do
|
28
|
+
describe "a public document" do
|
29
|
+
let(:document_attributes) { {rights_field => "PUBLIC"} }
|
30
|
+
it "is public" do
|
30
31
|
expect(document.public?).to be_truthy
|
31
32
|
end
|
32
33
|
end
|
33
|
-
describe
|
34
|
-
let(:document_attributes) { {
|
35
|
-
it
|
34
|
+
describe "a restricted resource" do
|
35
|
+
let(:document_attributes) { {rights_field => "RESTRICTED"} }
|
36
|
+
it "does not be public" do
|
36
37
|
expect(document.public?).to be_falsey
|
37
38
|
end
|
38
39
|
end
|
39
|
-
describe
|
40
|
+
describe "without rights data" do
|
40
41
|
let(:document_attributes) { {} }
|
41
|
-
it
|
42
|
+
it "is not public" do
|
42
43
|
expect(document.public?).to be_falsey
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
46
|
-
describe
|
47
|
-
describe
|
48
|
-
let(:document_attributes) { {
|
49
|
-
it
|
47
|
+
describe "#restricted?" do
|
48
|
+
describe "a restricted document" do
|
49
|
+
let(:document_attributes) { {rights_field => "RESTRICTED"} }
|
50
|
+
it "is restricted" do
|
50
51
|
expect(document.restricted?).to be_truthy
|
51
52
|
end
|
52
53
|
end
|
53
|
-
describe
|
54
|
-
let(:document_attributes) { {
|
55
|
-
it
|
54
|
+
describe "a non-restricted resource" do
|
55
|
+
let(:document_attributes) { {rights_field => "PUBLIC"} }
|
56
|
+
it "is not restricted" do
|
56
57
|
expect(document.restricted?).to be_falsey
|
57
58
|
end
|
58
59
|
end
|
59
|
-
describe
|
60
|
+
describe "without rights data" do
|
60
61
|
let(:document_attributes) { {} }
|
61
|
-
it
|
62
|
+
it "is restricted" do
|
62
63
|
expect(document.restricted?).to be_truthy
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
66
|
-
describe
|
67
|
-
describe
|
67
|
+
describe "#downloadable?" do
|
68
|
+
describe "available direct download" do
|
68
69
|
let(:document_attributes) do
|
69
70
|
{
|
70
|
-
rights_field =>
|
71
|
+
rights_field => "Public",
|
71
72
|
references_field => {
|
72
|
-
|
73
|
+
"http://schema.org/downloadUrl" => "http://example.com/direct/data.zip"
|
73
74
|
}.to_json
|
74
75
|
}
|
75
76
|
end
|
76
|
-
it
|
77
|
+
it "will be downloadable" do
|
77
78
|
expect(document.downloadable?).to be_truthy
|
78
79
|
end
|
79
80
|
end
|
80
81
|
end
|
81
|
-
describe
|
82
|
-
describe
|
83
|
-
let(:document_attributes) { {
|
84
|
-
it
|
85
|
-
allow(Settings).to receive(
|
82
|
+
describe "#same_institution?" do
|
83
|
+
describe "within the same institution" do
|
84
|
+
let(:document_attributes) { {provider_field => "STANFORD"} }
|
85
|
+
it "is true" do
|
86
|
+
allow(Settings).to receive("Institution").and_return("Stanford")
|
86
87
|
expect(document.same_institution?).to be_truthy
|
87
88
|
end
|
88
|
-
it
|
89
|
-
allow(Settings).to receive(
|
89
|
+
it "matches case inconsistencies" do
|
90
|
+
allow(Settings).to receive("Institution").and_return("StAnFord")
|
90
91
|
expect(document.same_institution?).to be_truthy
|
91
92
|
end
|
92
93
|
end
|
93
|
-
describe
|
94
|
-
let(:document_attributes) { {
|
95
|
-
it
|
96
|
-
allow(Settings).to receive(
|
94
|
+
describe "within a different institution" do
|
95
|
+
let(:document_attributes) { {provider_field => "MIT"} }
|
96
|
+
it "is false" do
|
97
|
+
allow(Settings).to receive("Institution").and_return("Stanford")
|
97
98
|
expect(document.same_institution?).to be_falsey
|
98
99
|
end
|
99
100
|
end
|
100
101
|
end
|
101
|
-
describe
|
102
|
+
describe "references" do
|
102
103
|
let(:document_attributes) { {} }
|
103
|
-
it
|
104
|
+
it "generates a new references object" do
|
104
105
|
expect(document.references).to be_an Geoblacklight::References
|
105
106
|
end
|
106
107
|
end
|
107
|
-
describe
|
108
|
+
describe "download_types" do
|
108
109
|
let(:document_attributes) { {} }
|
109
|
-
it
|
110
|
+
it "calls download_types" do
|
110
111
|
expect_any_instance_of(Geoblacklight::References).to receive(:download_types)
|
111
112
|
document.download_types
|
112
113
|
end
|
113
114
|
end
|
114
|
-
describe
|
115
|
+
describe "direct_download" do
|
115
116
|
let(:document_attributes) { {} }
|
116
|
-
describe
|
117
|
+
describe "with a direct download" do
|
117
118
|
let(:document_attributes) do
|
118
119
|
{
|
119
120
|
references_field => {
|
120
|
-
|
121
|
+
"http://schema.org/downloadUrl" => "http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip"
|
121
122
|
}.to_json
|
122
123
|
}
|
123
124
|
end
|
124
|
-
it
|
125
|
+
it "returns a direct download hash" do
|
125
126
|
expect_any_instance_of(Geoblacklight::Reference).to receive(:to_hash)
|
126
127
|
document.direct_download
|
127
128
|
end
|
128
129
|
end
|
129
|
-
it
|
130
|
+
it "returns nil if no direct download" do
|
130
131
|
expect_any_instance_of(Geoblacklight::Reference).not_to receive(:to_hash)
|
131
132
|
expect(document.direct_download).to be_nil
|
132
133
|
end
|
133
134
|
end
|
134
|
-
describe
|
135
|
-
describe
|
135
|
+
describe "hgl_download" do
|
136
|
+
describe "with an hgl download" do
|
136
137
|
let(:document_attributes) do
|
137
138
|
{
|
138
139
|
references_field => {
|
139
|
-
|
140
|
+
"http://schema.org/DownloadAction" => "http://example.com/harvard"
|
140
141
|
}.to_json
|
141
142
|
}
|
142
143
|
end
|
143
|
-
it
|
144
|
-
expect(document.hgl_download[:hgl]).to eq(
|
144
|
+
it "returns an hgl download hash" do
|
145
|
+
expect(document.hgl_download[:hgl]).to eq("http://example.com/harvard")
|
145
146
|
end
|
146
147
|
end
|
147
|
-
describe
|
148
|
+
describe "without an hgl download" do
|
148
149
|
let(:document_attributes) { {} }
|
149
|
-
it
|
150
|
+
it "returns nil" do
|
150
151
|
expect(document.direct_download).to be_nil
|
151
152
|
end
|
152
153
|
end
|
153
154
|
end
|
154
|
-
describe
|
155
|
-
describe
|
155
|
+
describe "#oembed" do
|
156
|
+
describe "with an oembed url" do
|
156
157
|
let(:document_attributes) do
|
157
158
|
{
|
158
159
|
references_field => {
|
159
|
-
|
160
|
+
"https://oembed.com" => "http://example.com/oembed?url=oembec.com/id123"
|
160
161
|
}.to_json
|
161
162
|
}
|
162
163
|
end
|
163
|
-
it
|
164
|
-
expect(document.oembed).to eq(
|
164
|
+
it "returns a url string" do
|
165
|
+
expect(document.oembed).to eq("http://example.com/oembed?url=oembec.com/id123")
|
165
166
|
end
|
166
167
|
end
|
167
|
-
describe
|
168
|
+
describe "without an oembed url" do
|
168
169
|
let(:document_attributes) { {} }
|
169
|
-
it
|
170
|
+
it "returns nil" do
|
170
171
|
expect(document.oembed).to be_nil
|
171
172
|
end
|
172
173
|
end
|
173
174
|
end
|
174
|
-
describe
|
175
|
-
describe
|
175
|
+
describe "iiif_download" do
|
176
|
+
describe "with a IIIF download" do
|
176
177
|
let(:document_attributes) do
|
177
178
|
{
|
178
179
|
references_field => {
|
179
|
-
|
180
|
+
"http://iiif.io/api/image" => "https://example.edu/images/info.json"
|
180
181
|
}.to_json
|
181
182
|
}
|
182
183
|
end
|
183
|
-
it
|
184
|
-
expect(document.iiif_download[:iiif]).to eq(
|
184
|
+
it "returns a IIIF download hash" do
|
185
|
+
expect(document.iiif_download[:iiif]).to eq("https://example.edu/images/info.json")
|
185
186
|
end
|
186
187
|
end
|
187
|
-
describe
|
188
|
+
describe "without a IIIF download" do
|
188
189
|
let(:document_attributes) { {} }
|
189
|
-
it
|
190
|
+
it "returns nil" do
|
190
191
|
expect(document.iiif_download).to be_nil
|
191
192
|
end
|
192
193
|
end
|
193
194
|
end
|
194
|
-
describe
|
195
|
-
describe
|
195
|
+
describe "data_dictionary_download" do
|
196
|
+
describe "with a data dictionary reference" do
|
196
197
|
let(:document_attributes) do
|
197
198
|
{
|
198
199
|
references_field => {
|
199
|
-
|
200
|
+
"http://lccn.loc.gov/sh85035852" => "https://example.edu/documentation/data_dictionary.zip"
|
200
201
|
}.to_json
|
201
202
|
}
|
202
203
|
end
|
203
|
-
it
|
204
|
-
expect(document.data_dictionary_download[:data_dictionary]).to eq(
|
204
|
+
it "returns a data dictionary download hash" do
|
205
|
+
expect(document.data_dictionary_download[:data_dictionary]).to eq("https://example.edu/documentation/data_dictionary.zip")
|
205
206
|
end
|
206
207
|
end
|
207
|
-
describe
|
208
|
+
describe "without a data dictionary download" do
|
208
209
|
let(:document_attributes) { {} }
|
209
|
-
it
|
210
|
+
it "returns nil" do
|
210
211
|
expect(document.data_dictionary_download).to be_nil
|
211
212
|
end
|
212
213
|
end
|
213
214
|
end
|
214
|
-
describe
|
215
|
+
describe "item_viewer" do
|
215
216
|
let(:document_attributes) { {} }
|
216
|
-
it
|
217
|
+
it "is a ItemViewer" do
|
217
218
|
expect(document.item_viewer).to be_an Geoblacklight::ItemViewer
|
218
219
|
end
|
219
220
|
end
|
220
|
-
describe
|
221
|
-
describe
|
221
|
+
describe "viewer_protocol" do
|
222
|
+
describe "with a wms reference" do
|
222
223
|
let(:document_attributes) do
|
223
224
|
{
|
224
225
|
references_field => {
|
225
|
-
|
226
|
+
"http://www.opengis.net/def/serviceType/ogc/wms" => "http://www.example.com/wms"
|
226
227
|
}.to_json
|
227
228
|
}
|
228
229
|
end
|
229
|
-
it
|
230
|
-
expect(document.viewer_protocol).to eq
|
230
|
+
it "returns wms protocol" do
|
231
|
+
expect(document.viewer_protocol).to eq "wms"
|
231
232
|
end
|
232
233
|
end
|
233
234
|
let(:document_attributes) { {} }
|
234
|
-
it
|
235
|
-
expect(document.viewer_protocol).to eq
|
235
|
+
it "returns leaflet protocol" do
|
236
|
+
expect(document.viewer_protocol).to eq "map"
|
236
237
|
end
|
237
238
|
end
|
238
|
-
describe
|
239
|
-
describe
|
239
|
+
describe "viewer_endpoint" do
|
240
|
+
describe "with a wms reference" do
|
240
241
|
let(:document_attributes) do
|
241
242
|
{
|
242
243
|
references_field => {
|
243
|
-
|
244
|
+
"http://www.opengis.net/def/serviceType/ogc/wms" => "http://www.example.com/wms"
|
244
245
|
}.to_json
|
245
246
|
}
|
246
247
|
end
|
247
|
-
it
|
248
|
-
expect(document.viewer_endpoint).to eq
|
248
|
+
it "returns wms endpoint" do
|
249
|
+
expect(document.viewer_endpoint).to eq "http://www.example.com/wms"
|
249
250
|
end
|
250
251
|
end
|
251
252
|
let(:document_attributes) { {} }
|
252
|
-
it
|
253
|
-
expect(document.viewer_endpoint).to eq
|
253
|
+
it "returns no endpoint" do
|
254
|
+
expect(document.viewer_endpoint).to eq ""
|
254
255
|
end
|
255
256
|
end
|
256
|
-
describe
|
257
|
+
describe "checked_endpoint" do
|
257
258
|
let(:document_attributes) { {} }
|
258
|
-
let(:reference) { Geoblacklight::Reference.new([
|
259
|
-
it
|
259
|
+
let(:reference) { Geoblacklight::Reference.new(["http://www.opengis.net/def/serviceType/ogc/wms", "http://www.example.com/wms"]) }
|
260
|
+
it "returns endpoint if available" do
|
260
261
|
expect_any_instance_of(Geoblacklight::References).to receive(:wms).and_return(reference)
|
261
|
-
expect(document.checked_endpoint(
|
262
|
+
expect(document.checked_endpoint("wms")).to eq "http://www.example.com/wms"
|
262
263
|
end
|
263
|
-
it
|
264
|
+
it "return nil if not available" do
|
264
265
|
expect_any_instance_of(Geoblacklight::References).to receive(:wms).and_return(nil)
|
265
|
-
expect(document.checked_endpoint(
|
266
|
+
expect(document.checked_endpoint("wms")).to be_nil
|
266
267
|
end
|
267
268
|
end
|
268
|
-
describe
|
269
|
+
describe "method_missing" do
|
269
270
|
let(:document_attributes) { {} }
|
270
|
-
it
|
271
|
-
expect(document).to receive(:checked_endpoint).with(
|
271
|
+
it "calls checked_endpoint with parsed method name if matches" do
|
272
|
+
expect(document).to receive(:checked_endpoint).with("wms").and_return(nil)
|
272
273
|
expect(document.wms_url).to be_nil
|
273
274
|
end
|
274
|
-
it
|
275
|
+
it "raises no method error" do
|
275
276
|
expect { document.wms_urlz }.to raise_error NoMethodError
|
276
277
|
end
|
277
278
|
end
|
279
|
+
describe "#respond_to_missing?" do
|
280
|
+
let(:document_attributes) { {} }
|
281
|
+
context "with a valid method" do
|
282
|
+
it "returns true" do
|
283
|
+
expect(document.respond_to?(:wms_url)).to be true
|
284
|
+
end
|
285
|
+
end
|
286
|
+
context "with a invalid method" do
|
287
|
+
it "returns true" do
|
288
|
+
expect(document.respond_to?(:wms_urlz)).to be false
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
278
292
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Geoblacklight::SuppressedRecordsSearchBehavior do
|
5
6
|
subject(:searcher) { search_builder.with(user_params) }
|
6
7
|
|
7
8
|
let(:user_params) { {} }
|
8
|
-
let(:solr_params) { {
|
9
|
+
let(:solr_params) { {q: "water"} }
|
9
10
|
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
10
11
|
let(:context) { CatalogController.new }
|
11
12
|
let(:search_builder_class) do
|
@@ -16,14 +17,14 @@ describe Geoblacklight::SuppressedRecordsSearchBehavior do
|
|
16
17
|
end
|
17
18
|
let(:search_builder) { search_builder_class.new(context) }
|
18
19
|
|
19
|
-
describe
|
20
|
-
it
|
21
|
-
expect(searcher.hide_suppressed_records(solr_params)).to include(
|
20
|
+
describe "#hide_suppressed_records" do
|
21
|
+
it "hides/filters suppressed records" do
|
22
|
+
expect(searcher.hide_suppressed_records(solr_params)).to include("-gbl_suppressed_b: true")
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
context
|
26
|
-
it
|
26
|
+
context "when document action call like CatalogController#web_services" do
|
27
|
+
it "does not hide/filter suppressed records" do
|
27
28
|
solr_params[:q] = "{!lucene}#{Settings.FIELDS.ID}:"
|
28
29
|
expect(searcher.hide_suppressed_records(solr_params)).to be_nil
|
29
30
|
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::BboxItemPresenter, type: :presenter do
|
6
6
|
subject(:presenter) do
|
@@ -9,27 +9,27 @@ RSpec.describe Geoblacklight::BboxItemPresenter, type: :presenter do
|
|
9
9
|
|
10
10
|
let(:facet_item) { instance_double(Blacklight::Solr::Response::Facets::FacetItem) }
|
11
11
|
let(:filter_field) { instance_double(Blacklight::SearchState::FilterField, include?: true) }
|
12
|
-
let(:facet_config) { Blacklight::Configuration::FacetField.new(key:
|
12
|
+
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: "key") }
|
13
13
|
let(:facet_field) { instance_double(Blacklight::Solr::Response::Facets::FacetField) }
|
14
14
|
let(:view_context) { controller.view_context }
|
15
15
|
let(:search_state) { instance_double(Blacklight::SearchState, filter: filter_field) }
|
16
16
|
let(:controller) { CatalogController.new }
|
17
17
|
|
18
|
-
describe
|
19
|
-
context
|
20
|
-
let(:facet_item) {
|
18
|
+
describe "#label" do
|
19
|
+
context "with a single value" do
|
20
|
+
let(:facet_item) { "blah" }
|
21
21
|
|
22
|
-
it
|
23
|
-
expect(presenter.label).to eq
|
22
|
+
it "uses the normal logic for item values" do
|
23
|
+
expect(presenter.label).to eq "blah"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
context
|
27
|
+
context "with a bbox" do
|
28
28
|
let(:facet_item) { Geoblacklight::BoundingBox.new(-160, -80, 120, 70) }
|
29
29
|
|
30
|
-
it
|
30
|
+
it "translates the bbox into some nice, human-readable html" do
|
31
31
|
expect(Capybara.string(presenter.label))
|
32
|
-
.to have_text(
|
32
|
+
.to have_text("-160 -80 120 70")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
2
|
|
4
|
-
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe "Catalog Routes", type: :routing do
|
5
6
|
# Test paths for custom routes
|
6
7
|
it "maps { :controller => 'catalog', :action => 'opensearch', :format => 'xml' } to /catalog/opensearch.xml" do
|
7
|
-
expect(get:
|
8
|
+
expect(get: "/catalog/opensearch.xml").to route_to(controller: "catalog", action: "opensearch", format: "xml")
|
8
9
|
end
|
9
10
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,64 +1,65 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
ENV['RAILS_ENV'] ||= 'test'
|
3
2
|
|
4
|
-
|
3
|
+
ENV["RAILS_ENV"] ||= "test"
|
4
|
+
|
5
|
+
require "simplecov"
|
5
6
|
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
6
7
|
|
7
|
-
if ENV.fetch(
|
8
|
-
dir = File.join(ENV.fetch(
|
8
|
+
if ENV.fetch("CIRCLE_ARTIFACTS", false)
|
9
|
+
dir = File.join(ENV.fetch("CIRCLE_ARTIFACTS"), "coverage")
|
9
10
|
SimpleCov.coverage_dir(dir)
|
10
11
|
end
|
11
12
|
|
12
|
-
SimpleCov.start
|
13
|
-
add_filter
|
14
|
-
add_filter
|
15
|
-
add_filter
|
16
|
-
add_filter
|
17
|
-
add_filter
|
18
|
-
add_filter
|
13
|
+
SimpleCov.start "rails" do
|
14
|
+
add_filter "lib/generators/geoblacklight/install_generator.rb"
|
15
|
+
add_filter "lib/geoblacklight/version.rb"
|
16
|
+
add_filter "lib/generators"
|
17
|
+
add_filter "lib/tasks/geoblacklight.rake"
|
18
|
+
add_filter "/spec"
|
19
|
+
add_filter ".internal_test_app/"
|
19
20
|
minimum_coverage 100
|
20
21
|
end
|
21
22
|
|
22
|
-
require
|
23
|
-
require
|
23
|
+
require "factory_bot"
|
24
|
+
require "database_cleaner"
|
24
25
|
|
25
|
-
require
|
26
|
+
require "engine_cart"
|
26
27
|
EngineCart.load_application!
|
27
28
|
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
29
|
+
require "rails-controller-testing" if Rails::VERSION::MAJOR >= 5
|
30
|
+
require "rspec/rails"
|
31
|
+
require "capybara/rspec"
|
32
|
+
require "selenium-webdriver"
|
33
|
+
require "webdrivers"
|
33
34
|
|
34
35
|
# Setup webmock for specific tests
|
35
|
-
require
|
36
|
+
require "webmock/rspec"
|
36
37
|
WebMock.allow_net_connect!(net_http_connect_on_start: true)
|
37
38
|
|
38
39
|
Capybara.register_driver(:headless_chrome) do |app|
|
39
40
|
Capybara::Selenium::Driver.load_selenium
|
40
41
|
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
41
|
-
opts.args <<
|
42
|
-
opts.args <<
|
43
|
-
opts.args <<
|
42
|
+
opts.args << "--headless"
|
43
|
+
opts.args << "--disable-gpu"
|
44
|
+
opts.args << "--window-size=1280,1024"
|
44
45
|
end
|
45
46
|
http_client = Selenium::WebDriver::Remote::Http::Default.new
|
46
47
|
http_client.read_timeout = 120
|
47
48
|
http_client.open_timeout = 120
|
48
49
|
Capybara::Selenium::Driver.new(app,
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
browser: :chrome,
|
51
|
+
http_client: http_client,
|
52
|
+
capabilities: [browser_options])
|
52
53
|
end
|
53
54
|
|
54
55
|
Capybara.javascript_driver = :headless_chrome
|
55
56
|
Capybara.default_max_wait_time = 120
|
56
57
|
|
57
|
-
require
|
58
|
+
require "geoblacklight"
|
58
59
|
|
59
|
-
Dir[
|
60
|
+
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
|
60
61
|
|
61
|
-
FactoryBot.definition_file_paths = [File.expand_path(
|
62
|
+
FactoryBot.definition_file_paths = [File.expand_path("../factories", __FILE__)]
|
62
63
|
FactoryBot.find_definitions
|
63
64
|
|
64
65
|
RSpec.configure do |config|
|
@@ -66,10 +67,10 @@ RSpec.configure do |config|
|
|
66
67
|
|
67
68
|
config.before do
|
68
69
|
DatabaseCleaner.strategy = if Capybara.current_driver == :rack_test
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
:transaction
|
71
|
+
else
|
72
|
+
:truncation
|
73
|
+
end
|
73
74
|
DatabaseCleaner.start
|
74
75
|
end
|
75
76
|
|