diff options
Diffstat (limited to 'activerecord/test/cases/locking_test.rb')
-rw-r--r-- | activerecord/test/cases/locking_test.rb | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index de017022d7..4eb89b8595 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -11,7 +11,7 @@ class LockWithoutDefault < ActiveRecord::Base; end class LockWithCustomColumnWithoutDefault < ActiveRecord::Base self.table_name = :lock_without_defaults_cust - set_locking_column :custom_lock_version + self.locking_column = :custom_lock_version end class ReadonlyFirstNamePerson < Person @@ -226,6 +226,46 @@ class OptimisticLockingTest < ActiveRecord::TestCase end end +class SetLockingColumnTest < ActiveRecord::TestCase + def test_set_set_locking_column_with_value + k = Class.new( ActiveRecord::Base ) + k.locking_column = "foo" + assert_equal "foo", k.locking_column + + assert_deprecated do + k.set_locking_column "bar" + end + assert_equal "bar", k.locking_column + end + + def test_set_locking_column_with_block + k = Class.new( ActiveRecord::Base ) + k.locking_column = 'foo' + + assert_deprecated do + k.set_locking_column { "lock_" + original_locking_column } + end + assert_equal "lock_foo", k.locking_column + end + + def test_original_locking_column + k = Class.new(ActiveRecord::Base) + k.locking_column = "bar" + + assert_deprecated do + assert_equal ActiveRecord::Locking::Optimistic::ClassMethods::DEFAULT_LOCKING_COLUMN, k.original_locking_column + end + + k = Class.new(ActiveRecord::Base) + k.locking_column = "omg" + k.locking_column = "wtf" + + assert_deprecated do + assert_equal "omg", k.original_locking_column + end + end +end + class OptimisticLockingWithSchemaChangeTest < ActiveRecord::TestCase fixtures :people, :legacy_things, :references |