diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-06-22 14:34:31 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-22 14:34:31 -0600 |
commit | 3529bbd8cab56db5fea527cdd2f21e7d2552d62e (patch) | |
tree | 04dde031ef1b2638ececddba70ca3e7e7db7d3a7 /activerecord/test | |
parent | 22da898becb1e6d64ec6ed7894b2d58c217a0a71 (diff) | |
download | rails-3529bbd8cab56db5fea527cdd2f21e7d2552d62e.tar.gz rails-3529bbd8cab56db5fea527cdd2f21e7d2552d62e.tar.bz2 rails-3529bbd8cab56db5fea527cdd2f21e7d2552d62e.zip |
`reload` should fully reload attributes
`reload` is meant to put a record in the same state it would be if you
were to do `Post.find(post.id)`. This means we should fully replace the
attributes hash.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index 28341d0b42..1192ecd6b4 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -858,4 +858,11 @@ class PersistenceTest < ActiveRecord::TestCase post.body end end + + def test_reload_removes_custom_selects + post = Post.select('posts.*, 1 as wibble').last! + + assert_equal 1, post[:wibble] + assert_nil post.reload[:wibble] + end end |