diff options
author | wangjohn <wangjohn@mit.edu> | 2013-03-21 17:10:17 -0400 |
---|---|---|
committer | wangjohn <wangjohn@mit.edu> | 2013-06-25 20:56:58 -0700 |
commit | 926c4b95e49cc65a1d7420392c95d2193b099965 (patch) | |
tree | 910528e0c3283283d101a0b46ba91bbe452efc6b /activerecord/test | |
parent | 9218770daa9ff0e3df56f75c98c053a6f8f751c7 (diff) | |
download | rails-926c4b95e49cc65a1d7420392c95d2193b099965.tar.gz rails-926c4b95e49cc65a1d7420392c95d2193b099965.tar.bz2 rails-926c4b95e49cc65a1d7420392c95d2193b099965.zip |
Raising an error when nil or non-hash is passed to update_attributes.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 15 |
2 files changed, 12 insertions, 5 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index ee0150558d..a3a7d338d1 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -92,7 +92,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase def test_set_attributes_without_hash topic = Topic.new - assert_nothing_raised { topic.attributes = '' } + assert_raise(ArgumentError) { topic.attributes = '' } end def test_integers_as_nil diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index 30dc2a34c6..6cd3e2154e 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -419,10 +419,6 @@ class PersistenceTest < ActiveRecord::TestCase assert !Topic.find(1).approved? end - def test_update_attribute_does_not_choke_on_nil - assert Topic.find(1).update(nil) - end - def test_update_attribute_for_readonly_attribute minivan = Minivan.find('m1') assert_raises(ActiveRecord::ActiveRecordError) { minivan.update_attribute(:color, 'black') } @@ -701,6 +697,17 @@ class PersistenceTest < ActiveRecord::TestCase assert_equal topic.title, Topic.find(1234).title end + def test_update_attributes_parameters + topic = Topic.find(1) + assert_nothing_raised do + topic.update_attributes({}) + end + + assert_raises(ArgumentError) do + topic.update_attributes(nil) + end + end + def test_update! Reply.validates_presence_of(:title) reply = Reply.find(2) |