Skip to content

Commit

Permalink
update wxs_identifier field
Browse files Browse the repository at this point in the history
  • Loading branch information
tampakis committed Mar 24, 2016
1 parent 1dec4c3 commit 37b6bfe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
6 changes: 2 additions & 4 deletions app/presenters/geoblacklight/document_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ module Geoblacklight
class DocumentPresenter < Blacklight::DocumentPresenter
##
# Accesses a documents configured Wxs Identifier
# @param [SolrDocument]
# @return [String]
def wxs_identifier
fields = Array(@configuration.wxs_identifier_field)
f = fields.find { |field| @document.has? field }
render_field_value(@document[f])
field = Settings.FIELDS.WXS_IDENTIFIER.to_sym
render_field_value(@document[field])
end

def file_format
Expand Down
4 changes: 0 additions & 4 deletions lib/generators/geoblacklight/templates/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ class CatalogController < ApplicationController

config.show.display_type_field = 'format'

# Custom GeoBlacklight fields which currently map to GeoBlacklight-Schema
# v0.3.2
config.wxs_identifier_field = 'layer_id_s'

# solr fields that will be treated as facets by the blacklight application
# The ordering of the field names is the order of the display
#
Expand Down
1 change: 1 addition & 0 deletions lib/generators/geoblacklight/templates/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ GEOMETRY_FIELD: 'solr_geom'
FIELDS:
:FILE_FORMAT: 'dc_format_s'
:GEOMETRY: 'solr_geom'
:WXS_IDENTIFIER: 'layer_id_s'

# Institution deployed at
INSTITUTION: 'Stanford'
Expand Down
20 changes: 9 additions & 11 deletions spec/lib/geoblacklight/document_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

describe Geoblacklight::DocumentPresenter do
let(:request_context) { double(add_facet_params: '') }
let(:config) { Blacklight::Configuration.new }
let(:wxs_identifier_field) { Blacklight::Configuration.new }
let(:solr_fields) { Settings.FIELDS }
subject { presenter }
let(:presenter) do
described_class.new(document, request_context, config)
Expand All @@ -13,17 +14,14 @@
end

describe '#wxs_identifier' do
describe 'without wxs identifier in configuration' do
end
it 'returns empty string' do
expect(subject.wxs_identifier).to eq ''
end
describe 'without wxs identifier in configuration' do
let(:config) do
Blacklight::Configuration.new.configure do |config|
config.wxs_identifier_field = 'layer_id_s'
end
context 'document without wxs identifier field present' do
before { solr_fields.WXS_IDENTIFIER = 'non_present_field' }
it 'returns empty string' do
expect(subject.wxs_identifier).to eq ''
end
end
context 'without wxs identifier in configuration' do
before { solr_fields.WXS_IDENTIFIER = 'layer_id_s' }
it 'returns configured field' do
expect(subject.wxs_identifier).to eq 'druid:abc123'
end
Expand Down

0 comments on commit 37b6bfe

Please sign in to comment.