diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-07-18 07:54:48 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-21 14:55:57 +0200 |
commit | 992711a86bc4ddd4460f9067e49eea36b37ca94f (patch) | |
tree | 230b419c54ec4633ea033c847a7a8b81ea7a9683 /activerecord/test/cases | |
parent | c96a50539121c4a722f354220c7f0e314b24804d (diff) | |
download | rails-992711a86bc4ddd4460f9067e49eea36b37ca94f.tar.gz rails-992711a86bc4ddd4460f9067e49eea36b37ca94f.tar.bz2 rails-992711a86bc4ddd4460f9067e49eea36b37ca94f.zip |
update_attribute should not update readonly attributes
[#5106 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index 4ea5df0945..54fe991648 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -17,13 +17,14 @@ require 'models/comment' require 'models/minimalistic' require 'models/warehouse_thing' require 'models/parrot' +require 'models/minivan' require 'models/loose_person' require 'rexml/document' require 'active_support/core_ext/exception' class PersistencesTest < ActiveRecord::TestCase - fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts + fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts, :minivans def test_create topic = Topic.new @@ -220,6 +221,11 @@ class PersistencesTest < ActiveRecord::TestCase assert !Topic.find(1).approved? end + def test_update_attribute_for_readonly_attribute + minivan = Minivan.find('m1') + assert_raises(ActiveRecord::ActiveRecordError) { minivan.update_attribute(:color, 'black') } + end + def test_update_attribute_with_one_changed_and_one_updated t = Topic.order('id').limit(1).first title, author_name = t.title, t.author_name |