From 824ea8d06ff596f5e60307082828745b4afd4ebf Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Fri, 5 Apr 2019 16:13:40 +0900 Subject: Add missing `touch_all` delegation to relation Follow up of #31513. --- .../test/cases/relation/delegation_test.rb | 2 +- .../test/cases/relation/update_all_test.rb | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'activerecord/test') 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 -- cgit v1.2.3