@@ -86,7 +86,7 @@ def test_from
8686 DCField . where ( "id < #{ first_id + 10 } " ) . update_all ( updated_at : Time . parse ( "June 1 2005" ) )
8787
8888
89- from_param = Time . parse ( "January 1 2006" )
89+ from_param = Time . parse ( "January 1 2006" ) . getutc . iso8601
9090
9191 doc = REXML ::Document . new (
9292 @provider . list_records (
@@ -97,7 +97,7 @@ def test_from
9797
9898 doc = REXML ::Document . new (
9999 @provider . list_records (
100- :metadata_prefix => 'oai_dc' , :from => Time . parse ( "May 30 2005" ) )
100+ :metadata_prefix => 'oai_dc' , :from => Time . parse ( "May 30 2005" ) . getutc . iso8601 )
101101 )
102102 assert_equal 20 , doc . elements [ 'OAI-PMH/ListRecords' ] . to_a . size
103103 end
@@ -122,11 +122,38 @@ def test_from_and_until
122122 doc = REXML ::Document . new (
123123 @provider . list_records (
124124 :metadata_prefix => 'oai_dc' ,
125- :from => Time . parse ( "June 3 2005" ) ,
126- :until => Time . parse ( "June 16 2005" ) )
125+ :from => Time . parse ( "June 3 2005" ) . getutc . iso8601 ,
126+ :until => Time . parse ( "June 16 2005" ) . getutc . iso8601 )
127127 )
128128 assert_equal 40 , doc . elements [ 'OAI-PMH/ListRecords' ] . to_a . size
129129 end
130+
131+ def test_bad_until_raises_exception
132+ DCField . order ( 'id asc' ) . limit ( 10 ) . update_all ( updated_at : 1 . year . ago )
133+ DCField . order ( 'id desc' ) . limit ( 10 ) . update_all ( updated_at : 1 . year . from_now )
134+ badTimes = [
135+ 'junk' ,
136+ 'February 92nd, 2015' ]
137+ badTimes . each do |time |
138+ assert_raise ( OAI ::ArgumentException ) do
139+ @provider . list_records ( :metadata_prefix => 'oai_dc' , :until => time )
140+ end
141+ end
142+ end
143+
144+ def test_bad_from_raises_exception
145+ DCField . order ( 'id asc' ) . limit ( 10 ) . update_all ( updated_at : 1 . year . ago )
146+ DCField . order ( 'id desc' ) . limit ( 10 ) . update_all ( updated_at : 1 . year . from_now )
147+
148+ badTimes = [
149+ 'junk' ,
150+ 'February 92nd, 2015' ]
151+ badTimes . each do |time |
152+ assert_raise ( OAI ::ArgumentException ) do
153+ @provider . list_records ( :metadata_prefix => 'oai_dc' , :from => time )
154+ end
155+ end
156+ end
130157
131158 def test_handles_empty_collections
132159 DCField . delete_all
0 commit comments