diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-25 10:56:20 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-25 10:56:20 +0000 |
commit | deda0ee4a8008475629f020e0334f64cc05215c8 (patch) | |
tree | e41d89732885455334c5565488f3bfce2bc6085f /activerecord/test | |
parent | e4ccbf28c815fefeeb90c45524feea7b57e5a6ae (diff) | |
download | rails-deda0ee4a8008475629f020e0334f64cc05215c8.tar.gz rails-deda0ee4a8008475629f020e0334f64cc05215c8.tar.bz2 rails-deda0ee4a8008475629f020e0334f64cc05215c8.zip |
Fixed that clear_association_cache doesn't delete new associations on new records (so you can safely place new records in the session with Action Pack without having new associations wiped) #1494 [cluon]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1504 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index e0d2e9e695..fa1d621950 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -826,4 +826,25 @@ class BasicsTest < Test::Unit::TestCase assert_equal res, res2 end + def test_clear_association_cache_stored + firm = Firm.find(1) + assert_kind_of Firm, firm + + firm.clear_association_cache + assert_equal Firm.find(1).clients.collect{ |x| x.name }.sort, firm.clients.collect{ |x| x.name }.sort + end + + def test_clear_association_cache_new_record + firm = Firm.new + client_stored = Client.find(3) + client_new = Client.new + client_new.name = "The Joneses" + clients = [ client_stored, client_new ] + + firm.clients << clients + + firm.clear_association_cache + + assert_equal firm.clients.collect{ |x| x.name }.sort, clients.collect{ |x| x.name }.sort + end end |