diff options
author | Adam Meehan <adam.meehan@gmail.com> | 2012-08-12 20:26:17 +1000 |
---|---|---|
committer | Adam Meehan <adam.meehan@gmail.com> | 2012-09-05 21:05:04 +1000 |
commit | ce7cdb90728d2883e6eee100f3c6a845d3569d63 (patch) | |
tree | 31ca33d123eb8d19e4aa1d17fcb79de86ca4269d /activerecord/test/cases/base_test.rb | |
parent | 08c4eb5e24f2a6aad3f0af4b9ae18290279d05bf (diff) | |
download | rails-ce7cdb90728d2883e6eee100f3c6a845d3569d63.tar.gz rails-ce7cdb90728d2883e6eee100f3c6a845d3569d63.tar.bz2 rails-ce7cdb90728d2883e6eee100f3c6a845d3569d63.zip |
Fix for time type columns with invalid time
The string_to_dummy_time method was blindly parsing the dummy time string
with Date._parse which returns a hash for the date part regardless
of whether the time part is an invalid time string.
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 9fcee99222..b9d480d9ce 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -970,6 +970,18 @@ class BasicsTest < ActiveRecord::TestCase assert_equal Time.local(2000, 1, 1, 5, 42, 0), topic.bonus_time end + def test_attributes_on_dummy_time_with_invalid_time + # Oracle, and Sybase do not have a TIME datatype. + return true if current_adapter?(:OracleAdapter, :SybaseAdapter) + + attributes = { + "bonus_time" => "not a time" + } + topic = Topic.find(1) + topic.attributes = attributes + assert_nil topic.bonus_time + end + def test_boolean b_nil = Boolean.create({ "value" => nil }) nil_id = b_nil.id |