@@ -307,24 +307,14 @@ def test_touch_existing_lock_without_default_should_work_with_null_in_the_databa
307
307
308
308
def test_update_lock_version_to_nil_without_validation_or_constraint_raises_error
309
309
t1 = LockWithoutDefault . create! ( title : "title1" )
310
- error = assert_raises ( RuntimeError ) { t1 . update ( lock_version : nil ) }
311
-
312
- assert_match ( locking_column_nil_error_message , error . message )
313
-
314
- error = assert_raises ( RuntimeError ) { t1 . update! ( lock_version : nil ) }
315
-
316
- assert_match ( locking_column_nil_error_message , error . message )
310
+ assert_raises ( RuntimeError , match : locking_column_nil_error_message ) { t1 . update ( lock_version : nil ) }
311
+ assert_raises ( RuntimeError , match : locking_column_nil_error_message ) { t1 . update! ( lock_version : nil ) }
317
312
end
318
313
319
314
def test_update_lock_version_to_nil_without_validation_raises
320
315
person = Person . find ( 1 )
321
- error = assert_raises ( RuntimeError ) { person . update ( lock_version : nil ) }
322
-
323
- assert_match ( locking_column_nil_error_message , error . message )
324
-
325
- error = assert_raises ( RuntimeError ) { person . update! ( lock_version : nil ) }
326
-
327
- assert_match ( locking_column_nil_error_message , error . message )
316
+ assert_raises ( RuntimeError , match : locking_column_nil_error_message ) { person . update ( lock_version : nil ) }
317
+ assert_raises ( RuntimeError , match : locking_column_nil_error_message ) { person . update! ( lock_version : nil ) }
328
318
end
329
319
330
320
def test_update_lock_version_to_nil_with_validation_does_not_raise_runtime_lock_version_error
@@ -597,7 +587,10 @@ def test_yaml_dumping_with_lock_column
597
587
598
588
private
599
589
def locking_column_nil_error_message
600
- /'lock_version' should not be set to `nil`/
590
+ <<-MSG . squish
591
+ For optimistic locking, locking_column ('lock_version') can't be nil.
592
+ Are you missing a default value or validation on 'lock_version'?
593
+ MSG
601
594
end
602
595
end
603
596
0 commit comments