Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added #to_i to DateTime in ActiveSupport so #to_yaml works correctly …
…on ActiveRecord models with DateTime attributes.
- Loading branch information
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require "cases/helper" | ||
require 'models/topic' | ||
|
||
class YamlSerializationTest < ActiveRecord::TestCase | ||
def test_to_yaml_with_time_with_zone_should_not_raise_exception | ||
Time.zone = ActiveSupport::TimeZone["Pacific Time (US & Canada)"] | ||
ActiveRecord::Base.time_zone_aware_attributes = true | ||
topic = Topic.new(:written_on => DateTime.now) | ||
assert_nothing_raised { topic.to_yaml } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters