Skip to content

Commit 734f129

Browse files
tjdettcbeer
authored andcommitted
Fixing Ruby 1.8 date handling for activerecord provider.
1 parent db4e35a commit 734f129

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/oai/provider/model/activerecord_wrapper.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'active_record'
2+
23
module OAI::Provider
34
# = OAI::Provider::ActiveRecordWrapper
45
#
@@ -141,7 +142,7 @@ def sql_conditions(opts)
141142
if opts.has_key?(:until)
142143
# Handle databases which store fractions of a second by rounding up
143144
sql << "#{timestamp_field} < :until"
144-
esc_values[:until] = parse_to_local(opts[:until]) { |t| round_up(t) }
145+
esc_values[:until] = parse_to_local(opts[:until]) { |t| t.succ }
145146
end
146147
if opts.has_key?(:set)
147148
sql << "set = :set"
@@ -155,11 +156,7 @@ def sql_conditions(opts)
155156
def parse_to_local(time)
156157
time_obj = Time.parse(time.to_s)
157158
time_obj = yield(time_obj) if block_given?
158-
time_obj.localtime.to_s
159-
end
160-
161-
def round_up(time)
162-
(time + 1).round(0)
159+
time_obj.localtime.strftime("%Y-%m-%d %H:%M:%S")
163160
end
164161

165162
end

test/activerecord_provider/helpers/transactional_test_case.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
class TransactionalTestCase < Test::Unit::TestCase
22

33
def run(result, &block)
4+
# Handle the default "you have no tests" test if it turns up
5+
return if @method_name.to_s == "default_test"
46
ActiveRecord::Base.transaction do
57
load_fixtures
68
result = super(result, &block)

0 commit comments

Comments
 (0)