Added check for validate_on_create and validate_on_update, which have both been removed in Rails 3

This commit is contained in:
Josh Delsman 2010-07-17 12:54:55 +08:00 committed by Jeremy McAnally
parent 6674c844b9
commit 9eb81b7134
2 changed files with 25 additions and 0 deletions

View File

@ -50,6 +50,24 @@ module Rails
)
end
end
def check_validation_methods
files = []
["validate_on_create", "validate_on_update"].each do |v|
lines = grep_for(v, "app/models/")
files += extract_filenames(lines) || []
end
if files
alert(
"Removed validate_on_* methods",
"Validate-on-callback methods (validate_on_create/validate_on_destroy) have been removed",
"https://rails.lighthouseapp.com/projects/8994/tickets/3880-validate_on_create-and-validate_on_update-no-longer-seem-to-exist",
files
)
end
end
# Check for deprecated router syntax
def check_routes

View File

@ -57,6 +57,13 @@ class ApplicationCheckerTest < ActiveSupport::TestCase
assert @checker.alerts.has_key?("Soon-to-be-deprecated ActiveRecord calls")
end
def test_check_validation_methods
make_file("app/models", "post.rb", "validate_on_create :comments_valid?")
@checker.check_validation_methods
assert @checker.alerts.has_key?("Removed validate_on_* methods")
end
def test_named_scope_left_over
make_file("app/models", "post.rb", "named_scope :failure")