diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-08-07 18:56:49 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-02-23 13:42:16 +0100 |
commit | d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62 (patch) | |
tree | c6645aed37294bb168362b15c014ec68f68ab118 /activerecord/test/cases/attribute_methods_test.rb | |
parent | 96759cf6c6a17053abb6a2b7cd87cdbd5a8420ba (diff) | |
download | rails-d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62.tar.gz rails-d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62.tar.bz2 rails-d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62.zip |
Coerce strings when reading attributes.
Diffstat (limited to 'activerecord/test/cases/attribute_methods_test.rb')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 6c581a432f..38a43de05a 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -555,6 +555,24 @@ class AttributeMethodsTest < ActiveRecord::TestCase end end + def test_converted_values_are_returned_after_assignment + developer = Developer.new(name: 1337, salary: "50000") + + assert_equal "50000", developer.salary_before_type_cast + assert_equal 1337, developer.name_before_type_cast + + assert_equal 50000, developer.salary + assert_equal "1337", developer.name + + developer.save! + + assert_equal "50000", developer.salary_before_type_cast + assert_equal 1337, developer.name_before_type_cast + + assert_equal 50000, developer.salary + assert_equal "1337", developer.name + end + def test_write_nil_to_time_attributes in_time_zone "Pacific Time (US & Canada)" do record = @target.new |