diff options
author | Mauricio Linhares <mauricio.linhares@gmail.com> | 2012-06-27 14:31:22 -0300 |
---|---|---|
committer | Mauricio Linhares <mauricio.linhares@gmail.com> | 2012-06-27 14:31:22 -0300 |
commit | ab7c1c4e0fa3d7ba51f7dd885f4cc9065652240b (patch) | |
tree | 2357630aa3679b43b07fc755743aa3562cefd8d6 /activerecord/test/cases | |
parent | d79ca9288e5c55563a554d05c779a41e701181cd (diff) | |
download | rails-ab7c1c4e0fa3d7ba51f7dd885f4cc9065652240b.tar.gz rails-ab7c1c4e0fa3d7ba51f7dd885f4cc9065652240b.tar.bz2 rails-ab7c1c4e0fa3d7ba51f7dd885f4cc9065652240b.zip |
Fixes #6825, adds tests covering cases and error possibilities, also changes SQLite3 driver to correctly generate a time column instead of datetime
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 1093fedea1..6c5a968454 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -791,6 +791,39 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_equal "lol", topic.author_name end + def test_setting_time_attribute + topic = Topic.new( "bonus_time(4i)"=> "01", "bonus_time(5i)" => "05" ) + assert_equal 1, topic.bonus_time.hour + assert_equal 5, topic.bonus_time.min + end + + def test_setting_date_attribute + topic = Topic.new( "written_on(1i)" => "1952", "written_on(2i)" => "3", "written_on(3i)" => "11" ) + assert_equal 1952, topic.written_on.year + assert_equal 3, topic.written_on.month + assert_equal 11, topic.written_on.day + end + + def test_setting_date_and_time_attribute + topic = Topic.new( + "written_on(1i)" => "1952", + "written_on(2i)" => "3", + "written_on(3i)" => "11", + "written_on(4i)" => "13", + "written_on(5i)" => "55") + assert_equal 1952, topic.written_on.year + assert_equal 3, topic.written_on.month + assert_equal 11, topic.written_on.day + assert_equal 13, topic.written_on.hour + assert_equal 55, topic.written_on.min + end + + def test_setting_time_but_not_date_on_date_field + assert_raise( ActiveRecord::MultiparameterAssignmentErrors ) do + Topic.new( "written_on(4i)" => "13", "written_on(5i)" => "55" ) + end + end + private def cached_columns Topic.columns.find_all { |column| |