diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-11-29 19:40:29 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-11-29 20:13:37 +0000 |
commit | f3c84dc31692204aacac3c125dcfcc986fd961a0 (patch) | |
tree | 71731744d75ff5ea5c05ca20e435266f0bf1e2c7 /activerecord/test | |
parent | 1a474cc8e41522ae079871d297c0e61ee4f6ef35 (diff) | |
download | rails-f3c84dc31692204aacac3c125dcfcc986fd961a0.tar.gz rails-f3c84dc31692204aacac3c125dcfcc986fd961a0.tar.bz2 rails-f3c84dc31692204aacac3c125dcfcc986fd961a0.zip |
Deprecate set_locking_column in favour of self.locking_column=
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/locking_test.rb | 42 | ||||
-rw-r--r-- | activerecord/test/models/legacy_thing.rb | 2 |
2 files changed, 42 insertions, 2 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 diff --git a/activerecord/test/models/legacy_thing.rb b/activerecord/test/models/legacy_thing.rb index eaeb642d12..eead181a0e 100644 --- a/activerecord/test/models/legacy_thing.rb +++ b/activerecord/test/models/legacy_thing.rb @@ -1,3 +1,3 @@ class LegacyThing < ActiveRecord::Base - set_locking_column :version + self.locking_column = :version end |