Sha256: 2d88e30056b77022bdb454d35aada6b0e37de260e4a89182272415073c387b5b
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
require File.dirname(__FILE__) + '/helper' class FindSomeTest < ActiveSupport::TestCase fixtures :blogs, :posts should "cache find(id, id) calls" do post1 = Post.first post2 = Post.last assert_nil(Kasket.cache.read(post1.kasket_key)) assert_nil(Kasket.cache.read(post2.kasket_key)) Post.find(post1.id, post2.id) assert(Kasket.cache.read(post1.kasket_key)) assert(Kasket.cache.read(post2.kasket_key)) Post.connection.expects(:select_all).never Post.find(post1.id, post2.id) end should "only lookup the records that are not in the cache" do post1 = Post.first post2 = Post.last assert_equal(post1, Post.find(post1.id)) assert(Kasket.cache.read(post1.kasket_key)) assert_nil(Kasket.cache.read(post2.kasket_key)) Post.expects(:find_by_sql_without_kasket).with("SELECT * FROM \"posts\" WHERE (\"posts\".\"id\" = #{post2.id}) ").returns([post2]) found_posts = Post.find(post1.id, post2.id) assert_equal([post1, post2].map(&:id).sort, found_posts.map(&:id).sort) Post.expects(:find_by_sql_without_kasket).never found_posts = Post.find(post1.id, post2.id) assert_equal([post1, post2].map(&:id).sort, found_posts.map(&:id).sort) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kasket-0.8.4 | test/find_some_test.rb |
kasket-0.8.3 | test/find_some_test.rb |
kasket-0.8.2 | test/find_some_test.rb |