From bee414748c975b2452bcb5025fe191bf4d06a4ca Mon Sep 17 00:00:00 2001 From: Trey Bean Date: Tue, 17 Aug 2010 12:51:13 -0600 Subject: [PATCH 1/4] Missing object for comparison in ActiveModel::EachValidator example code. --- activemodel/lib/active_model/validations/validates.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index 3242e49269..ba84f53e2a 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -48,7 +48,7 @@ module ActiveModel # # class TitleValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) - # record.errors[attribute] << "must start with 'the'" unless =~ /^the/i + # record.errors[attribute] << "must start with 'the'" unless value =~ /^the/i # end # end # From c924068714026ab798b16be5ee92b00b54b1f6f8 Mon Sep 17 00:00:00 2001 From: Sunny Ripert Date: Tue, 17 Aug 2010 21:48:43 +0200 Subject: [PATCH 2/4] Testing Guide: rake test:uncommitted now supports git --- railties/guides/source/testing.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index 69695c93c8..85066d5534 100644 --- a/railties/guides/source/testing.textile +++ b/railties/guides/source/testing.textile @@ -735,7 +735,7 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai |+rake test:plugins+ |Run all the plugin tests from +vendor/plugins/*/**/test+ (or specify with +PLUGIN=_name_+)| |+rake test:profile+ |Profile the performance tests| |+rake test:recent+ |Tests recent changes| -|+rake test:uncommitted+ |Runs all the tests which are uncommitted. Only supports Subversion| +|+rake test:uncommitted+ |Runs all the tests which are uncommitted. Only supports Subversion and Git| |+rake test:units+ |Runs all the unit tests from +test/unit+| From ea2ad26a8dc0240c40770bc1a5d3bac17ee3da8d Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 18 Aug 2010 00:15:01 +0200 Subject: [PATCH 3/4] you rarely want ^ or $ in validations, use \A when you mean \A --- activemodel/lib/active_model/validations/validates.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index ba84f53e2a..f6349d57a5 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -28,7 +28,7 @@ module ActiveModel # class EmailValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) # record.errors[attribute] << (options[:message] || "is not an email") unless - # value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i + # value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i # end # end # @@ -48,7 +48,7 @@ module ActiveModel # # class TitleValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) - # record.errors[attribute] << "must start with 'the'" unless value =~ /^the/i + # record.errors[attribute] << "must start with 'the'" unless value =~ /\Athe/i # end # end # From 23f6e51b69e9c4e4b5a43183b2fa28be45358a9e Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 18 Aug 2010 00:16:39 +0200 Subject: [PATCH 4/4] commit review: now that there are two supported, just mention them --- railties/guides/source/testing.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index 85066d5534..6686dc3290 100644 --- a/railties/guides/source/testing.textile +++ b/railties/guides/source/testing.textile @@ -735,7 +735,7 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai |+rake test:plugins+ |Run all the plugin tests from +vendor/plugins/*/**/test+ (or specify with +PLUGIN=_name_+)| |+rake test:profile+ |Profile the performance tests| |+rake test:recent+ |Tests recent changes| -|+rake test:uncommitted+ |Runs all the tests which are uncommitted. Only supports Subversion and Git| +|+rake test:uncommitted+ |Runs all the tests which are uncommitted. Supports Subversion and Git| |+rake test:units+ |Runs all the unit tests from +test/unit+|