From ce102e3af9ccdb5015e20ab7155d2a13c7832a9a Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sat, 15 Dec 2007 01:45:30 +0000 Subject: Ensure optimistic locking handles nil #lock_version values properly. Closes #10510 [rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8395 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/locking_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/locking_test.rb b/activerecord/test/locking_test.rb index 97fbfaaeb1..9a3b76e810 100644 --- a/activerecord/test/locking_test.rb +++ b/activerecord/test/locking_test.rb @@ -64,6 +64,15 @@ class OptimisticLockingTest < Test::Unit::TestCase assert_raises(ActiveRecord::StaleObjectError) { p2.save! } end + + def test_lock_new_with_nil + p1 = Person.new(:first_name => 'anika') + p1.save! + p1.lock_version = nil # simulate bad fixture or column with no default + p1.save! + assert_equal 1, p1.lock_version + end + def test_lock_column_name_existing t1 = LegacyThing.find(1) -- cgit v1.2.3