geoblacklight 0.12.1 → 1.0.0.pre1
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/.hound.yml +8 -0
- data/.jshintignore +2 -0
- data/.jshintrc +67 -0
- data/.rubocop.yml +29 -3
- data/Gemfile +20 -16
- data/README.md +1 -0
- data/Rakefile +3 -2
- data/app/assets/javascripts/geoblacklight/basemaps.js +0 -9
- data/app/assets/javascripts/geoblacklight/controls.js +1 -0
- data/app/assets/javascripts/geoblacklight/controls/opacity.js +8 -0
- data/app/assets/javascripts/geoblacklight/geoblacklight.js +3 -2
- data/app/assets/javascripts/geoblacklight/viewers.js +1 -1
- data/app/assets/javascripts/geoblacklight/viewers/esri.js +2 -3
- data/app/assets/javascripts/geoblacklight/viewers/esri/dynamic_map_layer.js +2 -2
- data/app/assets/javascripts/geoblacklight/viewers/esri/feature_layer.js +1 -5
- data/app/assets/javascripts/geoblacklight/viewers/iiif.js +1 -1
- data/app/assets/javascripts/geoblacklight/viewers/map.js +1 -9
- data/app/assets/javascripts/geoblacklight/viewers/viewer.js +42 -1
- data/app/assets/javascripts/geoblacklight/viewers/wms.js +1 -1
- data/app/assets/stylesheets/geoblacklight/modules/toolbar.scss +4 -0
- data/app/helpers/geoblacklight_helper.rb +28 -14
- data/app/models/concerns/geoblacklight/solr_document.rb +20 -11
- data/{lib/geoblacklight/search_builder.rb → app/models/concerns/geoblacklight/spatial_search_behavior.rb} +6 -8
- data/app/presenters/geoblacklight/document_presenter.rb +14 -7
- data/app/views/catalog/_document_split.html.erb +1 -1
- data/app/views/catalog/_downloads.html.erb +46 -38
- data/app/views/catalog/_facet_tag_item.html.erb +1 -1
- data/app/views/catalog/_facet_tag_layout.html.erb +1 -1
- data/app/views/catalog/_header_icons.html.erb +3 -0
- data/app/views/catalog/_home_text.html.erb +5 -5
- data/app/views/catalog/_index_split_default.html.erb +5 -7
- data/app/views/catalog/_search_form_no_navbar.html.erb +2 -2
- data/app/views/catalog/_show_default_viewer_container.html.erb +2 -2
- data/app/views/catalog/_show_header_default.html.erb +1 -3
- data/app/views/catalog/_web_services_wfs.html.erb +1 -1
- data/app/views/catalog/_web_services_wms.html.erb +1 -1
- data/config/jetty.yml +1 -1
- data/config/locales/geoblacklight.en.yml +1 -0
- data/geoblacklight.gemspec +4 -4
- data/lib/generators/geoblacklight/install_generator.rb +34 -3
- data/lib/generators/geoblacklight/templates/catalog_controller.rb +36 -31
- data/lib/generators/geoblacklight/templates/config/jetty.yml +1 -1
- data/lib/generators/geoblacklight/templates/geoblacklight.js +1 -0
- data/lib/generators/geoblacklight/templates/{geoblacklight.css.scss → geoblacklight.scss} +0 -0
- data/lib/generators/geoblacklight/templates/settings.yml +42 -2
- data/lib/geoblacklight.rb +1 -2
- data/lib/geoblacklight/constants.rb +1 -1
- data/lib/geoblacklight/download.rb +8 -7
- data/lib/geoblacklight/download/geojson_download.rb +1 -1
- data/lib/geoblacklight/download/geotiff_download.rb +1 -1
- data/lib/geoblacklight/download/kmz_download.rb +1 -1
- data/lib/geoblacklight/download/shapefile_download.rb +1 -1
- data/lib/geoblacklight/geoblacklight_helper_behavior.rb +4 -10
- data/lib/geoblacklight/metadata.rb +3 -6
- data/lib/geoblacklight/references.rb +2 -2
- data/lib/geoblacklight/routes.rb +3 -17
- data/lib/geoblacklight/routes/downloadable.rb +14 -0
- data/lib/geoblacklight/routes/exportable.rb +16 -0
- data/lib/geoblacklight/routes/wms.rb +13 -0
- data/lib/geoblacklight/version.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +1 -1
- data/spec/controllers/download_controller_spec.rb +7 -1
- data/spec/features/bookmarks_spec.rb +1 -1
- data/spec/features/configurable_basemap_spec.rb +9 -8
- data/spec/features/download_layer_spec.rb +33 -15
- data/spec/features/esri_viewer_spec.rb +9 -8
- data/spec/features/exports_spec.rb +3 -3
- data/spec/features/home_page_spec.rb +1 -1
- data/spec/features/iiif_viewer_spec.rb +1 -1
- data/spec/features/layer_inspection_spec.rb +2 -2
- data/spec/features/layer_opacity_spec.rb +7 -2
- data/spec/features/layer_preview_spec.rb +2 -2
- data/spec/features/metadata_panel_spec.rb +3 -3
- data/spec/features/saved_searches_spec.rb +1 -1
- data/spec/features/search_bar_spec.rb +2 -2
- data/spec/features/show_page_metadata_spec.rb +1 -1
- data/spec/features/split_view.html.erb_spec.rb +6 -5
- data/spec/features/web_services_modal_spec.rb +3 -3
- data/spec/helpers/geoblacklight_helpers_spec.rb +71 -3
- data/spec/lib/geoblacklight/document_presenter_spec.rb +41 -13
- data/spec/lib/geoblacklight/download_spec.rb +9 -1
- data/spec/lib/geoblacklight/geoblacklight_helper_behavior_spec.rb +12 -9
- data/spec/lib/geoblacklight/item_viewer_spec.rb +4 -3
- data/spec/lib/geoblacklight/references_spec.rb +22 -18
- data/spec/lib/geoblacklight/view_helper_override_spec.rb +1 -1
- data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +1 -1
- data/spec/lib/geoblacklight/wms_layer_spec.rb +1 -1
- data/spec/models/concerns/geoblacklight/solr_document/carto_db_spec.rb +7 -1
- data/spec/models/concerns/geoblacklight/solr_document_spec.rb +34 -11
- data/spec/{lib/geoblacklight/search_builder_spec.rb → models/concerns/geoblacklight/spatial_search_behavior_spec.rb} +10 -15
- data/spec/spec_helper.rb +6 -6
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- metadata +25 -22
@@ -2,30 +2,58 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Geoblacklight::DocumentPresenter do
|
4
4
|
let(:request_context) { double(add_facet_params: '') }
|
5
|
-
let(:
|
5
|
+
let(:blacklight_config) do
|
6
|
+
Blacklight::Configuration.new.configure do |config|
|
7
|
+
config.add_index_field 'layer_id_s'
|
8
|
+
config.add_index_field 'index_display'
|
9
|
+
config.add_index_field 'period'
|
10
|
+
config.add_index_field 'multi_display'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
let(:solr_fields) { Settings.FIELDS }
|
6
14
|
subject { presenter }
|
7
15
|
let(:presenter) do
|
8
|
-
described_class.new(document, request_context,
|
16
|
+
described_class.new(document, request_context, blacklight_config)
|
9
17
|
end
|
10
18
|
|
11
19
|
let(:document) do
|
12
|
-
SolrDocument.new(
|
20
|
+
SolrDocument.new(
|
21
|
+
id: 1,
|
22
|
+
layer_id_s: 'druid:abc123',
|
23
|
+
non_index_field: 'do not render',
|
24
|
+
period: 'Ends with period.',
|
25
|
+
multi_display: %w(blue blah)
|
26
|
+
)
|
13
27
|
end
|
14
28
|
|
15
|
-
describe '#
|
16
|
-
|
29
|
+
describe '#index_fields_display' do
|
30
|
+
let(:rendered_index_text) { subject.index_fields_display }
|
31
|
+
let(:multi_valued_text) { document['multi_display'].join(' and ') }
|
32
|
+
let(:combined_fields) { document['layer_id_s'] + '. ' + document['period'] }
|
33
|
+
|
34
|
+
context 'with multi-valued field' do
|
35
|
+
it 'each value is separated by comma' do
|
36
|
+
expect(rendered_index_text).to include(multi_valued_text)
|
37
|
+
end
|
17
38
|
end
|
18
|
-
|
19
|
-
|
39
|
+
context 'with document fields not configured as index field' do
|
40
|
+
it 'does not render' do
|
41
|
+
expect(rendered_index_text).not_to include(document['non_index_field'])
|
42
|
+
end
|
20
43
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
44
|
+
context 'with multiple document index fields present' do
|
45
|
+
it 'separates fields by period followed by a space' do
|
46
|
+
expect(rendered_index_text).to include(combined_fields)
|
47
|
+
end
|
48
|
+
context 'with index field ending in period' do
|
49
|
+
it 'renders only 1 period' do
|
50
|
+
expect(rendered_index_text).to include(document['period'] + ' ')
|
25
51
|
end
|
26
52
|
end
|
27
|
-
|
28
|
-
|
53
|
+
end
|
54
|
+
context 'with document empty configured index field' do
|
55
|
+
it 'does not render a period followed by a space' do
|
56
|
+
expect(rendered_index_text).not_to include('. .')
|
29
57
|
end
|
30
58
|
end
|
31
59
|
end
|
@@ -4,7 +4,8 @@ describe Geoblacklight::Download do
|
|
4
4
|
let(:response) { double('response') }
|
5
5
|
let(:get) { double('get') }
|
6
6
|
let(:body) { double('body') }
|
7
|
-
let(:
|
7
|
+
let(:references_field) { Settings.FIELDS.REFERENCES }
|
8
|
+
let(:document) { SolrDocument.new(layer_slug_s: 'test', references_field => { 'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://www.example.com/wms' }.to_json) }
|
8
9
|
let(:options) { { type: 'shapefile', extension: 'zip', service_type: 'wms', content_type: 'application/zip' } }
|
9
10
|
let(:download) { Geoblacklight::ShapefileDownload.new(document, options) }
|
10
11
|
|
@@ -64,6 +65,13 @@ describe Geoblacklight::Download do
|
|
64
65
|
expect(File).to receive(:rename)
|
65
66
|
expect(download.create_download_file).to eq download.file_name
|
66
67
|
end
|
68
|
+
it 'accepts response MIME type that is more complex than requested' do
|
69
|
+
geojson = OpenStruct.new(headers: { 'content-type' => 'application/json;charset=utf-8' })
|
70
|
+
expect(download).to receive(:initiate_download).and_return(geojson)
|
71
|
+
expect(File).to receive(:open).with("#{download.file_path_and_name}.tmp", 'wb').and_return('')
|
72
|
+
expect(File).to receive(:rename)
|
73
|
+
expect(download.create_download_file).to eq download.file_name
|
74
|
+
end
|
67
75
|
end
|
68
76
|
describe '#initiate_download' do
|
69
77
|
it 'request download from server' do
|
@@ -5,17 +5,20 @@ describe Geoblacklight::GeoblacklightHelperBehavior do
|
|
5
5
|
Class.new.extend(described_class)
|
6
6
|
end
|
7
7
|
|
8
|
-
describe '#
|
9
|
-
|
8
|
+
describe '#geoblacklight_present' do
|
9
|
+
before do
|
10
10
|
expect(dummy_class).to receive(:presenter)
|
11
|
-
.and_return(double(
|
12
|
-
expect(dummy_class.wxs_identifier).to eq 'druid:abc123'
|
11
|
+
.and_return(double(fake_name: 'druid:abc123'))
|
13
12
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
context 'as a Symbol' do
|
14
|
+
it 'calls defined presenter class' do
|
15
|
+
expect(dummy_class.geoblacklight_present(:fake_name)).to eq 'druid:abc123'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
context 'as a String' do
|
19
|
+
it 'calls defined presenter class' do
|
20
|
+
expect(dummy_class.geoblacklight_present('fake_name')).to eq 'druid:abc123'
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -4,6 +4,7 @@ describe Geoblacklight::ItemViewer do
|
|
4
4
|
let(:document) { SolrDocument.new(document_attributes) }
|
5
5
|
let(:document_attributes) { {} }
|
6
6
|
let(:references) { document.references }
|
7
|
+
let(:references_field) { Settings.FIELDS.REFERENCES }
|
7
8
|
let(:item_viewer) { described_class.new(references) }
|
8
9
|
describe 'viewer_preference' do
|
9
10
|
describe 'for no references' do
|
@@ -14,7 +15,7 @@ describe Geoblacklight::ItemViewer do
|
|
14
15
|
describe 'for wms reference' do
|
15
16
|
let(:document_attributes) do
|
16
17
|
{
|
17
|
-
|
18
|
+
references_field => {
|
18
19
|
'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://www.example.com/wms',
|
19
20
|
'http://iiif.io/api/image' => 'http://www.example.com/iiif'
|
20
21
|
}.to_json
|
@@ -27,7 +28,7 @@ describe Geoblacklight::ItemViewer do
|
|
27
28
|
describe 'for iiif only reference' do
|
28
29
|
let(:document_attributes) do
|
29
30
|
{
|
30
|
-
|
31
|
+
references_field => {
|
31
32
|
'http://iiif.io/api/image' => 'http://www.example.com/iiif'
|
32
33
|
}.to_json
|
33
34
|
}
|
@@ -39,7 +40,7 @@ describe Geoblacklight::ItemViewer do
|
|
39
40
|
describe 'for tiled map layer reference' do
|
40
41
|
let(:document_attributes) do
|
41
42
|
{
|
42
|
-
|
43
|
+
references_field => {
|
43
44
|
'urn:x-esri:serviceType:ArcGIS#TiledMapLayer' => 'http://www.example.com/MapServer'
|
44
45
|
}.to_json
|
45
46
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Geoblacklight::References do
|
4
|
+
let(:references_field) { Settings.FIELDS.REFERENCES }
|
5
|
+
let(:file_format_field) { Settings.FIELDS.FILE_FORMAT }
|
4
6
|
let(:typical_ogp_shapefile) do
|
5
7
|
described_class.new(
|
6
8
|
SolrDocument.new(
|
7
|
-
|
8
|
-
|
9
|
+
file_format_field => 'Shapefile',
|
10
|
+
references_field => {
|
9
11
|
'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://hgl.harvard.edu:8080/geoserver/wms',
|
10
12
|
'http://www.opengis.net/def/serviceType/ogc/wfs' => 'http://hgl.harvard.edu:8080/geoserver/wfs'
|
11
13
|
}.to_json
|
@@ -15,16 +17,16 @@ describe Geoblacklight::References do
|
|
15
17
|
let(:no_service_shapefile) do
|
16
18
|
described_class.new(
|
17
19
|
SolrDocument.new(
|
18
|
-
|
19
|
-
|
20
|
+
file_format_field => 'Shapefile',
|
21
|
+
references_field => {}.to_json
|
20
22
|
)
|
21
23
|
)
|
22
24
|
end
|
23
25
|
let(:typical_ogp_geotiff) do
|
24
26
|
described_class.new(
|
25
27
|
SolrDocument.new(
|
26
|
-
|
27
|
-
|
28
|
+
file_format_field => 'GeoTIFF',
|
29
|
+
references_field => {
|
28
30
|
'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://hgl.harvard.edu:8080/geoserver/wms',
|
29
31
|
'http://www.opengis.net/def/serviceType/ogc/wfs' => 'http://hgl.harvard.edu:8080/geoserver/wfs'
|
30
32
|
}.to_json
|
@@ -34,8 +36,8 @@ describe Geoblacklight::References do
|
|
34
36
|
let(:typical_arcgrid) do
|
35
37
|
described_class.new(
|
36
38
|
SolrDocument.new(
|
37
|
-
|
38
|
-
|
39
|
+
file_format_field => 'ArcGRID',
|
40
|
+
references_field => {
|
39
41
|
'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://hgl.harvard.edu:8080/geoserver/wms',
|
40
42
|
'http://www.opengis.net/def/serviceType/ogc/wfs' => 'http://hgl.harvard.edu:8080/geoserver/wfs'
|
41
43
|
}.to_json
|
@@ -45,8 +47,8 @@ describe Geoblacklight::References do
|
|
45
47
|
let(:complex_shapefile) do
|
46
48
|
described_class.new(
|
47
49
|
SolrDocument.new(
|
48
|
-
|
49
|
-
|
50
|
+
file_format_field => 'Shapefile',
|
51
|
+
references_field => {
|
50
52
|
'http://schema.org/downloadUrl' => 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip',
|
51
53
|
'http://www.isotc211.org/schemas/2005/gmd/' => 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/iso19139.xml',
|
52
54
|
'http://www.loc.gov/mods/v3' => 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/mods.xml',
|
@@ -59,17 +61,19 @@ describe Geoblacklight::References do
|
|
59
61
|
end
|
60
62
|
let(:direct_download_only) do
|
61
63
|
described_class.new(
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
SolrDocument.new(
|
65
|
+
file_format_field => 'GeoTIFF',
|
66
|
+
references_field => {
|
67
|
+
'http://schema.org/downloadUrl' => 'http://example.com/layer-id-geotiff.tiff'
|
68
|
+
}.to_json
|
69
|
+
)
|
66
70
|
)
|
67
71
|
end
|
68
72
|
let(:simple_iiif_image) do
|
69
73
|
described_class.new(
|
70
74
|
SolrDocument.new(
|
71
|
-
|
72
|
-
|
75
|
+
file_format_field => 'Raster',
|
76
|
+
references_field => {
|
73
77
|
'http://schema.org/url' => 'http://arks.princeton.edu/ark:/88435/02870w62c',
|
74
78
|
'http://iiif.io/api/image' => 'http://libimages.princeton.edu/loris2/pudl0076%2Fmap_pownall%2F00000001.jp2/info.json'
|
75
79
|
}.to_json
|
@@ -82,7 +86,7 @@ describe Geoblacklight::References do
|
|
82
86
|
)
|
83
87
|
end
|
84
88
|
describe '#initialize' do
|
85
|
-
it 'parses
|
89
|
+
it 'parses configured references field to @refs' do
|
86
90
|
expect(typical_ogp_shapefile.instance_variable_get(:@refs)).to be_an Array
|
87
91
|
end
|
88
92
|
it 'empty references return an empty array' do
|
@@ -91,7 +95,7 @@ describe Geoblacklight::References do
|
|
91
95
|
expect(empty_refs).to eq []
|
92
96
|
end
|
93
97
|
it 'sets @references_field' do
|
94
|
-
expect(typical_ogp_shapefile.reference_field).to eq
|
98
|
+
expect(typical_ogp_shapefile.reference_field).to eq references_field
|
95
99
|
expect(custom_fields.reference_field).to eq :new_ref_field
|
96
100
|
end
|
97
101
|
end
|
@@ -25,7 +25,7 @@ describe Geoblacklight::FeatureInfoResponse do
|
|
25
25
|
|
26
26
|
describe '#format' do
|
27
27
|
it 'returns a formated response' do
|
28
|
-
expect(response.format).
|
28
|
+
expect(response.format).not_to be_nil
|
29
29
|
expect(response.format[:values].length).to eq 2
|
30
30
|
expect(response.format[:values][0]).to eq %w(Header1 value1)
|
31
31
|
expect(response.format[:values][1]).to eq %w(Header2 value2)
|
@@ -18,7 +18,7 @@ describe Geoblacklight::WmsLayer do
|
|
18
18
|
describe '#search_params' do
|
19
19
|
it 'returns all params except URL plus default params' do
|
20
20
|
expect(wms_layer.search_params.length).to eq 8
|
21
|
-
expect(wms_layer.search_params).
|
21
|
+
expect(wms_layer.search_params).not_to include 'URL' => 'http://www.example.com'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -2,6 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Geoblacklight::SolrDocument::CartoDb do
|
4
4
|
let(:subject) { SolrDocument.new }
|
5
|
+
let(:geojson_download) { instance_double(Geoblacklight::GeojsonDownload) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
allow(Geoblacklight::GeojsonDownload).to receive(:new).and_return(geojson_download)
|
9
|
+
end
|
10
|
+
|
5
11
|
describe '#cartodb_reference' do
|
6
12
|
it 'returns nil for restricted documents' do
|
7
13
|
expect(subject).to receive(:public?).and_return(false)
|
@@ -21,7 +27,7 @@ describe Geoblacklight::SolrDocument::CartoDb do
|
|
21
27
|
expect(subject).to receive(:public?).and_return(true)
|
22
28
|
expect(subject).to receive(:download_types)
|
23
29
|
.and_return(geojson: { 'stuff' => 'stuff' })
|
24
|
-
|
30
|
+
expect(geojson_download)
|
25
31
|
.to receive(:url_with_params)
|
26
32
|
.and_return('http://www.example.com/geojsonDownload')
|
27
33
|
expect(subject.cartodb_reference).to eq 'http://www.example.com/geojsonDownload'
|
@@ -2,6 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Geoblacklight::SolrDocument do
|
4
4
|
let(:document) { SolrDocument.new(document_attributes) }
|
5
|
+
let(:rights_field) { Settings.FIELDS.RIGHTS }
|
6
|
+
let(:provenance_field) { Settings.FIELDS.PROVENANCE }
|
7
|
+
let(:references_field) { Settings.FIELDS.REFERENCES }
|
5
8
|
describe '#available?' do
|
6
9
|
let(:document_attributes) { {} }
|
7
10
|
describe 'a public document' do
|
@@ -21,13 +24,13 @@ describe Geoblacklight::SolrDocument do
|
|
21
24
|
end
|
22
25
|
describe '#public?' do
|
23
26
|
describe 'a public document' do
|
24
|
-
let(:document_attributes) { {
|
27
|
+
let(:document_attributes) { { rights_field => 'PUBLIC' } }
|
25
28
|
it 'is public' do
|
26
29
|
expect(document.public?).to be_truthy
|
27
30
|
end
|
28
31
|
end
|
29
32
|
describe 'a restricted resource' do
|
30
|
-
let(:document_attributes) { {
|
33
|
+
let(:document_attributes) { { rights_field => 'RESTRICTED' } }
|
31
34
|
it 'does not be public' do
|
32
35
|
expect(document.public?).to be_falsey
|
33
36
|
end
|
@@ -37,8 +40,8 @@ describe Geoblacklight::SolrDocument do
|
|
37
40
|
describe 'available direct download' do
|
38
41
|
let(:document_attributes) do
|
39
42
|
{
|
40
|
-
|
41
|
-
|
43
|
+
rights_field => 'Public',
|
44
|
+
references_field => {
|
42
45
|
'http://schema.org/downloadUrl' => 'http://example.com/direct/data.zip'
|
43
46
|
}.to_json
|
44
47
|
}
|
@@ -50,7 +53,7 @@ describe Geoblacklight::SolrDocument do
|
|
50
53
|
end
|
51
54
|
describe '#same_institution?' do
|
52
55
|
describe 'within the same institution' do
|
53
|
-
let(:document_attributes) { {
|
56
|
+
let(:document_attributes) { { provenance_field => 'STANFORD' } }
|
54
57
|
it 'is true' do
|
55
58
|
allow(Settings).to receive('Institution').and_return('Stanford')
|
56
59
|
expect(document.same_institution?).to be_truthy
|
@@ -61,7 +64,7 @@ describe Geoblacklight::SolrDocument do
|
|
61
64
|
end
|
62
65
|
end
|
63
66
|
describe 'within a different institution' do
|
64
|
-
let(:document_attributes) { {
|
67
|
+
let(:document_attributes) { { provenance_field => 'MIT' } }
|
65
68
|
it 'is false' do
|
66
69
|
allow(Settings).to receive('Institution').and_return('Stanford')
|
67
70
|
expect(document.same_institution?).to be_falsey
|
@@ -86,7 +89,7 @@ describe Geoblacklight::SolrDocument do
|
|
86
89
|
describe 'with a direct download' do
|
87
90
|
let(:document_attributes) do
|
88
91
|
{
|
89
|
-
|
92
|
+
references_field => {
|
90
93
|
'http://schema.org/downloadUrl' => 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip'
|
91
94
|
}.to_json
|
92
95
|
}
|
@@ -97,7 +100,7 @@ describe Geoblacklight::SolrDocument do
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
it 'returns nil if no direct download' do
|
100
|
-
expect_any_instance_of(Geoblacklight::Reference).
|
103
|
+
expect_any_instance_of(Geoblacklight::Reference).not_to receive(:to_hash)
|
101
104
|
expect(document.direct_download).to be_nil
|
102
105
|
end
|
103
106
|
end
|
@@ -105,7 +108,7 @@ describe Geoblacklight::SolrDocument do
|
|
105
108
|
describe 'with an hgl download' do
|
106
109
|
let(:document_attributes) do
|
107
110
|
{
|
108
|
-
|
111
|
+
references_field => {
|
109
112
|
'http://schema.org/DownloadAction' => 'http://example.com/harvard'
|
110
113
|
}.to_json
|
111
114
|
}
|
@@ -121,6 +124,26 @@ describe Geoblacklight::SolrDocument do
|
|
121
124
|
end
|
122
125
|
end
|
123
126
|
end
|
127
|
+
describe 'iiif_download' do
|
128
|
+
describe 'with a IIIF download' do
|
129
|
+
let(:document_attributes) do
|
130
|
+
{
|
131
|
+
references_field => {
|
132
|
+
'http://iiif.io/api/image' => 'https://example.edu/images/info.json'
|
133
|
+
}.to_json
|
134
|
+
}
|
135
|
+
end
|
136
|
+
it 'returns a IIIF download hash' do
|
137
|
+
expect(document.iiif_download[:iiif]).to eq('https://example.edu/images/info.json')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
describe 'without a IIIF download' do
|
141
|
+
let(:document_attributes) { {} }
|
142
|
+
it 'returns nil' do
|
143
|
+
expect(document.iiif_download).to be_nil
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
124
147
|
describe 'item_viewer' do
|
125
148
|
let(:document_attributes) { {} }
|
126
149
|
it 'is a ItemViewer' do
|
@@ -131,7 +154,7 @@ describe Geoblacklight::SolrDocument do
|
|
131
154
|
describe 'with a wms reference' do
|
132
155
|
let(:document_attributes) do
|
133
156
|
{
|
134
|
-
|
157
|
+
references_field => {
|
135
158
|
'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://www.example.com/wms'
|
136
159
|
}.to_json
|
137
160
|
}
|
@@ -149,7 +172,7 @@ describe Geoblacklight::SolrDocument do
|
|
149
172
|
describe 'with a wms reference' do
|
150
173
|
let(:document_attributes) do
|
151
174
|
{
|
152
|
-
|
175
|
+
references_field => {
|
153
176
|
'http://www.opengis.net/def/serviceType/ogc/wms' => 'http://www.example.com/wms'
|
154
177
|
}.to_json
|
155
178
|
}
|
@@ -1,27 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Geoblacklight::
|
4
|
-
let(:method_chain) { CatalogController.search_params_logic }
|
3
|
+
describe Geoblacklight::SpatialSearchBehavior do
|
5
4
|
let(:user_params) { Hash.new }
|
6
5
|
let(:solr_params) { Hash.new }
|
6
|
+
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
7
7
|
let(:context) { CatalogController.new }
|
8
8
|
|
9
|
-
let(:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
describe '#initialize' do
|
14
|
-
it 'has add_spatial_params in processor chain once' do
|
15
|
-
expect(subject.processor_chain).to include :add_spatial_params
|
16
|
-
expect(subject.processor_chain
|
17
|
-
.count { |x| x == :add_spatial_params }).to eq 1
|
18
|
-
new_search = described_class.new(subject.processor_chain, context)
|
19
|
-
expect(new_search.processor_chain).to include :add_spatial_params
|
20
|
-
expect(subject.processor_chain
|
21
|
-
.count { |x| x == :add_spatial_params }).to eq 1
|
9
|
+
let(:search_builder_class) do
|
10
|
+
Class.new(Blacklight::SearchBuilder).tap do |klass|
|
11
|
+
include Blacklight::Solr::SearchBuilderBehavior
|
12
|
+
klass.include(described_class)
|
22
13
|
end
|
23
14
|
end
|
24
15
|
|
16
|
+
let(:search_builder) { search_builder_class.new(context) }
|
17
|
+
|
18
|
+
subject { search_builder.with(user_params) }
|
19
|
+
|
25
20
|
describe '#add_spatial_params' do
|
26
21
|
it 'returns the solr_params when no bbox is given' do
|
27
22
|
expect(subject.add_spatial_params(solr_params)).to eq solr_params
|