diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-06-27 11:00:02 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-06-27 11:00:02 -0700 |
commit | 2076efed1ca4b5df3a7101c9a478d6149bb53297 (patch) | |
tree | 2357630aa3679b43b07fc755743aa3562cefd8d6 /activerecord/test/cases/attribute_methods_test.rb | |
parent | d79ca9288e5c55563a554d05c779a41e701181cd (diff) | |
parent | ab7c1c4e0fa3d7ba51f7dd885f4cc9065652240b (diff) | |
download | rails-2076efed1ca4b5df3a7101c9a478d6149bb53297.tar.gz rails-2076efed1ca4b5df3a7101c9a478d6149bb53297.tar.bz2 rails-2076efed1ca4b5df3a7101c9a478d6149bb53297.zip |
Merge pull request #6873 from mauricio/fix-for-6825
Fixes #6825, adds tests covering cases and error possibilities
Diffstat (limited to 'activerecord/test/cases/attribute_methods_test.rb')
-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| |