diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-14 17:08:25 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-14 17:08:25 -0700 |
commit | d8e710410ea300ec4626250c0b35946cb52bc38c (patch) | |
tree | a844532921c8a62aac2c04822cb419a0cb26506e /activerecord/test/cases/attribute_methods_test.rb | |
parent | b67990cf342fb1d8f9ecab532db7e5b884981d7d (diff) | |
download | rails-d8e710410ea300ec4626250c0b35946cb52bc38c.tar.gz rails-d8e710410ea300ec4626250c0b35946cb52bc38c.tar.bz2 rails-d8e710410ea300ec4626250c0b35946cb52bc38c.zip |
Only use the `_before_type_cast` in the form when from user input
While we don't want to change the form input when validations fail,
blindly using `_before_type_cast` will cause the input to display the
wrong data for any type which does additional work on database values.
Diffstat (limited to 'activerecord/test/cases/attribute_methods_test.rb')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 01ee1234a2..359503db98 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -888,6 +888,14 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_not_equal ['id'], @target.column_names end + def test_came_from_user + model = @target.first + + assert_not model.id_came_from_user? + model.id = "omg" + assert model.id_came_from_user? + end + private def new_topic_like_ar_class(&block) |