diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-05 17:59:47 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 17:59:47 +0900 |
commit | 902c06f8355adce4109fde76680d956b16428166 (patch) | |
tree | 69be812c997390b9645b5c282c0c87f28388c72a /activerecord/test/cases | |
parent | bd1e9a1b98d1a3fcd419e4f975f7efa012b6f399 (diff) | |
parent | 824ea8d06ff596f5e60307082828745b4afd4ebf (diff) | |
download | rails-902c06f8355adce4109fde76680d956b16428166.tar.gz rails-902c06f8355adce4109fde76680d956b16428166.tar.bz2 rails-902c06f8355adce4109fde76680d956b16428166.zip |
Merge pull request #35871 from kamipo/klass_level_touch_all
Add missing `touch_all` delegation to relation
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relation/delegation_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relation/update_all_test.rb | 32 |
2 files changed, 33 insertions, 1 deletions
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 |