Skip to content

Commit

Permalink
Don't try to parse nil dates. Fixes #937
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 2, 2015
1 parent 95ee653 commit 9a69ffa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_fedora/loadable_from_json.rb
Expand Up @@ -178,7 +178,7 @@ def date_attribute?(attribute_name)
# @param attribute_name [String] the name of the attribute to adapt
# @return [Object] the adapted value
def adapt_single_attribute_value(value, attribute_name)
if date_attribute?(attribute_name)
if value && date_attribute?(attribute_name)
DateTime.parse(value)
else
value
Expand Down
1 change: 1 addition & 0 deletions spec/integration/date_time_properties_spec.rb
Expand Up @@ -8,6 +8,7 @@ class Foo < ActiveFedora::Base
index.type :date
end
property :single_date, multiple: false, class_name: 'DateTime', predicate: ::RDF::URI.new('http://www.example.com/single_date')
property :missing_date, multiple: false, class_name: 'DateTime', predicate: ::RDF::URI.new('http://www.example.com/missing_date')
end
end

Expand Down

0 comments on commit 9a69ffa

Please sign in to comment.