-
Notifications
You must be signed in to change notification settings - Fork 63
/
date_time_properties_spec.rb
42 lines (37 loc) · 1.55 KB
/
date_time_properties_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'spec_helper'
describe ActiveFedora::Base do
before do
class Foo < ActiveFedora::Base
# Date attributes are recognized by having index.type :Date or class_name: 'DateTime'
property :date, predicate: ::RDF::DC.date do |index|
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')
property :empty_date, multiple: false, class_name: 'DateTime', predicate: ::RDF::URI.new('http://www.example.com/empty_date')
end
end
after do
Object.send(:remove_const, :Foo)
end
let(:date) { DateTime.parse("2015-10-22T10:20:03.653+01:00") }
let(:date2) { DateTime.parse("2015-10-22T15:34:20.323-11:00") }
subject { Foo.create(date: [date], single_date: date2, empty_date: '').reload }
describe "saving and loading in Fedora" do
it "loads the correct time" do
expect(subject.date.first).to eql date
expect(subject.single_date).to eql date2
end
end
describe "saving and loading in Solr" do
let(:subject_solr) { subject.class.load_instance_from_solr(subject.id) }
it "uses DateTime objects" do
expect(subject_solr.date.first).to be_a DateTime
expect(subject_solr.single_date).to be_a DateTime
end
it "loads the correct time" do
expect(subject_solr.date.first).to eql date
expect(subject_solr.single_date).to eql date2
end
end
end