correctly greping for depreciated ERb block helpers

This commit is contained in:
Zac Williams 2010-08-20 06:35:10 +08:00 committed by Jeremy McAnally
parent 3015100b37
commit 56b03373a8
2 changed files with 16 additions and 1 deletions

View File

@ -259,7 +259,14 @@ module Rails
# Checks for old-style ERb helpers
def check_old_helpers
lines = grep_for("<% .* do.*%>", "app/views/**/*")
lines = grep_for("<% .*content_tag.* do.*%>", "app/views/**/*")
lines += grep_for("<% .*javascript_tag.* do.*%>", "app/views/**/*")
lines += grep_for("<% .*form_for.* do.*%>", "app/views/**/*")
lines += grep_for("<% .*form_tag.* do.*%>", "app/views/**/*")
lines += grep_for("<% .*fields_for.* do.*%>", "app/views/**/*")
lines += grep_for("<% .*field_set_tag.* do.*%>", "app/views/**/*")
files = extract_filenames(lines)
if files

View File

@ -244,6 +244,14 @@ class ApplicationCheckerTest < ActiveSupport::TestCase
@checker.check_old_helpers
assert @checker.alerts.has_key?("Deprecated ERb helper calls")
end
def test_check_old_helpers_lets_regular_blocks_pass
make_file("app/views/users/", "another_test.html.erb", "<b>blah blah blah</b><% @some_items.each do |item| %> <label>doo dah</label> <%= item %> <% end %>")
@checker.check_old_helpers
assert_equal @checker.alerts.has_key?("Deprecated ERb helper calls"), false
end
def test_check_old_helpers_lets_regular_blocks_pass