aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/locking_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/locking_test.rb')
-rw-r--r--activerecord/test/locking_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/locking_test.rb b/activerecord/test/locking_test.rb
index 00df4bb8e4..80f0dc8496 100644
--- a/activerecord/test/locking_test.rb
+++ b/activerecord/test/locking_test.rb
@@ -2,6 +2,12 @@ require 'abstract_unit'
require 'fixtures/person'
require 'fixtures/legacy_thing'
+class LockWithoutDefault < ActiveRecord::Base; end
+
+class LockWithCustomColumnWithoutDefault < ActiveRecord::Base
+ set_locking_column :custom_lock_version
+end
+
class OptimisticLockingTest < Test::Unit::TestCase
fixtures :people, :legacy_things
@@ -56,6 +62,16 @@ class OptimisticLockingTest < Test::Unit::TestCase
assert_equal 1, p1.lock_version
assert_equal p1.lock_version, Person.new(p1.attributes).lock_version
end
+
+ def test_lock_without_default_sets_version_to_zero
+ t1 = LockWithoutDefault.new
+ assert_equal 0, t1.lock_version
+ end
+
+ def test_lock_with_custom_column_without_default_sets_version_to_zero
+ t1 = LockWithCustomColumnWithoutDefault.new
+ assert_equal 0, t1.custom_lock_version
+ end
end