Skip to content

Commit

Permalink
Don't parse date_created as a Date, fixes #657
Browse files Browse the repository at this point in the history
  • Loading branch information
awead committed Mar 4, 2016
1 parent ea84b24 commit 17a60ef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/presenters/curation_concerns/collection_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(solr_document, current_ability)

# Metadata Methods
delegate :title, :description, :creator, :contributor, :subject, :publisher, :language,
:embargo_release_date, :lease_expiration_date, :rights, to: :solr_document
:embargo_release_date, :lease_expiration_date, :rights, :date_created, to: :solr_document

def size
number_to_human_size(@solr_document['bytes_is'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def representative_id
fetch(Solrizer.solr_name('hasRelatedMediaFragment', :symbol), []).first
end

# Date created is indexed as a string. This allows users to enter values like: 'Circa 1840-1844'
def date_created
date_field('date_created')
fetch(Solrizer.solr_name("date_created"), []).first
end

def date_modified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
build(:collection,
id: 'adc12v',
description: ['a nice collection'],
title: ['A clever title'])
title: ['A clever title'],
date_created: ['some date'])
end
let(:work) { build(:work, title: ['unimaginitive title']) }
let(:solr_document) { SolrDocument.new(collection.to_solr) }
Expand Down Expand Up @@ -44,4 +45,9 @@
it { is_expected.to eq 0 }
end
end

describe "#date_created" do
subject { presenter.date_created }
it { is_expected.to eq 'some date' }
end
end
9 changes: 7 additions & 2 deletions spec/presenters/curation_concerns/work_show_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{ "title_tesim" => ["foo bar"],
"human_readable_type_tesim" => ["Generic Work"],
"has_model_ssim" => ["GenericWork"],
"date_created_dtsi" => date_index,
"date_created_tesim" => ['an unformatted date'],
"date_modified_dtsi" => date_index,
"date_uploaded_dtsi" => date_index }
end
Expand All @@ -31,7 +31,12 @@
it { is_expected.to be_kind_of ActiveModel::Name }
end

[:date_created, :date_modified, :date_uploaded].each do |date_field|
describe "#date_created" do
subject { presenter.date_created }
it { is_expected.to eq('an unformatted date') }
end

[:date_modified, :date_uploaded].each do |date_field|
describe "##{date_field}" do
subject { presenter.send date_field }
it { is_expected.to eq date_value.to_formatted_s(:standard) }
Expand Down

0 comments on commit 17a60ef

Please sign in to comment.