public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
change activerecord validation tests to not use the deprecated interpolation 
syntax any more

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
svenfuchs (author)
Wed Sep 10 15:30:07 -0700 2008
jeremy (committer)
Wed Sep 10 19:28:36 -0700 2008
commit  79c8b104d676ce40268caaa530b7e4dcc0a8ff20
tree    5e619faef5255b6bd5a80b45fc6022e9a3e7a911
parent  70a4f6c2dd66d855ff66a176076ad45caf3ed6ab
...
605
606
607
608
 
609
610
611
...
666
667
668
669
 
670
671
672
...
691
692
693
694
 
695
696
697
...
791
792
793
794
 
795
796
797
...
812
813
814
815
 
816
817
818
...
875
876
877
878
 
879
880
881
...
919
920
921
922
 
923
924
925
...
927
928
929
930
 
931
932
933
...
935
936
937
938
 
939
940
941
...
943
944
945
946
 
947
948
949
...
951
952
953
954
 
955
956
957
...
959
960
961
962
 
963
964
965
...
1025
1026
1027
1028
 
1029
1030
1031
...
1048
1049
1050
1051
 
1052
1053
1054
...
1083
1084
1085
1086
 
1087
1088
1089
...
1234
1235
1236
1237
 
1238
1239
1240
...
1243
1244
1245
1246
 
1247
1248
1249
...
1251
1252
1253
1254
 
1255
1256
1257
...
1259
1260
1261
1262
 
1263
1264
1265
...
1268
1269
1270
1271
 
1272
1273
1274
...
1277
1278
1279
1280
 
1281
1282
1283
...
1285
1286
1287
1288
 
1289
1290
1291
...
1293
1294
1295
1296
 
1297
1298
1299
...
1302
1303
1304
1305
 
1306
1307
1308
...
1312
1313
1314
1315
 
1316
1317
1318
...
1321
1322
1323
1324
 
1325
1326
1327
...
1330
1331
1332
1333
 
1334
1335
1336
...
1507
1508
1509
1510
 
1511
1512
1513
1514
1515
1516
 
1517
1518
1519
...
605
606
607
 
608
609
610
611
...
666
667
668
 
669
670
671
672
...
691
692
693
 
694
695
696
697
...
791
792
793
 
794
795
796
797
...
812
813
814
 
815
816
817
818
...
875
876
877
 
878
879
880
881
...
919
920
921
 
922
923
924
925
...
927
928
929
 
930
931
932
933
...
935
936
937
 
938
939
940
941
...
943
944
945
 
946
947
948
949
...
951
952
953
 
954
955
956
957
...
959
960
961
 
962
963
964
965
...
1025
1026
1027
 
1028
1029
1030
1031
...
1048
1049
1050
 
1051
1052
1053
1054
...
1083
1084
1085
 
1086
1087
1088
1089
...
1234
1235
1236
 
1237
1238
1239
1240
...
1243
1244
1245
 
1246
1247
1248
1249
...
1251
1252
1253
 
1254
1255
1256
1257
...
1259
1260
1261
 
1262
1263
1264
1265
...
1268
1269
1270
 
1271
1272
1273
1274
...
1277
1278
1279
 
1280
1281
1282
1283
...
1285
1286
1287
 
1288
1289
1290
1291
...
1293
1294
1295
 
1296
1297
1298
1299
...
1302
1303
1304
 
1305
1306
1307
1308
...
1312
1313
1314
 
1315
1316
1317
1318
...
1321
1322
1323
 
1324
1325
1326
1327
...
1330
1331
1332
 
1333
1334
1335
1336
...
1507
1508
1509
 
1510
1511
1512
1513
1514
1515
 
1516
1517
1518
1519
0
@@ -605,7 +605,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validate_format_with_formatted_message
0
-    Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => "can't be %s")
0
+    Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => "can't be {{value}}")
0
     t = Topic.create(:title => 'Invalid title')
0
     assert_equal "can't be Invalid title", t.errors.on(:title)
0
   end
0
@@ -666,7 +666,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_inclusion_of_with_formatted_message
0
-    Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => "option %s is not in the list" )
0
+    Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => "option {{value}} is not in the list" )
0
 
0
     assert Topic.create("title" => "a", "content" => "abc").valid?
0
 
0
@@ -691,7 +691,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_exclusion_of_with_formatted_message
0
-    Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => "option %s is restricted" )
0
+    Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => "option {{value}} is restricted" )
0
 
0
     assert Topic.create("title" => "something", "content" => "abc")
0
 
0
@@ -791,7 +791,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_optionally_validates_length_of_using_within_on_create
0
-    Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "my string is too long: %d"
0
+    Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "my string is too long: {{count}}"
0
 
0
     t = Topic.create("title" => "thisisnotvalid", "content" => "whatever")
0
     assert !t.save
0
@@ -812,7 +812,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_optionally_validates_length_of_using_within_on_update
0
-    Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "my string is too short: %d"
0
+    Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "my string is too short: {{count}}"
0
 
0
     t = Topic.create("title" => "vali", "content" => "whatever")
0
     assert !t.save
0
@@ -875,7 +875,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_validates_length_with_globally_modified_error_message
0
     ActiveSupport::Deprecation.silence do
0
-      ActiveRecord::Errors.default_error_messages[:too_short] = 'tu est trops petit hombre %d'
0
+      ActiveRecord::Errors.default_error_messages[:too_short] = 'tu est trops petit hombre {{count}}'
0
     end
0
     Topic.validates_length_of :title, :minimum => 10
0
     t = Topic.create(:title => 'too short')
0
@@ -919,7 +919,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_length_of_custom_errors_for_minimum_with_message
0
-    Topic.validates_length_of( :title, :minimum=>5, :message=>"boo %d" )
0
+    Topic.validates_length_of( :title, :minimum=>5, :message=>"boo {{count}}" )
0
     t = Topic.create("title" => "uhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -927,7 +927,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_length_of_custom_errors_for_minimum_with_too_short
0
-    Topic.validates_length_of( :title, :minimum=>5, :too_short=>"hoo %d" )
0
+    Topic.validates_length_of( :title, :minimum=>5, :too_short=>"hoo {{count}}" )
0
     t = Topic.create("title" => "uhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -935,7 +935,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_length_of_custom_errors_for_maximum_with_message
0
-    Topic.validates_length_of( :title, :maximum=>5, :message=>"boo %d" )
0
+    Topic.validates_length_of( :title, :maximum=>5, :message=>"boo {{count}}" )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -943,7 +943,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_length_of_custom_errors_for_maximum_with_too_long
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d" )
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}" )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -951,7 +951,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_length_of_custom_errors_for_is_with_message
0
-    Topic.validates_length_of( :title, :is=>5, :message=>"boo %d" )
0
+    Topic.validates_length_of( :title, :is=>5, :message=>"boo {{count}}" )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -959,7 +959,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_length_of_custom_errors_for_is_with_wrong_length
0
-    Topic.validates_length_of( :title, :is=>5, :wrong_length=>"hoo %d" )
0
+    Topic.validates_length_of( :title, :is=>5, :wrong_length=>"hoo {{count}}" )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -1025,7 +1025,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_optionally_validates_length_of_using_within_on_create_utf8
0
     with_kcode('UTF8') do
0
-      Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎます: %d"
0
+      Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎます: {{count}}"
0
 
0
       t = Topic.create("title" => "一二三四五六七八九十A", "content" => "whatever")
0
       assert !t.save
0
@@ -1048,7 +1048,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_optionally_validates_length_of_using_within_on_update_utf8
0
     with_kcode('UTF8') do
0
-      Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎます: %d"
0
+      Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎます: {{count}}"
0
 
0
       t = Topic.create("title" => "一二三4", "content" => "whatever")
0
       assert !t.save
0
@@ -1083,7 +1083,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_length_of_with_block
0
-    Topic.validates_length_of :content, :minimum => 5, :too_short=>"Your essay must be at least %d words.", 
0
+    Topic.validates_length_of :content, :minimum => 5, :too_short=>"Your essay must be at least {{count}} words.",
0
                                         :tokenizer => lambda {|str| str.scan(/\w+/) }
0
     t = Topic.create!(:content => "this content should be long enough")
0
     assert t.valid?
0
@@ -1234,7 +1234,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_if_validation_using_method_true
0
     # When the method returns true
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :if => :condition_is_true )
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => :condition_is_true )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -1243,7 +1243,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_unless_validation_using_method_true
0
     # When the method returns true
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :unless => :condition_is_true )
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => :condition_is_true )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert t.valid?
0
     assert !t.errors.on(:title)
0
@@ -1251,7 +1251,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_if_validation_using_method_false
0
     # When the method returns false
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :if => :condition_is_true_but_its_not )
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => :condition_is_true_but_its_not )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert t.valid?
0
     assert !t.errors.on(:title)
0
@@ -1259,7 +1259,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_unless_validation_using_method_false
0
     # When the method returns false
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :unless => :condition_is_true_but_its_not )
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => :condition_is_true_but_its_not )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -1268,7 +1268,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_if_validation_using_string_true
0
     # When the evaluated string returns true
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :if => "a = 1; a == 1" )
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => "a = 1; a == 1" )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -1277,7 +1277,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_unless_validation_using_string_true
0
     # When the evaluated string returns true
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :unless => "a = 1; a == 1" )
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => "a = 1; a == 1" )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert t.valid?
0
     assert !t.errors.on(:title)
0
@@ -1285,7 +1285,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_if_validation_using_string_false
0
     # When the evaluated string returns false
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :if => "false")
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => "false")
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert t.valid?
0
     assert !t.errors.on(:title)
0
@@ -1293,7 +1293,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_unless_validation_using_string_false
0
     # When the evaluated string returns false
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d", :unless => "false")
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => "false")
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
     assert t.errors.on(:title)
0
@@ -1302,7 +1302,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_if_validation_using_block_true
0
     # When the block returns true
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d",
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
0
       :if => Proc.new { |r| r.content.size > 4 } )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
@@ -1312,7 +1312,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_unless_validation_using_block_true
0
     # When the block returns true
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d",
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
0
       :unless => Proc.new { |r| r.content.size > 4 } )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert t.valid?
0
@@ -1321,7 +1321,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_if_validation_using_block_false
0
     # When the block returns false
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d",
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
0
       :if => Proc.new { |r| r.title != "uhohuhoh"} )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert t.valid?
0
@@ -1330,7 +1330,7 @@ class ValidationsTest < ActiveRecord::TestCase
0
 
0
   def test_unless_validation_using_block_false
0
     # When the block returns false
0
-    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %d",
0
+    Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
0
       :unless => Proc.new { |r| r.title != "uhohuhoh"} )
0
     t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
0
     assert !t.valid?
0
@@ -1507,13 +1507,13 @@ class ValidatesNumericalityTest < ActiveRecord::TestCase
0
   end
0
 
0
   def test_validates_numericality_with_numeric_message
0
-    Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than %d"
0
+    Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than {{count}}"
0
     topic = Topic.new("title" => "numeric test", "approved" => 10)
0
 
0
     assert !topic.valid?
0
     assert_equal "smaller than 4", topic.errors.on(:approved)
0
 
0
-    Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than %d"
0
+    Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than {{count}}"
0
     topic = Topic.new("title" => "numeric test", "approved" => 1)
0
 
0
     assert !topic.valid?

Comments