aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorTarmo Tänav <tarmo@itech.ee>2008-09-10 13:39:50 +0300
committerMichael Koziarski <michael@koziarski.com>2008-09-10 13:41:49 +0200
commit7c9851dbb6f841ffbf3ebd16e9f57c04319d3a39 (patch)
treeadc55140a573c0c7cd99a405f2f593e721f1efb3 /activerecord/test/cases
parent14d1560e85d5c4795c21ddb00953cf55e0525ee3 (diff)
downloadrails-7c9851dbb6f841ffbf3ebd16e9f57c04319d3a39.tar.gz
rails-7c9851dbb6f841ffbf3ebd16e9f57c04319d3a39.tar.bz2
rails-7c9851dbb6f841ffbf3ebd16e9f57c04319d3a39.zip
Support :limit on update_all so that has_many with :limit can be safely updated
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/base_test.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 67358fedd6..bda6f346f0 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -76,7 +76,7 @@ class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base
end
class BasicsTest < ActiveRecord::TestCase
- fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories
+ fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts
def test_table_exists
assert !NonExistentTable.table_exists?
@@ -664,10 +664,21 @@ class BasicsTest < ActiveRecord::TestCase
end
end
- def test_update_all_ignores_order_limit_from_association
- author = Author.find(1)
+ def test_update_all_ignores_order_without_limit_from_association
+ author = authors(:david)
assert_nothing_raised do
- assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all("body = 'bulk update!'")
+ assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all([ "body = ?", "bulk update!" ])
+ end
+ end
+
+ def test_update_all_with_order_and_limit_updates_subset_only
+ author = authors(:david)
+ assert_nothing_raised do
+ assert_equal 1, author.posts_sorted_by_id_limited.size
+ assert_equal 2, author.posts_sorted_by_id_limited.find(:all, :limit => 2).size
+ assert_equal 1, author.posts_sorted_by_id_limited.update_all([ "body = ?", "bulk update!" ])
+ assert_equal "bulk update!", posts(:welcome).body
+ assert_not_equal "bulk update!", posts(:thinking).body
end
end