diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-02-24 08:26:49 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-02-24 08:26:49 +0100 |
commit | 0e144bebc6d979780c3243537673ff553ffb37f5 (patch) | |
tree | c797ae18c38f740b84e46f8df16870e45c1e1066 /activerecord/test | |
parent | 4d24c150ab575db3980d1999c82806c9375b8b5f (diff) | |
parent | d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62 (diff) | |
download | rails-0e144bebc6d979780c3243537673ff553ffb37f5.tar.gz rails-0e144bebc6d979780c3243537673ff553ffb37f5.tar.bz2 rails-0e144bebc6d979780c3243537673ff553ffb37f5.zip |
Merge pull request #10497 from senny/10485_does_not_coerce_strings
coerce strings when reading attributes
Diffstat (limited to 'activerecord/test')
-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 |