1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add missing touch_all delegation to relation

Follow up of #31513.
This commit is contained in:
Ryuta Kamizono 2019-04-05 16:13:40 +09:00
parent a11ca2ff76
commit 824ea8d06f
3 changed files with 34 additions and 2 deletions

View file

@ -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,

View file

@ -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

View file

@ -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