Skip to content
Browse files

Use a model without counter cache to test read-only attributes

  • Loading branch information...
1 parent df1a5e4 commit f89d5e4603d53ae38e39cced22479420e61ad761 @rafaelfranca rafaelfranca committed Aug 21, 2012
Showing with 10 additions and 9 deletions.
  1. +10 −9 activerecord/test/cases/locking_test.rb
View
19 activerecord/test/cases/locking_test.rb
@@ -3,6 +3,7 @@
require 'models/person'
require 'models/job'
require 'models/reader'
+require 'models/ship'
require 'models/legacy_thing'
require 'models/reference'
require 'models/string_key_object'
@@ -18,8 +19,8 @@ class LockWithCustomColumnWithoutDefault < ActiveRecord::Base
self.locking_column = :custom_lock_version
end
-class ReadonlyFirstNamePerson < Person
- attr_readonly :first_name
+class ReadonlyNameShip < Ship
+ attr_readonly :name
end
class OptimisticLockingTest < ActiveRecord::TestCase
@@ -200,15 +201,15 @@ def test_lock_with_custom_column_without_default_sets_version_to_zero
end
def test_readonly_attributes
- assert_equal Set.new([ 'first_name' ]), ReadonlyFirstNamePerson.readonly_attributes
+ assert_equal Set.new([ 'name' ]), ReadonlyNameShip.readonly_attributes
- p = ReadonlyFirstNamePerson.create(:first_name => "unchangeable name")
- p.reload
- assert_equal "unchangeable name", p.first_name
+ s = ReadonlyNameShip.create(:name => "unchangeable name")
+ s.reload
+ assert_equal "unchangeable name", s.name
- p.update_attributes(:first_name => "changed name")
- p.reload
- assert_equal "unchangeable name", p.first_name
+ s.update_attributes(:name => "changed name")
+ s.reload
+ assert_equal "unchangeable name", s.name
end
def test_quote_table_name

0 comments on commit f89d5e4

Please sign in to comment.
Something went wrong with that request. Please try again.