diff options
author | Matthew Draper <matthew@trebex.net> | 2017-07-09 04:20:54 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2017-07-09 04:29:28 +0930 |
commit | b83852e6eed5789b23b13bac40228e87e8822b4d (patch) | |
tree | 997f6afc67fa678d33fdb6495bc9a92cf1fc0846 /activerecord/test/cases/calculations_test.rb | |
parent | e5bcc7b53cb87643e8cdbf000fea0a03bfcd34f6 (diff) | |
parent | 6658e3746b236f84e27e711fced6a83b187ad2b1 (diff) | |
download | rails-b83852e6eed5789b23b13bac40228e87e8822b4d.tar.gz rails-b83852e6eed5789b23b13bac40228e87e8822b4d.tar.bz2 rails-b83852e6eed5789b23b13bac40228e87e8822b4d.zip |
Merge pull request #28867 from eugeneius/skip_query_cache_in_batches
Skip query cache for in_batches and friends
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 80baaac30a..7d6dc21e34 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -817,4 +817,46 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal 6, Account.sum(:firm_id) { 1 } end end + + test "#skip_query_cache! for #pluck" do + Account.cache do + assert_queries(1) do + Account.pluck(:credit_limit) + Account.pluck(:credit_limit) + end + + assert_queries(2) do + Account.all.skip_query_cache!.pluck(:credit_limit) + Account.all.skip_query_cache!.pluck(:credit_limit) + end + end + end + + test "#skip_query_cache! for a simple calculation" do + Account.cache do + assert_queries(1) do + Account.calculate(:sum, :credit_limit) + Account.calculate(:sum, :credit_limit) + end + + assert_queries(2) do + Account.all.skip_query_cache!.calculate(:sum, :credit_limit) + Account.all.skip_query_cache!.calculate(:sum, :credit_limit) + end + end + end + + test "#skip_query_cache! for a grouped calculation" do + Account.cache do + assert_queries(1) do + Account.group(:firm_id).calculate(:sum, :credit_limit) + Account.group(:firm_id).calculate(:sum, :credit_limit) + end + + assert_queries(2) do + Account.all.skip_query_cache!.group(:firm_id).calculate(:sum, :credit_limit) + Account.all.skip_query_cache!.group(:firm_id).calculate(:sum, :credit_limit) + end + end + end end |