aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-01-14 14:26:00 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-01-14 14:26:00 -0800
commit74bfbfdb028bf4fb97fdf93451caeb49aa89ff39 (patch)
tree316ff960d8e4b746aef1451d011037a4b93c3b67 /activerecord/test/cases
parenta924e0dbcd08f6cb72a5afb093f7cc9c1b867e2b (diff)
downloadrails-74bfbfdb028bf4fb97fdf93451caeb49aa89ff39.tar.gz
rails-74bfbfdb028bf4fb97fdf93451caeb49aa89ff39.tar.bz2
rails-74bfbfdb028bf4fb97fdf93451caeb49aa89ff39.zip
fix cache class interface
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/statement_cache_test.rb26
1 files changed, 9 insertions, 17 deletions
diff --git a/activerecord/test/cases/statement_cache_test.rb b/activerecord/test/cases/statement_cache_test.rb
index ae34b174db..3c8f34c851 100644
--- a/activerecord/test/cases/statement_cache_test.rb
+++ b/activerecord/test/cases/statement_cache_test.rb
@@ -15,13 +15,13 @@ module ActiveRecord
Book.create(name: "my book")
Book.create(name: "my other book")
- cache = StatementCache.new do
- Book.where(:name => "my book")
+ cache = StatementCache.new do |name|
+ Book.where(:name => name)
end
- b = cache.execute name: "my book"
+ b = cache.execute "my book"
assert_equal "my book", b[0].name
- b = cache.execute name: "my other book"
+ b = cache.execute "my other book"
assert_equal "my other book", b[0].name
end
@@ -31,13 +31,13 @@ module ActiveRecord
Book.create(name: "my book")
Book.create(name: "my other book")
- cache = StatementCache.new do
- Book.where(id: "1")
+ cache = StatementCache.new do |id|
+ Book.where(id: id)
end
- b = cache.execute id: "1"
+ b = cache.execute "1"
assert_equal "my book", b[0].name
- b = cache.execute id: "2"
+ b = cache.execute "2"
assert_equal "my other book", b[0].name
end
@@ -64,14 +64,6 @@ module ActiveRecord
assert_equal "my book", books[0].name
end
- def test_statement_cache_with_nil_statement_raises_error
- assert_raise(ArgumentError) do
- ActiveRecord::StatementCache.new do
- nil
- end
- end
- end
-
def test_statement_cache_with_complex_statement
cache = ActiveRecord::StatementCache.new do
Liquid.joins(:molecules => :electrons).where('molecules.name' => 'dioxane', 'electrons.name' => 'lepton')
@@ -104,4 +96,4 @@ module ActiveRecord
assert first_books != additional_books
end
end
-end \ No newline at end of file
+end