geoblacklight 6.0.0.pre.alpha.3 → 6.0.0.pre.alpha.5
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/Rakefile +0 -1
- data/app/assets/stylesheets/geoblacklight/global.css +30 -0
- data/app/assets/stylesheets/geoblacklight/record.css +41 -1
- data/app/components/geoblacklight/document/download_link_component.html.erb +6 -0
- data/app/components/geoblacklight/document/download_link_component.rb +66 -0
- data/app/components/geoblacklight/document/download_links_component.html.erb +8 -0
- data/app/components/geoblacklight/document/download_links_component.rb +59 -0
- data/app/components/geoblacklight/document/sidebar_component.html.erb +3 -9
- data/app/components/geoblacklight/document/sidebar_component.rb +6 -11
- data/app/components/geoblacklight/login_link_component.html.erb +3 -5
- data/app/helpers/geoblacklight_helper.rb +1 -1
- data/app/javascript/geoblacklight/core.js +0 -2
- data/app/javascript/geoblacklight/index.js +0 -2
- data/app/javascript/geoblacklight/leaflet/inspection.js +5 -4
- data/app/models/concerns/geoblacklight/solr_document.rb +1 -2
- data/config/locales/geoblacklight.en.yml +5 -14
- data/geoblacklight.gemspec +0 -1
- data/lib/generators/geoblacklight/install_generator.rb +0 -9
- data/lib/generators/geoblacklight/templates/settings.yml +1 -15
- data/lib/geoblacklight/configuration/settings_builder.rb +0 -3
- data/lib/geoblacklight/configuration.rb +0 -10
- data/lib/geoblacklight/exceptions.rb +0 -23
- data/lib/geoblacklight/references.rb +0 -80
- data/lib/geoblacklight/version.rb +1 -1
- data/lib/geoblacklight.rb +0 -1
- data/lib/tasks/geoblacklight.rake +0 -30
- data/spec/components/geoblacklight/document/sidebar_component_spec.rb +1 -1
- data/spec/components/geoblacklight/download_links_component_spec.rb +59 -85
- data/spec/features/index_view_spec.rb +0 -33
- data/spec/features/layer_inspection_spec.rb +0 -10
- data/spec/features/layer_opacity_spec.rb +0 -7
- data/spec/helpers/geoblacklight_helper_spec.rb +1 -1
- data/spec/lib/geoblacklight/configuration/settings_builder_spec.rb +0 -2
- data/spec/lib/geoblacklight/references_spec.rb +1 -57
- data/spec/models/concerns/geoblacklight/solr_document_spec.rb +0 -7
- data/template.rb +1 -1
- metadata +6 -42
- data/app/components/geoblacklight/download_links_component.html.erb +0 -31
- data/app/components/geoblacklight/download_links_component.rb +0 -87
- data/app/controllers/download_controller.rb +0 -76
- data/app/javascript/geoblacklight/controllers/downloads_controller.js +0 -64
- data/lib/geoblacklight/download/csv_download.rb +0 -22
- data/lib/geoblacklight/download/geojson_download.rb +0 -24
- data/lib/geoblacklight/download/geotiff_download.rb +0 -22
- data/lib/geoblacklight/download/kmz_download.rb +0 -24
- data/lib/geoblacklight/download/shapefile_download.rb +0 -22
- data/lib/geoblacklight/download.rb +0 -110
- data/lib/geoblacklight/routes/downloadable.rb +0 -15
- data/spec/controllers/download_controller_spec.rb +0 -99
- data/spec/features/download_layer_spec.rb +0 -96
- data/spec/features/esri_viewer_spec.rb +0 -43
- data/spec/features/index_map_spec.rb +0 -40
- data/spec/features/layer_with_no_references_spec.rb +0 -10
- data/spec/features/linkified_attribute_table_spec.rb +0 -13
- data/spec/features/multiple_downloads_spec.rb +0 -17
- data/spec/features/show_page_download_spec.rb +0 -22
- data/spec/lib/geoblacklight/download/csv_download_spec.rb +0 -21
- data/spec/lib/geoblacklight/download/geojson_download_spec.rb +0 -22
- data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +0 -25
- data/spec/lib/geoblacklight/download/kmz_download_spec.rb +0 -22
- data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +0 -21
- data/spec/lib/geoblacklight/download_spec.rb +0 -188
- data/spec/tasks/geoblacklight_spec.rb +0 -20
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe DownloadController, type: :controller do
|
|
6
|
-
describe "#file" do
|
|
7
|
-
describe "restricted file" do
|
|
8
|
-
it "redirects to login for authentication" do
|
|
9
|
-
get :file, params: {id: "stanford-cg357zz0321-shapefile", format: "zip"}
|
|
10
|
-
expect(response).to have_http_status :unauthorized
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
describe "public file" do
|
|
14
|
-
it "initiates download" do
|
|
15
|
-
allow(controller).to receive(:render) # Needed for testing with Rails 4
|
|
16
|
-
expect(controller).to receive(:send_file)
|
|
17
|
-
get :file, params: {id: "mit-f6rqs4ucovjk2-shapefile", format: "zip"}
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
describe "#show" do
|
|
22
|
-
describe "restricted file" do
|
|
23
|
-
it "redirects to login for authentication" do
|
|
24
|
-
get :show, params: {id: "stanford-cg357zz0321", format: "json"}
|
|
25
|
-
expect(response).to have_http_status :unauthorized
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
describe "public file" do
|
|
29
|
-
let(:shapefile_download) { instance_double(Geoblacklight::ShapefileDownload) }
|
|
30
|
-
|
|
31
|
-
before do
|
|
32
|
-
allow(Geoblacklight::ShapefileDownload).to receive(:new).and_return(shapefile_download)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "initiates download creation" do
|
|
36
|
-
allow(shapefile_download).to receive(:get).and_return("success")
|
|
37
|
-
get :show, params: {id: "mit-f6rqs4ucovjk2", type: "shapefile"}
|
|
38
|
-
expect(response).to have_http_status :ok
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context "when requesting GeoJSON files" do
|
|
43
|
-
let(:id) { "tufts-cambridgegrid100-04" }
|
|
44
|
-
let(:type) { "geojson" }
|
|
45
|
-
let(:geojson_download) { instance_double(Geoblacklight::GeojsonDownload) }
|
|
46
|
-
|
|
47
|
-
before do
|
|
48
|
-
allow(geojson_download).to receive(:get).and_return("file.json")
|
|
49
|
-
allow(Geoblacklight::GeojsonDownload).to receive(:new).and_return(geojson_download)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "downloads the files and notifies the user" do
|
|
53
|
-
expect(Geoblacklight::GeojsonDownload).to receive(:new)
|
|
54
|
-
get :show, params: {id: id, type: type}
|
|
55
|
-
|
|
56
|
-
expect(response.body).to include "success"
|
|
57
|
-
expect(response.body).to include "Your file file.json is ready for download"
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
context "when requesting GeoTIFF files" do
|
|
62
|
-
let(:id) { "tufts-cambridgegrid100-04" }
|
|
63
|
-
let(:type) { "geotiff" }
|
|
64
|
-
let(:geotiff_download) { instance_double(Geoblacklight::GeotiffDownload) }
|
|
65
|
-
|
|
66
|
-
before do
|
|
67
|
-
allow(geotiff_download).to receive(:get).and_return("file.tiff")
|
|
68
|
-
allow(Geoblacklight::GeotiffDownload).to receive(:new).and_return(geotiff_download)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "downloads the files and notifies the user" do
|
|
72
|
-
expect(Geoblacklight::GeotiffDownload).to receive(:new)
|
|
73
|
-
get :show, params: {id: id, type: type}
|
|
74
|
-
|
|
75
|
-
expect(response.body).to include "success"
|
|
76
|
-
expect(response.body).to include "Your file file.tiff is ready for download"
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "when requesting CSV files" do
|
|
81
|
-
let(:id) { "tufts-cambridgegrid100-04" }
|
|
82
|
-
let(:type) { "csv" }
|
|
83
|
-
let(:csv_download) { instance_double(Geoblacklight::CsvDownload) }
|
|
84
|
-
|
|
85
|
-
before do
|
|
86
|
-
allow(csv_download).to receive(:get).and_return("file.csv")
|
|
87
|
-
allow(Geoblacklight::CsvDownload).to receive(:new).and_return(csv_download)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "downloads the files and notifies the user" do
|
|
91
|
-
expect(Geoblacklight::CsvDownload).to receive(:new)
|
|
92
|
-
get :show, params: {id: id, type: type}
|
|
93
|
-
|
|
94
|
-
expect(response.body).to include "success"
|
|
95
|
-
expect(response.body).to include "Your file file.csv is ready for download"
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.feature "Download layer" do
|
|
6
|
-
let(:shapefile_download) { instance_double(Geoblacklight::ShapefileDownload) }
|
|
7
|
-
let(:kmz_download) { instance_double(Geoblacklight::KmzDownload) }
|
|
8
|
-
let(:csv_download) { instance_double(Geoblacklight::CsvDownload) }
|
|
9
|
-
|
|
10
|
-
before do
|
|
11
|
-
allow(Geoblacklight::ShapefileDownload).to receive(:new).and_return(shapefile_download)
|
|
12
|
-
allow(Geoblacklight::KmzDownload).to receive(:new).and_return(kmz_download)
|
|
13
|
-
allow(Geoblacklight::CsvDownload).to receive(:new).and_return(csv_download)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# cleanup any downloaded files
|
|
17
|
-
after do
|
|
18
|
-
FileUtils.rm("tufts-cambridgegrid100-04-shapefile.zip", force: true)
|
|
19
|
-
FileUtils.rm("tufts-cambridgegrid100-04-kmz.kmz", force: true)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
scenario "clicking initial shapefile download button should trigger download", js: true do
|
|
23
|
-
allow(shapefile_download).to receive(:get).and_return("tufts-cambridgegrid100-04-shapefile.zip")
|
|
24
|
-
visit solr_document_path("tufts-cambridgegrid100-04")
|
|
25
|
-
find("#downloads-button").click
|
|
26
|
-
find('a[data-download-type="shapefile"]', text: "Export Shapefile").click
|
|
27
|
-
expect(page).to have_css(
|
|
28
|
-
'a[href="/download/file/tufts-cambridgegrid100-04-shapefile.zip"]',
|
|
29
|
-
text: "Your file tufts-cambridgegrid100-04-shapefile.zip is ready for download"
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
scenario "failed download should return message with link to layer", js: true do
|
|
34
|
-
allow(shapefile_download).to receive(:get).and_raise(Geoblacklight::Exceptions::ExternalDownloadFailed.new(
|
|
35
|
-
message: "Failed", url: "http://www.example.com/failed"
|
|
36
|
-
))
|
|
37
|
-
visit solr_document_path("mit-f6rqs4ucovjk2")
|
|
38
|
-
find("#downloads-button").click
|
|
39
|
-
find('#downloads-collapse a[data-download-type="shapefile"]', text: "Export Shapefile").click
|
|
40
|
-
expect(page).to have_text "Download failed (shapefile)"
|
|
41
|
-
expect(page).to have_css "div.alert.alert-danger", text: "Sorry, the requested file could not be downloaded."
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
scenario "clicking kmz download button should trigger download", js: true do
|
|
45
|
-
allow(kmz_download).to receive(:get).and_return("tufts-cambridgegrid100-04-kmz.kmz")
|
|
46
|
-
visit solr_document_path("tufts-cambridgegrid100-04")
|
|
47
|
-
find("#downloads-button").click
|
|
48
|
-
find('#downloads-collapse a[data-download-type="kmz"]', text: "Export KMZ").click
|
|
49
|
-
expect(page).to have_css(
|
|
50
|
-
'a[href="/download/file/tufts-cambridgegrid100-04-kmz.kmz"]',
|
|
51
|
-
text: "Your file tufts-cambridgegrid100-04-kmz.kmz is ready for download"
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
scenario "jpg download option should be present under toggle" do
|
|
56
|
-
visit solr_document_path("princeton-02870w62c")
|
|
57
|
-
find("#downloads-button").click
|
|
58
|
-
expect(page).to have_css("#downloads-collapse a", text: "Original JPG")
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
scenario "clicking jpg download button should redirect to external image" do
|
|
62
|
-
visit solr_document_path("princeton-02870w62c")
|
|
63
|
-
find("#downloads-button").click
|
|
64
|
-
expect(page).to have_css(
|
|
65
|
-
"#downloads-collapse a[href='https://iiif-cloud.princeton.edu/iiif/2/6c%2F52%2F12%2F6c5212e81bc845f59bb1cdc740a88bad%2Fintermediate_file/full/full/0/default.jpg']", text: "Original JPG"
|
|
66
|
-
)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
scenario "options should be available under toggle" do
|
|
70
|
-
visit solr_document_path("tufts-cambridgegrid100-04")
|
|
71
|
-
find("#downloads-button").click
|
|
72
|
-
expect(page).to have_css('#downloads-collapse a[data-download-type="shapefile"]', text: "Export Shapefile")
|
|
73
|
-
expect(page).to have_css('#downloads-collapse a[data-download-type="kmz"]', text: "Export KMZ")
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
scenario "restricted layer should not have download available to non logged in user" do
|
|
77
|
-
visit solr_document_path("stanford-cg357zz0321")
|
|
78
|
-
expect(page).to have_css "a", text: "Login to View and Download"
|
|
79
|
-
expect(page).not_to have_css "button", text: "Download"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
scenario "restricted layer should have download available to logged in user" do
|
|
83
|
-
sign_in
|
|
84
|
-
visit solr_document_path("stanford-cg357zz0321")
|
|
85
|
-
expect(page).not_to have_css "a", text: "Login to view and download"
|
|
86
|
-
expect(page).to have_css "button", text: "Download"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
scenario "layer with direct download and wms/wfs should include all download types" do
|
|
90
|
-
sign_in
|
|
91
|
-
visit solr_document_path("stanford-cg357zz0321")
|
|
92
|
-
find("#downloads-button").click
|
|
93
|
-
expect(page).to have_css("#downloads-collapse a", text: "Original")
|
|
94
|
-
expect(page).to have_css("#downloads-collapse a", text: "Export")
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.feature "feature_layer reference", js: true do
|
|
6
|
-
scenario "displays image map layer" do
|
|
7
|
-
skip "spec depend on potentially flaky external services"
|
|
8
|
-
visit solr_document_path "32653ed6-8d83-4692-8a06-bf13ffe2c018"
|
|
9
|
-
expect(page).to have_css ".leaflet-control-zoom", visible: true
|
|
10
|
-
expect(page).to have_css "img.leaflet-image-layer", visible: true
|
|
11
|
-
end
|
|
12
|
-
scenario "displays dynamic layer (all layers)" do
|
|
13
|
-
skip "spec depend on potentially flaky external services"
|
|
14
|
-
visit solr_document_path "90f14ff4-1359-4beb-b931-5cb41d20ab90"
|
|
15
|
-
expect(page).to have_css ".leaflet-control-zoom", visible: true
|
|
16
|
-
expect(page).to have_css "img.leaflet-image-layer", visible: true
|
|
17
|
-
end
|
|
18
|
-
scenario "displays dynamic layer (single layer)" do
|
|
19
|
-
skip "spec depend on potentially flaky external services"
|
|
20
|
-
visit solr_document_path "4669301e-b4b2-4c8b-bf40-01b968a2865b"
|
|
21
|
-
expect(page).to have_css ".leaflet-control-zoom", visible: true
|
|
22
|
-
expect(page).to have_css "img.leaflet-image-layer", visible: true
|
|
23
|
-
end
|
|
24
|
-
scenario "displays feature layer" do
|
|
25
|
-
pending "cannot currently test for svg feature"
|
|
26
|
-
visit solr_document_path "f406332e63eb4478a9560ad86ae90327_18"
|
|
27
|
-
expect(page).to have_css ".leaflet-control-zoom", visible: true
|
|
28
|
-
expect(Nokogiri::HTML.parse(page.body).css("g").length).to eq 23
|
|
29
|
-
fail
|
|
30
|
-
end
|
|
31
|
-
scenario "displays tiled map layer" do
|
|
32
|
-
skip "spec depend on potentially flaky external services"
|
|
33
|
-
visit solr_document_path "31567cf1-bad8-4bc5-8d57-44b96c207ecc"
|
|
34
|
-
expect(page).to have_css ".leaflet-control-zoom", visible: true
|
|
35
|
-
expect(page).to have_css "img.leaflet-tile.leaflet-tile-loaded", visible: true
|
|
36
|
-
end
|
|
37
|
-
scenario "displays Esri WMS layer" do
|
|
38
|
-
skip "spec depend on potentially flaky external services"
|
|
39
|
-
visit solr_document_path "purdue-urn-f082acb1-b01e-4a08-9126-fd62a23fd9aa"
|
|
40
|
-
expect(page).to have_css ".leaflet-control-zoom", visible: true
|
|
41
|
-
expect(page).to have_css "img.leaflet-tile.leaflet-tile-loaded", visible: true
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.feature "Index map", js: true do
|
|
6
|
-
# Colors
|
|
7
|
-
default_color = "#7FCDBB"
|
|
8
|
-
selected_color = "#2C7FB8"
|
|
9
|
-
scenario "displays index map viewer (polygon)" do
|
|
10
|
-
skip "Doesn't work for importmaps when headless in CI" if ENV["CI"]
|
|
11
|
-
|
|
12
|
-
visit solr_document_path("stanford-fb897vt9938")
|
|
13
|
-
# Wait until SVG elements are added
|
|
14
|
-
expect(page).to have_css ".leaflet-overlay-pane svg"
|
|
15
|
-
within "#leaflet-viewer" do
|
|
16
|
-
expect(page).to have_css "svg g path:nth-child(2)[fill='#{default_color}']"
|
|
17
|
-
# Click the top-left corner of the polygon instead of the center
|
|
18
|
-
# to prevent it being occluded by other DOM elements (occurs in headless mode)
|
|
19
|
-
find("svg g path:nth-child(2)").click(x: 1, y: 1)
|
|
20
|
-
expect(page).to have_css "svg g path:nth-child(2)[fill='#{selected_color}']"
|
|
21
|
-
first("svg g path").click(x: 1, y: 1)
|
|
22
|
-
expect(page).to have_css "svg g path:nth-child(2)[fill='#{default_color}']"
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
scenario "displays index map viewer (points)" do
|
|
27
|
-
skip "Doesn't work for importmaps when headless in CI" if ENV["CI"]
|
|
28
|
-
|
|
29
|
-
visit solr_document_path("cornell-ny-aerial-photos-1960s")
|
|
30
|
-
# Wait until SVG elements are added
|
|
31
|
-
expect(page).to have_css ".leaflet-overlay-pane svg"
|
|
32
|
-
within "#leaflet-viewer" do
|
|
33
|
-
expect(page).to have_css "svg g path:nth-child(2)[fill='#{default_color}']"
|
|
34
|
-
find("svg g path:nth-child(2)").click(x: 1, y: 1)
|
|
35
|
-
expect(page).to have_css "svg g path:nth-child(2)[fill='#{selected_color}']"
|
|
36
|
-
first("svg g path").click(x: 1, y: 1)
|
|
37
|
-
expect(page).to have_css "svg g path:nth-child(2)[fill='#{default_color}']"
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.feature "Attribute table values", js: true do
|
|
6
|
-
xscenario "are linkified" do
|
|
7
|
-
# ArcGIS server returning an error. Wait until SVG elements are added
|
|
8
|
-
visit solr_document_path "f406332e63eb4478a9560ad86ae90327_18"
|
|
9
|
-
expect(page).to have_css ".leaflet-overlay-pane svg"
|
|
10
|
-
page.first("svg g path").click
|
|
11
|
-
expect(page).to have_css 'td a[href="http://www.minneapolismn.gov/fire/stations/fire_station28"]', text: "http://www.minneapolismn.gov/fire/stations/fire_station28"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.feature "Multiple downloads" do
|
|
6
|
-
feature "when item has multiple downloads in dct_references_s" do
|
|
7
|
-
scenario "downloads are listed in download card" do
|
|
8
|
-
visit solr_document_path "cugir-007950"
|
|
9
|
-
find("#downloads-button").click
|
|
10
|
-
within "#downloads-collapse" do
|
|
11
|
-
expect(page).to have_link "Shapefile", href: "https://cugir-data.s3.amazonaws.com/00/79/50/cugir-007950.zip"
|
|
12
|
-
expect(page).to have_link "PDF", href: "https://cugir-data.s3.amazonaws.com/00/79/50/agBROO.pdf"
|
|
13
|
-
expect(page).to have_link "KMZ", href: "https://cugir-data.s3.amazonaws.com/00/79/50/agBROO2011.kmz"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.feature "Download display on show page" do
|
|
6
|
-
scenario "with download String" do
|
|
7
|
-
visit solr_document_path "2eddde2f-c222-41ca-bd07-2fd74a21f4de"
|
|
8
|
-
find("#downloads-button").click
|
|
9
|
-
within "#downloads-collapse" do
|
|
10
|
-
expect(page).to have_selector(:css, 'a[href="ftp://gdrs.dnr.state.mn.us/gdrs/data/pub/us_mn_state_dnr/fgdb_base_usgs_scanned_topo_100k_drg.zip"]')
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
scenario "with download Array" do
|
|
15
|
-
visit solr_document_path "princeton-sx61dn82p"
|
|
16
|
-
find("#downloads-button").click
|
|
17
|
-
within "#downloads-collapse" do
|
|
18
|
-
expect(page).to have_selector(:css, 'a[href="https://figgy.princeton.edu/downloads/a990e1b4-7f0e-44b8-ae2a-de7e93cdd74a/file/36a2274c-e0c6-4901-a14f-7c422d15e194"]')
|
|
19
|
-
expect(page).to have_selector(:css, 'a[href="https://libimages1.princeton.edu/loris/figgy_prod/2e%2Fa9%2F43%2F2ea943b0bd4348fc9954b299f1b359f6%2Fintermediate_file.jp2/full/full/0/default.jpg"]')
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Geoblacklight::CsvDownload do
|
|
6
|
-
let(:document) { SolrDocument.new(Geoblacklight.configuration.fields.id => "test", :solr_wfs_url => "http://www.example.com/wfs", Geoblacklight.configuration.fields.wxs_identifier => "stanford-test", Geoblacklight.configuration.fields.geometry => "ENVELOPE(-180, 180, 90, -90)") }
|
|
7
|
-
let(:download) { described_class.new(document) }
|
|
8
|
-
describe "#initialize" do
|
|
9
|
-
it "initializes as a CsvDownload object with specific options" do
|
|
10
|
-
expect(download).to be_an described_class
|
|
11
|
-
options = download.instance_variable_get(:@options)
|
|
12
|
-
expect(options[:content_type]).to eq "text/csv"
|
|
13
|
-
expect(options[:request_params][:typeName]).to eq "stanford-test"
|
|
14
|
-
end
|
|
15
|
-
it "merges custom options" do
|
|
16
|
-
download = described_class.new(document, timeout: 33)
|
|
17
|
-
options = download.instance_variable_get(:@options)
|
|
18
|
-
expect(options[:timeout]).to eq 33
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Geoblacklight::GeojsonDownload do
|
|
6
|
-
let(:document) { SolrDocument.new(Geoblacklight.configuration.fields.id => "test", :solr_wfs_url => "http://www.example.com/wfs", Geoblacklight.configuration.fields.wxs_identifier => "stanford-test", Geoblacklight.configuration.fields.geometry => "ENVELOPE(-180, 180, 90, -90)") }
|
|
7
|
-
let(:download) { described_class.new(document) }
|
|
8
|
-
describe "#initialize" do
|
|
9
|
-
it "initializes as a GeojsonDownload object with specific options" do
|
|
10
|
-
expect(download).to be_an described_class
|
|
11
|
-
options = download.instance_variable_get(:@options)
|
|
12
|
-
expect(options[:content_type]).to eq "application/json"
|
|
13
|
-
expect(options[:request_params][:typeName]).to eq "stanford-test"
|
|
14
|
-
expect(options[:extension]).to eq "geojson"
|
|
15
|
-
end
|
|
16
|
-
it "merges custom options" do
|
|
17
|
-
download = described_class.new(document, timeout: 33)
|
|
18
|
-
options = download.instance_variable_get(:@options)
|
|
19
|
-
expect(options[:timeout]).to eq 33
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Geoblacklight::GeotiffDownload do
|
|
6
|
-
let(:document) do
|
|
7
|
-
SolrDocument.new(Geoblacklight.configuration.fields.id => "test", Geoblacklight.configuration.fields.wxs_identifier => "stanford-test",
|
|
8
|
-
Geoblacklight.configuration.fields.geometry => "ENVELOPE(-180, 180, 90, -90)")
|
|
9
|
-
end
|
|
10
|
-
let(:download) { described_class.new(document) }
|
|
11
|
-
describe "#initialize" do
|
|
12
|
-
it "initializes as a GeotiffDownload object with specific options" do
|
|
13
|
-
expect(download).to be_an described_class
|
|
14
|
-
options = download.instance_variable_get(:@options)
|
|
15
|
-
expect(options[:content_type]).to eq "image/geotiff"
|
|
16
|
-
expect(options[:request_params][:layers]).to eq "stanford-test"
|
|
17
|
-
expect(options[:reflect]).to be_truthy
|
|
18
|
-
end
|
|
19
|
-
it "merges custom options" do
|
|
20
|
-
download = described_class.new(document, timeout: 33)
|
|
21
|
-
options = download.instance_variable_get(:@options)
|
|
22
|
-
expect(options[:timeout]).to eq 33
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Geoblacklight::KmzDownload do
|
|
6
|
-
let(:document) { SolrDocument.new(Geoblacklight.configuration.fields.id => "test", :solr_wfs_url => "http://www.example.com/wfs", Geoblacklight.configuration.fields.wxs_identifier => "stanford-test", Geoblacklight.configuration.fields.geometry => "ENVELOPE(-180, 180, 90, -90)") }
|
|
7
|
-
let(:download) { described_class.new(document) }
|
|
8
|
-
describe "#initialize" do
|
|
9
|
-
it "initializes as a KmzDownload object with specific options" do
|
|
10
|
-
expect(download).to be_an described_class
|
|
11
|
-
options = download.instance_variable_get(:@options)
|
|
12
|
-
expect(options[:content_type]).to eq "application/vnd.google-earth.kmz"
|
|
13
|
-
expect(options[:request_params][:layers]).to eq "stanford-test"
|
|
14
|
-
expect(options[:request_params][:bbox]).to eq "-180.0, -90.0, 180.0, 90.0"
|
|
15
|
-
end
|
|
16
|
-
it "merges custom options" do
|
|
17
|
-
download = described_class.new(document, timeout: 33)
|
|
18
|
-
options = download.instance_variable_get(:@options)
|
|
19
|
-
expect(options[:timeout]).to eq 33
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Geoblacklight::ShapefileDownload do
|
|
6
|
-
let(:document) { SolrDocument.new(Geoblacklight.configuration.fields.id => "test", :solr_wfs_url => "http://www.example.com/wfs", Geoblacklight.configuration.fields.wxs_identifier => "stanford-test", Geoblacklight.configuration.fields.geometry => "ENVELOPE(-180, 180, 90, -90)") }
|
|
7
|
-
let(:download) { described_class.new(document) }
|
|
8
|
-
describe "#initialize" do
|
|
9
|
-
it "initializes as a ShapefileDownload object with specific options" do
|
|
10
|
-
expect(download).to be_an described_class
|
|
11
|
-
options = download.instance_variable_get(:@options)
|
|
12
|
-
expect(options[:content_type]).to eq "application/zip"
|
|
13
|
-
expect(options[:request_params][:typeName]).to eq "stanford-test"
|
|
14
|
-
end
|
|
15
|
-
it "merges custom options" do
|
|
16
|
-
download = described_class.new(document, timeout: 33)
|
|
17
|
-
options = download.instance_variable_get(:@options)
|
|
18
|
-
expect(options[:timeout]).to eq 33
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "spec_helper"
|
|
4
|
-
|
|
5
|
-
RSpec.describe Geoblacklight::Download do
|
|
6
|
-
subject(:download) { described_class.new(document, options) }
|
|
7
|
-
|
|
8
|
-
let(:faraday_connection) { instance_double(Faraday::Connection) }
|
|
9
|
-
let(:faraday_response) { instance_double(Faraday::Response) }
|
|
10
|
-
let(:references_field) { Geoblacklight.configuration.fields.references }
|
|
11
|
-
let(:document) do
|
|
12
|
-
SolrDocument.new(:"#{Geoblacklight.configuration.fields.id}" => "test",
|
|
13
|
-
references_field => {"http://www.opengis.net/def/serviceType/ogc/wms" => "http://www.example.com/wms"}.to_json)
|
|
14
|
-
end
|
|
15
|
-
let(:options) { {type: "shapefile", extension: "zip", service_type: "wms", content_type: "application/zip"} }
|
|
16
|
-
|
|
17
|
-
describe "#initialize" do
|
|
18
|
-
it "initializes as a Download object" do
|
|
19
|
-
expect(download).to be_a described_class
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe "#downloadable?" do
|
|
24
|
-
before do
|
|
25
|
-
allow(document).to receive(:downloadable?).and_return(true)
|
|
26
|
-
end
|
|
27
|
-
it "determines whether or not the resource can be downloaded" do
|
|
28
|
-
expect(download.downloadable?).to be true
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe "#file_name" do
|
|
33
|
-
it "gives the file name with path and extension" do
|
|
34
|
-
expect(download.file_name).to eq "test-shapefile.zip"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "#file_path" do
|
|
39
|
-
it "returns the path with name and extension" do
|
|
40
|
-
expect(download.class.file_path).to eq Rails.root.join("tmp", "cache", "downloads").to_s
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "is configurable" do
|
|
44
|
-
expect(Geoblacklight.configuration).to receive(:download_path).and_return("configured/path")
|
|
45
|
-
expect(download.class.file_path).to eq "configured/path"
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
describe "#download_exists?" do
|
|
50
|
-
it "returns false if file does not exist" do
|
|
51
|
-
expect(File).to receive(:file?).and_return(false)
|
|
52
|
-
expect(download.download_exists?).to be_falsey
|
|
53
|
-
end
|
|
54
|
-
it "returns true if file does not exist" do
|
|
55
|
-
expect(File).to receive(:file?).and_return(true)
|
|
56
|
-
expect(download.download_exists?).to be_truthy
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
describe "#get" do
|
|
60
|
-
before do
|
|
61
|
-
allow(File).to receive(:file?).and_return(true)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "returns filename if download exists" do
|
|
65
|
-
expect(download.get).to eq download.file_name
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "when the file has not already been downloaded" do
|
|
69
|
-
let(:connection) { instance_double(Faraday::Connection) }
|
|
70
|
-
let(:response) { instance_double(Faraday::Response) }
|
|
71
|
-
|
|
72
|
-
before do
|
|
73
|
-
allow(File).to receive(:file?).and_return(false)
|
|
74
|
-
allow(connection).to receive(:get).and_return(object: "file")
|
|
75
|
-
allow(Faraday).to receive(:new).and_return(connection)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "calls create_download_file if it does not exist" do
|
|
79
|
-
allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", "wb").and_return("")
|
|
80
|
-
allow(File).to receive(:rename)
|
|
81
|
-
|
|
82
|
-
expect(download.get).to eq "test-shapefile.zip"
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
describe "#create_download_file" do
|
|
87
|
-
let(:file) { instance_double(File) }
|
|
88
|
-
let(:shapefile) { OpenStruct.new(headers: {"content-type" => "application/zip"}) }
|
|
89
|
-
let(:connection) { instance_double(Faraday::Connection) }
|
|
90
|
-
let(:response) { instance_double(Faraday::Response) }
|
|
91
|
-
|
|
92
|
-
before do
|
|
93
|
-
allow(file).to receive(:write)
|
|
94
|
-
allow(Faraday).to receive(:new).and_return(connection)
|
|
95
|
-
allow(connection).to receive(:get).and_return(shapefile)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "creates the file, write it, and then rename from tmp if everything is ok" do
|
|
99
|
-
allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", "wb").and_yield(file).and_return("")
|
|
100
|
-
allow(File).to receive(:rename)
|
|
101
|
-
|
|
102
|
-
expect(download.create_download_file).to eq download.file_name
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context "when the file received is not of the type requested" do
|
|
106
|
-
let(:bad_file) { OpenStruct.new(headers: {"content-type" => "bad/file"}) }
|
|
107
|
-
|
|
108
|
-
before do
|
|
109
|
-
allow(connection).to receive(:get).and_return(bad_file)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it "creates the file in fs and delete it if the content headers are not correct" do
|
|
113
|
-
allow(File).to receive(:delete).with("#{download.file_path_and_name}.tmp").and_return(nil)
|
|
114
|
-
|
|
115
|
-
expect do
|
|
116
|
-
download.create_download_file
|
|
117
|
-
end.to raise_error(Geoblacklight::Exceptions::ExternalDownloadFailed,
|
|
118
|
-
"Wrong download type")
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
context "when the MIME type has more information encoded" do
|
|
123
|
-
let(:geojson) { OpenStruct.new(headers: {"content-type" => "application/json;charset=utf-8"}) }
|
|
124
|
-
|
|
125
|
-
before do
|
|
126
|
-
allow(connection).to receive(:get).and_return(geojson)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
it "accepts response MIME type that is more complex than requested" do
|
|
130
|
-
allow(File).to receive(:open).with("#{download.file_path_and_name}.tmp", "wb").and_return("")
|
|
131
|
-
allow(File).to receive(:rename)
|
|
132
|
-
|
|
133
|
-
expect(download.create_download_file).to eq download.file_name
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
describe "#initiate_download" do
|
|
138
|
-
let(:faraday_request) { instance_double(Faraday::Request) }
|
|
139
|
-
let(:faraday_request_options) { OpenStruct.new(timeout: nil, open_timeout: nil) }
|
|
140
|
-
|
|
141
|
-
before do
|
|
142
|
-
allow(faraday_request).to receive(:params=)
|
|
143
|
-
allow(faraday_request).to receive(:options).and_return(faraday_request_options)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "request download from server" do
|
|
147
|
-
allow(faraday_connection).to receive(:get).and_yield(faraday_request).and_return(faraday_response)
|
|
148
|
-
allow(Faraday).to receive(:new).with(url: "http://www.example.com/wms").and_return(faraday_connection)
|
|
149
|
-
|
|
150
|
-
expect(download.initiate_download).to eq faraday_response
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
it "raises Geoblacklight::Exceptions::ExternalDownloadFailed with a connection failure" do
|
|
154
|
-
expect(faraday_connection).to receive(:url_prefix).and_return "http://www.example.com/wms"
|
|
155
|
-
expect(faraday_connection).to receive(:get).and_raise(Faraday::ConnectionFailed.new("Failed"))
|
|
156
|
-
expect(Faraday).to receive(:new).with(url: "http://www.example.com/wms").and_return(faraday_connection)
|
|
157
|
-
expect { download.initiate_download }.to raise_error(Geoblacklight::Exceptions::ExternalDownloadFailed)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
it "raises Geoblacklight::Exceptions::ExternalDownloadFailed with a connection timout" do
|
|
161
|
-
expect(faraday_connection).to receive(:url_prefix).and_return "http://www.example.com/wms"
|
|
162
|
-
expect(faraday_connection).to receive(:get).and_raise(Faraday::TimeoutError)
|
|
163
|
-
expect(Faraday).to receive(:new).with(url: "http://www.example.com/wms").and_return(faraday_connection)
|
|
164
|
-
expect { download.initiate_download }.to raise_error(Geoblacklight::Exceptions::ExternalDownloadFailed)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
describe "#url_with_params" do
|
|
168
|
-
let(:options) do
|
|
169
|
-
{
|
|
170
|
-
service_type: "wms",
|
|
171
|
-
request_params: {
|
|
172
|
-
service: "wfs",
|
|
173
|
-
version: "2.0.0",
|
|
174
|
-
request: "GetFeature",
|
|
175
|
-
srsName: "EPSG:4326",
|
|
176
|
-
outputformat: "SHAPE-ZIP",
|
|
177
|
-
typeName: ""
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
it "creates a download url with params" do
|
|
183
|
-
expect(download.url_with_params).to eq "http://www.example.com/wms/?ser" \
|
|
184
|
-
"vice=wfs&version=2.0.0&request=GetFeature&srsName=EPSG%3A4326&output" \
|
|
185
|
-
"format=SHAPE-ZIP&typeName="
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
end
|