mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
a11ca2ff76
commit
824ea8d06f
3 changed files with 34 additions and 2 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue