aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-01-28 15:12:54 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-01-28 15:12:54 +0000
commit5acea7fc9ca19848733c0a81e0c018bc7388af5e (patch)
tree1ffa10bd2754f5eb67ce1d2ea725217b39984aca /activerecord/test
parentc5f7997ebc9a49c3b58f007de26569b7e5f1795e (diff)
downloadrails-5acea7fc9ca19848733c0a81e0c018bc7388af5e.tar.gz
rails-5acea7fc9ca19848733c0a81e0c018bc7388af5e.tar.bz2
rails-5acea7fc9ca19848733c0a81e0c018bc7388af5e.zip
update_all can take a Hash argument. sanitize_sql splits into two methods for conditions and assignment since NULL values and delimiters are handled differently. References #6583, closes #7365.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6073 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/base_test.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index 95c758f805..8892dcbdc8 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -534,17 +534,30 @@ class BasicsTest < Test::Unit::TestCase
Topic.decrement_counter("replies_count", 2)
assert_equal -2, Topic.find(2).replies_count
end
-
- def test_update_all
- # The ADO library doesn't support the number of affected rows
- return true if current_adapter?(:SQLServerAdapter)
- assert_equal 2, Topic.update_all("content = 'bulk updated!'")
- assert_equal "bulk updated!", Topic.find(1).content
- assert_equal "bulk updated!", Topic.find(2).content
- assert_equal 2, Topic.update_all(['content = ?', 'bulk updated again!'])
- assert_equal "bulk updated again!", Topic.find(1).content
- assert_equal "bulk updated again!", Topic.find(2).content
+ # The ADO library doesn't support the number of affected rows
+ unless current_adapter?(:SQLServerAdapter)
+ def test_update_all
+ assert_equal 2, Topic.update_all("content = 'bulk updated!'")
+ assert_equal "bulk updated!", Topic.find(1).content
+ assert_equal "bulk updated!", Topic.find(2).content
+
+ assert_equal 2, Topic.update_all(['content = ?', 'bulk updated again!'])
+ assert_equal "bulk updated again!", Topic.find(1).content
+ assert_equal "bulk updated again!", Topic.find(2).content
+
+ assert_equal 2, Topic.update_all(['content = ?', nil])
+ assert_nil Topic.find(1).content
+ end
+
+ def test_update_all_with_hash
+ assert_not_nil Topic.find(1).last_read
+ assert_equal 2, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil)
+ assert_equal "bulk updated with hash!", Topic.find(1).content
+ assert_equal "bulk updated with hash!", Topic.find(2).content
+ assert_nil Topic.find(1).last_read
+ assert_nil Topic.find(2).last_read
+ end
end
def test_update_many