mirror of
https://github.com/github/rails.git
synced 2026-02-12 23:25:00 -05:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user