diff options
author | Dmitry Vorotilin <d.vorotilin@gmail.com> | 2013-03-14 01:19:27 +0400 |
---|---|---|
committer | Dmitry Vorotilin <d.vorotilin@gmail.com> | 2013-03-22 17:57:34 +0400 |
commit | 89828a405254bca8cf65259c54990dfe1921326d (patch) | |
tree | af47c84e9281bc45483ca8335ed9f2877388635a /activerecord/test/cases | |
parent | 7748d64a76ae140cb80cd54d183bc1f94c192b9d (diff) | |
download | rails-89828a405254bca8cf65259c54990dfe1921326d.tar.gz rails-89828a405254bca8cf65259c54990dfe1921326d.tar.bz2 rails-89828a405254bca8cf65259c54990dfe1921326d.zip |
When we pass id to update_attributes it will try to set new id for that record
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index b936cca875..a29189df05 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -661,6 +661,15 @@ class PersistencesTest < ActiveRecord::TestCase topic.reload assert !topic.approved? assert_equal "The First Topic", topic.title + + assert_raise(ActiveRecord::RecordNotUnique, ActiveRecord::StatementInvalid) do + topic.update_attributes(id: 3, title: "Hm is it possible?") + end + assert_not_equal "Hm is it possible?", Topic.find(3).title + + topic.update_attributes(id: 1234) + assert_nothing_raised { topic.reload } + assert_equal topic.title, Topic.find(1234).title end def test_update! |