Permalink
Browse files

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

  • Loading branch information...
1 parent 648c5a1 commit 015cac755390b344092ab81c512941a95c02cb5e @rafaelfranca rafaelfranca committed Aug 21, 2012
Showing with 10 additions and 9 deletions.
  1. +10 −9 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'
@@ -14,8 +15,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
@@ -196,15 +197,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 015cac7

Please sign in to comment.