Skip to content

Commit

Permalink
catch document build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Oct 28, 2016
1 parent 0bd0b2c commit 09a79c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Expand Up @@ -25,6 +25,8 @@ def layer_year
date = geo_concern.temporal.first
year = date.match(/(?<=\D|^)(\d{4})(?=\D|$)/)
year ? year[0].to_i : nil
rescue
''
end

# Returns the date the work was modified.
Expand Down
Expand Up @@ -28,6 +28,8 @@ def coverage
# @return [String] coverage in solr format
def to_solr
"ENVELOPE(#{coverage.w}, #{coverage.e}, #{coverage.n}, #{coverage.s})"
rescue
''
end
end
end
Expand Down
26 changes: 24 additions & 2 deletions spec/services/geo_concerns/discovery/document_builder_spec.rb
Expand Up @@ -156,12 +156,12 @@

context 'with a missing required metadata field' do
before do
attributes.delete(:title)
attributes.delete(:coverage)
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
end

it 'returns an error document' do
expect(document['error'][0]).to include('dc_title_s')
expect(document['error'][0]).to include('solr_geom')
expect(document['error'].size).to eq(1)
end
end
Expand All @@ -177,6 +177,28 @@
end
end

context 'with a missing temporal field' do
before do
attributes.delete(:temporal)
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
end

it 'returns a document without the field but valid' do
expect(document['dct_temporal_sm']).to be_nil
end
end

context 'with a missing issued field' do
before do
attributes.delete(:issued)
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
end

it 'returns a document without the field but valid' do
expect(document['dct_issued_dt']).to be_nil
end
end

context 'with a public visibility' do
before do
viz = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
Expand Down

0 comments on commit 09a79c2

Please sign in to comment.