Reputation: 13683
I'm trying to come up with a minimal test case for ActiveRecord 4.0. What I have is this gist which fails with this message:
1) Failure:
BugTest#test_association_stuff [millisecond_resolution.rb:28]:
Expected: "ActiveSupport::TimeWithZone"
Actual: "Time"
In a full Rails app, this does return ActiveSupport::TimeWithZone
. What I'm missing is the link between AS and AR so that the latter returns timestamps as TimeWithZone
. I've already added
ActiveRecord::Base.default_timezone = :local
ActiveRecord::Base.time_zone_aware_attributes = true
to no avail. I'm also aware of the lazy_load_hooks
in AS but am note sure if they are applicable.
What am I missing here? Am I on the wrong track?
Upvotes: 1
Views: 190
Reputation: 636
No time zone is set in your test. You have to set the time zone.
Time.zone = 'Berlin'
See http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html for more details.
Upvotes: 1
Reputation: 1325
Alright mate,
I've only got rails 4.0.0 on my computer, but a quick acking brought me to this:
# activesupport-4.0.0/lib/active_support/time_with_zone.rb:39
# Report class name as 'Time' to thwart type checking.
def self.name
'Time'
end
Hope that gets your nearer to a solution.
Upvotes: 1