Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8653 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Rick Olson
2008-01-18 01:55:11 +00:00
parent 3845de022b
commit 49794485b6
3 changed files with 28 additions and 6 deletions

View File

@@ -3,10 +3,12 @@ require 'fixtures/topic'
require 'fixtures/reply'
require 'fixtures/task'
require 'fixtures/course'
require 'fixtures/category'
require 'fixtures/post'
class QueryCacheTest < ActiveSupport::TestCase
fixtures :tasks, :topics
fixtures :tasks, :topics, :categories, :posts, :categories_posts
def test_find_queries
assert_queries(2) { Task.find(1); Task.find(1) }
@@ -99,6 +101,24 @@ class QueryCacheExpiryTest < ActiveSupport::TestCase
Task.create!
end
end
def test_cache_is_expired_by_habtm_update
ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
ActiveRecord::Base.cache do
c = Category.find(:first)
p = Post.find(:first)
p.categories << c
end
end
def test_cache_is_expired_by_habtm_delete
ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
ActiveRecord::Base.cache do
c = Category.find(:first)
p = Post.find(:first)
p.categories.delete_all
end
end
end
end