diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-05 16:13:40 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-05 16:13:40 +0900 |
commit | 824ea8d06ff596f5e60307082828745b4afd4ebf (patch) | |
tree | c56e10ec00c2f4c266929cfa67a5b1b175e34794 /activerecord | |
parent | a11ca2ff76d3e1b845282e784c3970b2ebaffd89 (diff) | |
download | rails-824ea8d06ff596f5e60307082828745b4afd4ebf.tar.gz rails-824ea8d06ff596f5e60307082828745b4afd4ebf.tar.bz2 rails-824ea8d06ff596f5e60307082828745b4afd4ebf.zip |
Add missing `touch_all` delegation to relation
Follow up of #31513.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/querying.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relation/delegation_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relation/update_all_test.rb | 32 |
3 files changed, 34 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb index ae1501f5a1..08cfc3fe5f 100644 --- a/activerecord/lib/active_record/querying.rb +++ b/activerecord/lib/active_record/querying.rb @@ -10,7 +10,7 @@ module ActiveRecord :first_or_create, :first_or_create!, :first_or_initialize, :find_or_create_by, :find_or_create_by!, :find_or_initialize_by, :create_or_find_by, :create_or_find_by!, - :destroy_all, :delete_all, :update_all, :destroy_by, :delete_by, + :destroy_all, :delete_all, :update_all, :touch_all, :destroy_by, :delete_by, :find_each, :find_in_batches, :in_batches, :select, :reselect, :order, :reorder, :group, :limit, :offset, :joins, :left_joins, :left_outer_joins, :where, :rewhere, :preload, :extract_associated, :eager_load, :includes, :from, :lock, :readonly, :extending, :or, diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb index 8208c45df1..085006c9a2 100644 --- a/activerecord/test/cases/relation/delegation_test.rb +++ b/activerecord/test/cases/relation/delegation_test.rb @@ -56,7 +56,7 @@ module ActiveRecord :first_or_create, :first_or_create!, :first_or_initialize, :find_or_create_by, :find_or_create_by!, :find_or_initialize_by, :create_or_find_by, :create_or_find_by!, - :destroy_all, :delete_all, :update_all, :delete_by, :destroy_by + :destroy_all, :delete_all, :update_all, :touch_all, :delete_by, :destroy_by ] def test_delegate_querying_methods diff --git a/activerecord/test/cases/relation/update_all_test.rb b/activerecord/test/cases/relation/update_all_test.rb index 0500574f28..e45531b4a9 100644 --- a/activerecord/test/cases/relation/update_all_test.rb +++ b/activerecord/test/cases/relation/update_all_test.rb @@ -241,6 +241,38 @@ class UpdateAllTest < ActiveRecord::TestCase end end + def test_klass_level_update_all + travel 5.seconds do + now = Time.now.utc + + Person.all.each do |person| + assert_not_equal now, person.updated_at + end + + Person.update_all(updated_at: now) + + Person.all.each do |person| + assert_equal now, person.updated_at + end + end + end + + def test_klass_level_touch_all + travel 5.seconds do + now = Time.now.utc + + Person.all.each do |person| + assert_not_equal now, person.updated_at + end + + Person.touch_all(time: now) + + Person.all.each do |person| + assert_equal now, person.updated_at + end + end + end + # Oracle UPDATE does not support ORDER BY unless current_adapter?(:OracleAdapter) def test_update_all_ignores_order_without_limit_from_association |