Permalink
Browse files

Fixed syntax for previous test I created; added before_validation_on_…

…* deprecation check
  • Loading branch information...
1 parent 9eb81b7 commit aa218395d3eb3c6526b386be41ea8e03f25adfc2 Josh Delsman committed with jm Jul 17, 2010
Showing with 31 additions and 6 deletions.
  1. +21 −3 lib/application_checker.rb
  2. +10 −3 test/application_checker_test.rb
View
@@ -51,7 +51,7 @@ def check_ar_methods
end
end
- def check_validation_methods
+ def check_validation_on_methods
files = []
["validate_on_create", "validate_on_update"].each do |v|
@@ -61,13 +61,31 @@ def check_validation_methods
if files
alert(
- "Removed validate_on_* methods",
- "Validate-on-callback methods (validate_on_create/validate_on_destroy) have been removed",
+ "Updated syntax for validate_on_* methods",
+ "Validate-on-callback methods (validate_on_create/validate_on_destroy) have been changed to validate :x, :on => :create",
"https://rails.lighthouseapp.com/projects/8994/tickets/3880-validate_on_create-and-validate_on_update-no-longer-seem-to-exist",
files
)
end
end
+
+ def check_before_validation_on_methods
+ files = []
+
+ %w(before_validation_on_create before_validation_on_update).each do |v|
+ lines = grep_for(v, "app/models/")
+ files += extract_filenames(lines) || []
+ end
+
+ if files
+ alert(
+ "Updated syntax for before_validation_on_* methods",
+ "before_validation_on_* methods have been changed to before_validation(:on => :create/:update) { ... }",
+ "https://rails.lighthouseapp.com/projects/8994/tickets/4699-before_validation_on_create-and-before_validation_on_update-doesnt-exist",
+ files
+ )
+ end
+ end
# Check for deprecated router syntax
def check_routes
@@ -58,11 +58,18 @@ def test_check_ar_methods_in_models
assert @checker.alerts.has_key?("Soon-to-be-deprecated ActiveRecord calls")
end
- def test_check_validation_methods
+ def test_check_validation_on_methods
make_file("app/models", "post.rb", "validate_on_create :comments_valid?")
- @checker.check_validation_methods
+ @checker.check_validation_on_methods
- assert @checker.alerts.has_key?("Removed validate_on_* methods")
+ assert @checker.alerts.has_key?("Updated syntax for validate_on_* methods")
+ end
+
+ def test_check_before_validation_on_methods
+ make_file("app/models", "post.rb", "before_validation_on_create :comments_valid?")
+ @checker.check_before_validation_on_methods
+
+ assert @checker.alerts.has_key?("Updated syntax for before_validation_on_* methods")
end
def test_named_scope_left_over

0 comments on commit aa21839

Please sign in to comment.