geo_concerns 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc +8 -0
- data/.gitignore +1 -2
- data/.rubocop.yml +1 -0
- data/.travis.yml +7 -8
- data/Gemfile +1 -3
- data/README.md +3 -2
- data/app/assets/javascripts/geo_concerns/application.js +0 -1
- data/app/assets/javascripts/geo_concerns/bounding_box_selector.js +1 -2
- data/app/assets/javascripts/geo_concerns/es6-modules.js +7 -0
- data/app/assets/javascripts/geo_concerns/geo_concerns_boot.es6 +8 -0
- data/app/assets/javascripts/geo_concerns/relationships.js +3 -0
- data/app/assets/javascripts/geo_concerns/relationships/child_works.es6 +20 -0
- data/app/assets/javascripts/geo_concerns/relationships/parent_works.es6 +20 -0
- data/app/assets/javascripts/geo_concerns/relationships/related_works.es6 +187 -0
- data/app/assets/stylesheets/geo_concerns/related_works.scss +29 -0
- data/app/assets/stylesheets/geo_concerns/thumbnails.scss +12 -6
- data/app/helpers/geo_concerns/populate_metadata_helper.rb +7 -0
- data/app/jobs/delivery_job.rb +18 -0
- data/app/models/concerns/geo_concerns/file_set/derivatives.rb +9 -0
- data/app/models/concerns/geo_concerns/metadata_extraction_helper.rb +7 -8
- data/app/models/concerns/geo_concerns/solr_document_behavior.rb +17 -1
- data/app/presenters/geo_concerns/geo_concerns_show_presenter.rb +9 -1
- data/app/processors/geo_concerns/processors/base_geo_processor.rb +7 -7
- data/app/services/geo_concerns/delivery/geoserver.rb +64 -0
- data/app/services/geo_concerns/delivery_service.rb +11 -0
- data/app/services/geo_concerns/derivative_path.rb +1 -1
- data/app/services/geo_concerns/discovery/abstract_document.rb +4 -4
- data/app/services/geo_concerns/discovery/document_builder/basic_metadata_builder.rb +5 -12
- data/app/services/geo_concerns/discovery/document_builder/date_builder.rb +19 -8
- data/app/services/geo_concerns/discovery/document_builder/spatial_builder.rb +3 -8
- data/app/services/geo_concerns/discovery/geoblacklight_document.rb +32 -17
- data/app/views/curation_concerns/image_works/show.html.erb +1 -5
- data/app/views/curation_concerns/raster_works/_show_actions.html.erb +0 -14
- data/app/views/curation_concerns/raster_works/show.html.erb +1 -5
- data/app/views/curation_concerns/vector_works/show.html.erb +1 -5
- data/app/views/geo_concerns/_form_additional_information.html.erb +8 -8
- data/app/views/geo_concerns/_form_populate_metadata.html.erb +1 -1
- data/app/views/geo_concerns/_form_required_information.html.erb +0 -2
- data/app/views/geo_concerns/_related.html.erb +4 -0
- data/app/views/geo_concerns/file_sets/actions/_image_actions.html.erb +1 -1
- data/app/views/geo_concerns/file_sets/actions/_raster_actions.html.erb +2 -2
- data/app/views/geo_concerns/file_sets/actions/_vector_actions.html.erb +2 -2
- data/app/views/geo_concerns/related/_child_member.html.erb +13 -0
- data/app/views/geo_concerns/related/_child_works.html.erb +24 -0
- data/app/views/geo_concerns/related/_external_metadata_file_member.html.erb +8 -0
- data/app/views/geo_concerns/{_related_external_metadata_files.html.erb → related/_external_metadata_files.html.erb} +1 -2
- data/app/views/geo_concerns/{_related_geo_files.html.erb → related/_geo_files.html.erb} +0 -0
- data/app/views/geo_concerns/related/_new_child_member.html.erb +22 -0
- data/app/views/geo_concerns/related/_new_parent_member.html.erb +13 -0
- data/app/views/geo_concerns/related/_parent_member.html.erb +13 -0
- data/app/views/geo_concerns/related/_parent_works.html.erb +22 -0
- data/geo_concerns.gemspec +9 -6
- data/lib/generators/geo_concerns/install_generator.rb +10 -8
- data/lib/generators/geo_concerns/templates/config/geoserver.yml +17 -0
- data/lib/generators/geo_concerns/templates/config/locales/geo_concerns.en.yml +4 -0
- data/lib/geo_concerns/version.rb +1 -1
- data/spec/factories/collections.rb +17 -0
- data/spec/features/create_raster_work_spec.rb +5 -2
- data/spec/forms/geo_concerns/image_work_form_spec.rb +2 -2
- data/spec/helpers/geo_concerns/populate_metadata_helper_spec.rb +31 -0
- data/spec/jobs/delivery_job_spec.rb +25 -0
- data/spec/models/concerns/geo_concerns/file_set/derivatives_spec.rb +9 -0
- data/spec/models/image_work_spec.rb +1 -1
- data/spec/models/raster_work_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +2 -2
- data/spec/models/vector_work_spec.rb +1 -5
- data/spec/presenters/raster_work_show_presenter_spec.rb +22 -0
- data/spec/processors/geo_concerns/processors/base_geo_processor_spec.rb +14 -5
- data/spec/services/derivative_path_spec.rb +19 -5
- data/spec/services/geo_concerns/delivery/geoserver_spec.rb +72 -0
- data/spec/services/geo_concerns/delivery_service_spec.rb +15 -0
- data/spec/services/geo_concerns/discovery/document_builder_spec.rb +56 -38
- data/spec/services/geo_concerns/discovery/geoblacklight_document_spec.rb +7 -5
- data/template.rb +1 -1
- metadata +94 -19
- data/app/views/geo_concerns/_related_geo_works.html.erb +0 -32
- data/lib/generators/geo_concerns/templates/config/discovery/geoblacklight_schema.json +0 -168
- data/lib/generators/geo_concerns/templates/jobs/characterize_job.rb +0 -19
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
describe GeoConcerns::DeliveryJob do
|
5
|
+
let(:file_set) { double(FileSet, id: 'abc123') }
|
6
|
+
|
7
|
+
context '#perform' do
|
8
|
+
context 'local file' do
|
9
|
+
let(:content_url) { 'file:/somewhere-to-display-copy' }
|
10
|
+
it 'delegates to DeliveryService' do
|
11
|
+
dbl = double
|
12
|
+
expect(GeoConcerns::DeliveryService).to receive(:new).and_return(dbl)
|
13
|
+
expect(dbl).to receive(:publish).with(file_set.id, URI(content_url).path)
|
14
|
+
subject.perform(file_set, content_url)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
context 'remote file' do
|
18
|
+
let(:content_url) { 'http://somewhere/to-display-copy' }
|
19
|
+
it 'errors out' do
|
20
|
+
expect(GeoConcerns::DeliveryService).not_to receive(:new)
|
21
|
+
expect { subject.perform(file_set, content_url) }.to raise_error(NotImplementedError, /Only supports file URLs/)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
shared_examples 'a set of raster derivatives' do
|
4
|
+
before do
|
5
|
+
expect(DeliveryJob).to receive(:perform_later).with(file_set, /file/)
|
6
|
+
end
|
4
7
|
it 'makes a thumbnail' do
|
5
8
|
new_thumb = "#{Rails.root}/tmp/derivatives/#{file_set.id}/thumbnail.thumbnail"
|
6
9
|
expect {
|
@@ -19,6 +22,9 @@ shared_examples 'a set of raster derivatives' do
|
|
19
22
|
end
|
20
23
|
|
21
24
|
shared_examples 'a set of vector derivatives' do
|
25
|
+
before do
|
26
|
+
expect(DeliveryJob).to receive(:perform_later).with(file_set, /file/)
|
27
|
+
end
|
22
28
|
it 'makes a thumbnail' do
|
23
29
|
new_thumb = "#{Rails.root}/tmp/derivatives/#{file_set.id}/thumbnail.thumbnail"
|
24
30
|
expect {
|
@@ -37,6 +43,9 @@ shared_examples 'a set of vector derivatives' do
|
|
37
43
|
end
|
38
44
|
|
39
45
|
shared_examples 'a set of image derivatives' do
|
46
|
+
before do
|
47
|
+
expect(DeliveryJob).not_to receive(:perform_later)
|
48
|
+
end
|
40
49
|
it 'makes a thumbnail' do
|
41
50
|
new_thumb = "#{Rails.root}/tmp/derivatives/#{file_set.id}/thumbnail.thumbnail"
|
42
51
|
expect {
|
@@ -64,7 +64,7 @@ describe ImageWork do
|
|
64
64
|
external_metadata_file = subject.metadata_files.first
|
65
65
|
allow(external_metadata_file).to receive(:metadata_xml) { doc }
|
66
66
|
allow(external_metadata_file).to receive(:geo_mime_type) { 'application/xml; schema=iso19139' }
|
67
|
-
subject.populate_metadata
|
67
|
+
subject.populate_metadata(external_metadata_file.id)
|
68
68
|
expect(subject.title).to eq(['S_566_1914_clip.tif'])
|
69
69
|
end
|
70
70
|
end
|
@@ -115,7 +115,7 @@ describe RasterWork do
|
|
115
115
|
external_metadata_file = subject.metadata_files.first
|
116
116
|
allow(external_metadata_file).to receive(:metadata_xml).and_return(doc)
|
117
117
|
allow(external_metadata_file).to receive(:geo_mime_type).and_return('application/xml; schema=iso19139')
|
118
|
-
subject.should_populate_metadata =
|
118
|
+
subject.should_populate_metadata = external_metadata_file.id
|
119
119
|
expect(subject.title).to eq(['S_566_1914_clip.tif'])
|
120
120
|
end
|
121
121
|
end
|
@@ -28,8 +28,8 @@ describe SolrDocument do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "provenance" do
|
31
|
-
let(:attributes) { { Solrizer.solr_name('provenance') => '
|
31
|
+
let(:attributes) { { Solrizer.solr_name('provenance') => ['unused'] } }
|
32
32
|
subject { document.provenance }
|
33
|
-
it { is_expected.to eq '
|
33
|
+
it { is_expected.to eq 'Your Institution' }
|
34
34
|
end
|
35
35
|
end
|
@@ -102,12 +102,8 @@ describe VectorWork do
|
|
102
102
|
external_metadata_file = subject.metadata_files.first
|
103
103
|
allow(external_metadata_file).to receive(:metadata_xml) { doc }
|
104
104
|
allow(external_metadata_file).to receive(:geo_mime_type) { 'application/xml; schema=iso19139' }
|
105
|
-
subject.populate_metadata
|
105
|
+
subject.populate_metadata(external_metadata_file.id)
|
106
106
|
expect(subject.title).to eq(['S_566_1914_clip.tif'])
|
107
107
|
end
|
108
|
-
|
109
|
-
it 'will fail if there are multiple metadata files' do
|
110
|
-
expect { FactoryGirl.create(:vector_work_with_metadata_files).extract_metadata }.to raise_error(NotImplementedError)
|
111
|
-
end
|
112
108
|
end
|
113
109
|
end
|
@@ -32,6 +32,28 @@ RSpec.describe GeoConcerns::RasterWorkShowPresenter do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe "#parent_work_presenters" do
|
36
|
+
let(:obj) { FactoryGirl.create(:raster_work) }
|
37
|
+
let(:parent_work) { FactoryGirl.create(:image_work) }
|
38
|
+
let(:collection) { FactoryGirl.create(:collection) }
|
39
|
+
let(:attributes) { obj.to_solr }
|
40
|
+
|
41
|
+
subject { described_class.new(solr_document, ability) }
|
42
|
+
|
43
|
+
before do
|
44
|
+
parent_work.members << obj
|
45
|
+
parent_work.save!
|
46
|
+
collection.members << obj
|
47
|
+
collection.save!
|
48
|
+
obj.save!
|
49
|
+
end
|
50
|
+
|
51
|
+
it "filters out collections and only returns work presenters" do
|
52
|
+
expect(subject.parent_work_presenters.count).to eq 1
|
53
|
+
expect(subject.parent_work_presenters.first.model_name.name).to eq "ImageWork"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
35
57
|
describe "file presenters" do
|
36
58
|
let(:obj) { FactoryGirl.create(:raster_work_with_files_and_metadata_files) }
|
37
59
|
let(:attributes) { obj.to_solr }
|
@@ -21,7 +21,9 @@ describe GeoConcerns::Processors::BaseGeoProcessor do
|
|
21
21
|
subject { TestProcessor.new }
|
22
22
|
|
23
23
|
let(:directives) { { format: 'png', size: '200x400' } }
|
24
|
-
let(:
|
24
|
+
let(:output_file_jpg) { 'output/geo.jpg' }
|
25
|
+
let(:output_file_png) { 'output/geo.png' }
|
26
|
+
let(:output_file) { output_file_png }
|
25
27
|
let(:file_name) { 'files/geo.tif' }
|
26
28
|
let(:options) { { output_size: '150 150' } }
|
27
29
|
|
@@ -43,18 +45,25 @@ describe GeoConcerns::Processors::BaseGeoProcessor do
|
|
43
45
|
allow(MiniMagick::Image).to receive(:open).and_return(image)
|
44
46
|
end
|
45
47
|
|
46
|
-
it 'transforms the image and saves it as a
|
48
|
+
it 'transforms the image and saves it as a PNG' do
|
49
|
+
expect(image).to receive(:format).with('png')
|
50
|
+
expect(image).to receive(:combine_options)
|
51
|
+
expect(image).to receive(:write).with(output_file_png)
|
52
|
+
subject.class.convert(file_name, output_file_png, options)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'transforms the image and saves it as a JPG' do
|
47
56
|
expect(image).to receive(:format).with('jpg')
|
48
57
|
expect(image).to receive(:combine_options)
|
49
|
-
expect(image).to receive(:write).with(
|
50
|
-
subject.class.convert(file_name,
|
58
|
+
expect(image).to receive(:write).with(output_file_jpg)
|
59
|
+
subject.class.convert(file_name, output_file_jpg, options)
|
51
60
|
end
|
52
61
|
end
|
53
62
|
|
54
63
|
describe '#temp_path' do
|
55
64
|
it 'returns a path to a temporary file based on the input file' do
|
56
65
|
expect(subject.class.temp_path(output_file))
|
57
|
-
.to
|
66
|
+
.to match(%r{output/geo_\d+})
|
58
67
|
end
|
59
68
|
end
|
60
69
|
|
@@ -1,12 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe GeoConcerns::DerivativePath do
|
4
|
+
subject { described_class.derivative_path_for_reference('12', destination_name) }
|
4
5
|
describe '#extension' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
context 'with thumbnail destination' do
|
7
|
+
let(:destination_name) { 'thumbnail' }
|
8
|
+
it { is_expected.to include('.jpeg') }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'with display_raster destination' do
|
12
|
+
let(:destination_name) { 'display_raster' }
|
13
|
+
it { is_expected.to include('.tif') }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with display_vector destination' do
|
17
|
+
let(:destination_name) { 'display_vector' }
|
18
|
+
it { is_expected.to include('.zip') }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with simplified destination' do
|
22
|
+
let(:destination_name) { 'simplified' }
|
23
|
+
it { is_expected.to include('.simplified') }
|
10
24
|
end
|
11
25
|
end
|
12
26
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoConcerns::Delivery::Geoserver do
|
4
|
+
let(:id) { 'abc123' }
|
5
|
+
|
6
|
+
context '#initialize' do
|
7
|
+
it 'configures correctly with defaults' do
|
8
|
+
expect(File).to receive(:read).and_raise(Errno::ENOENT)
|
9
|
+
expect { subject }.not_to raise_error
|
10
|
+
expect(subject.config).to include('url' => 'http://localhost:8181/geoserver/rest',
|
11
|
+
'user' => 'admin',
|
12
|
+
'password' => 'geoserver')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context '#catalog' do
|
17
|
+
it 'connects to a RGeoServer catalog' do
|
18
|
+
expect(RGeoServer).to receive(:catalog).with(hash_including(:url, :user, :password)).and_return(double).once
|
19
|
+
subject.catalog
|
20
|
+
subject.catalog # should cache result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context '#publish' do
|
25
|
+
it 'requires a valid type' do
|
26
|
+
expect { subject.publish(id, 'some/file', :unknown) }.to raise_error(ArgumentError, /Unknown file type/)
|
27
|
+
end
|
28
|
+
context 'vector' do
|
29
|
+
let(:type) { :vector }
|
30
|
+
let(:filename) { 'file.zip' }
|
31
|
+
it 'routes to publish_vector' do
|
32
|
+
expect(subject).to receive(:publish_vector).with(id, filename)
|
33
|
+
subject.publish(id, filename, type)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
context 'raster' do
|
37
|
+
let(:type) { :raster }
|
38
|
+
let(:filename) { 'file.tif' }
|
39
|
+
it 'routes to publish_raster' do
|
40
|
+
expect(subject).to receive(:publish_raster).with(id, filename)
|
41
|
+
subject.publish(id, filename, type)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context '#publish_vector' do
|
47
|
+
let(:filename) { 'spec/fixtures/files/tufts-cambridgegrid100-04.zip' }
|
48
|
+
it 'requires a vector ZIP file' do
|
49
|
+
expect { subject.send(:publish_vector, id, 'not-a-zip') }.to raise_error(ArgumentError, /Not ZIPed Shapefile/)
|
50
|
+
end
|
51
|
+
it 'dispatches to RGeoServer' do
|
52
|
+
ws_dbl = double
|
53
|
+
expect(RGeoServer::Workspace).to receive(:new).with(subject.catalog, hash_including(name: 'geo')).and_return(ws_dbl)
|
54
|
+
expect(ws_dbl).to receive(:'new?').and_return(true)
|
55
|
+
expect(ws_dbl).to receive(:save)
|
56
|
+
ds_dbl = double
|
57
|
+
expect(RGeoServer::DataStore).to receive(:new).with(subject.catalog, hash_including(workspace: ws_dbl, name: id)).and_return(ds_dbl)
|
58
|
+
expect(ds_dbl).to receive(:upload_file).with(filename, hash_including(publish: true))
|
59
|
+
subject.send(:publish_vector, id, filename)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context '#publish_raster' do
|
64
|
+
let(:filename) { 'spec/fixtures/files/S_566_1914_clip.tif' }
|
65
|
+
it 'requires GeoTIFF' do
|
66
|
+
expect { subject.send(:publish_raster, id, 'not-a-tiff') }.to raise_error(ArgumentError, /Not GeoTIFF/)
|
67
|
+
end
|
68
|
+
it 'is not implemented yet' do
|
69
|
+
expect { subject.send(:publish_raster, id, filename) }.to raise_error(NotImplementedError)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoConcerns::DeliveryService do
|
4
|
+
let(:id) { 'abc123' }
|
5
|
+
let(:filename) { 'somewhere-to-display-copy' }
|
6
|
+
|
7
|
+
context '#publish' do
|
8
|
+
it 'dispatches to Geoserver delivery' do
|
9
|
+
dbl = double
|
10
|
+
expect(subject).to receive(:geoserver).and_return(dbl)
|
11
|
+
expect(dbl).to receive(:publish).with(id, filename)
|
12
|
+
subject.publish(id, filename)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
# See https://github.com/geoblacklight/geoblacklight/wiki/Schema
|
4
|
+
|
3
5
|
describe GeoConcerns::Discovery::DocumentBuilder do
|
4
6
|
subject { described_class.new(geo_concern_presenter, document_class) }
|
5
7
|
|
@@ -14,19 +16,18 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
14
16
|
let(:geo_file) { FileSet.new(id: 'geofile', geo_mime_type: geo_file_mime_type) }
|
15
17
|
let(:geo_file_presenter) { CurationConcerns::FileSetPresenter.new(SolrDocument.new(geo_file.to_solr), nil) }
|
16
18
|
let(:coverage) { GeoConcerns::Coverage.new(43.039, -69.856, 42.943, -71.032) }
|
17
|
-
let(:
|
19
|
+
let(:issued) { '01/02/2013' }
|
20
|
+
let(:issued_xmlschema) { '2013-02-01T00:00:00Z' }
|
18
21
|
let(:attributes) { { id: 'geo-work-1',
|
19
|
-
identifier: ['abcde'],
|
20
22
|
title: ['Geo Work'],
|
21
23
|
coverage: coverage.to_s,
|
22
24
|
description: ['This is a Geo Work'],
|
23
25
|
creator: ['Yosiwo George'],
|
24
26
|
publisher: ['National Geographic'],
|
25
|
-
|
27
|
+
issued: issued,
|
26
28
|
spatial: ['Micronesia'],
|
27
29
|
temporal: ['2011'],
|
28
30
|
subject: ['Human settlements'],
|
29
|
-
provenance: 'Pacific Islands University',
|
30
31
|
language: ['Esperanto'] }
|
31
32
|
}
|
32
33
|
|
@@ -35,42 +36,58 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
35
36
|
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
expect(document['dct_temporal_sm']).to eq(['2011'])
|
49
|
-
expect(document['dc_title_s']).to eq('Geo Work')
|
50
|
-
expect(document['dc_language_s']).to eq('Esperanto')
|
51
|
-
expect(document['dc_publisher_s']).to eq('National Geographic')
|
39
|
+
context 'required' do
|
40
|
+
it 'has all metadata' do
|
41
|
+
expect(document['dc_identifier_s']).to eq('https://your-institution/geo-work-1')
|
42
|
+
expect(document['layer_slug_s']).to eq('your-institution-geo-work-1')
|
43
|
+
expect(document['dc_title_s']).to eq('Geo Work')
|
44
|
+
expect(document['solr_geom']).to eq('ENVELOPE(-71.032, -69.856, 43.039, 42.943)')
|
45
|
+
expect(document['dct_provenance_s']).to eq('Your Institution')
|
46
|
+
expect(document['dc_rights_s']).to eq('Restricted')
|
47
|
+
expect(document['geoblacklight_version']).to eq('1.0')
|
48
|
+
end
|
52
49
|
end
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
context 'optional' do
|
52
|
+
it 'has metadata' do
|
53
|
+
expect(document['dc_description_s']).to eq('This is a Geo Work')
|
54
|
+
expect(document['dc_creator_sm']).to eq(['Yosiwo George'])
|
55
|
+
expect(document['dc_subject_sm']).to eq(['Human settlements'])
|
56
|
+
expect(document['dct_spatial_sm']).to eq(['Micronesia'])
|
57
|
+
expect(document['dct_temporal_sm']).to eq(['2011'])
|
58
|
+
expect(document['dc_language_s']).to eq('Esperanto')
|
59
|
+
expect(document['dc_publisher_s']).to eq('National Geographic')
|
60
|
+
end
|
57
61
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
it 'has modified date' do
|
63
|
+
expect(document).to include('layer_modified_dt')
|
64
|
+
# TODO: Rails 4 puts +00:00 rather than Z for `xmlschema` format
|
65
|
+
expect(document['layer_modified_dt']).to match(/\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(Z|\+00:00)/)
|
66
|
+
end
|
62
67
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
context 'issued date' do
|
69
|
+
it 'works with valid date' do
|
70
|
+
expect(document).to include('dct_issued_dt')
|
71
|
+
expect(document['dct_issued_dt']).to eq(issued_xmlschema)
|
72
|
+
end
|
73
|
+
end
|
67
74
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
it 'has date field' do
|
76
|
+
expect(document['solr_year_i']).to eq(2011)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'has layer info fields' do
|
80
|
+
expect(document['layer_geom_type_s']).to eq('Mixed')
|
81
|
+
expect(document['dc_format_s']).to eq('Shapefile')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'has references' do
|
85
|
+
refs = JSON.parse(document['dct_references_s'])
|
86
|
+
expect(refs['http://schema.org/url']).to eq('http://localhost:3000/concern/vector_works/geo-work-1')
|
87
|
+
expect(refs['http://www.isotc211.org/schemas/2005/gmd/']).to eq('http://localhost:3000/downloads/metadatafile')
|
88
|
+
expect(refs['http://schema.org/downloadUrl']).to eq('http://localhost:3000/downloads/geofile')
|
89
|
+
expect(refs['http://schema.org/thumbnailUrl']).to eq('http://localhost:3000/downloads/geofile?file=thumbnail')
|
90
|
+
end
|
74
91
|
end
|
75
92
|
end
|
76
93
|
|
@@ -145,6 +162,7 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
145
162
|
|
146
163
|
it 'returns an error document' do
|
147
164
|
expect(document['error'][0]).to include('dc_title_s')
|
165
|
+
expect(document['error'].size).to eq(1)
|
148
166
|
end
|
149
167
|
end
|
150
168
|
|
@@ -154,16 +172,16 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
154
172
|
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
155
173
|
end
|
156
174
|
|
157
|
-
it 'returns a document without the field' do
|
175
|
+
it 'returns a document without the field but valid' do
|
158
176
|
expect(document['dc_language_s']).to be_nil
|
159
177
|
end
|
160
178
|
end
|
161
179
|
|
162
180
|
context 'with a public visibility' do
|
163
181
|
before do
|
164
|
-
|
182
|
+
viz = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
165
183
|
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
166
|
-
allow(geo_concern_presenter.solr_document).to receive(:visibility).and_return(
|
184
|
+
allow(geo_concern_presenter.solr_document).to receive(:visibility).and_return(viz)
|
167
185
|
end
|
168
186
|
|
169
187
|
it 'return a public access' do
|
@@ -4,14 +4,16 @@ describe GeoConcerns::Discovery::GeoblacklightDocument do
|
|
4
4
|
subject { described_class.new }
|
5
5
|
|
6
6
|
describe '#to_hash' do
|
7
|
-
let(:document) { { id: 'test' } }
|
8
|
-
|
9
7
|
before do
|
10
|
-
allow(subject).to receive(:
|
8
|
+
allow(subject).to receive(:document_hash).and_return(document_hash)
|
11
9
|
end
|
10
|
+
context 'incomplete data' do
|
11
|
+
let(:document_hash) { Hash.new }
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
it 'failed to validate the document hash' do
|
14
|
+
expect(subject.to_hash).to include(:error)
|
15
|
+
expect(subject.to_hash[:error].size).to eq(6)
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|