From 6674c844b9d1d116cc5c5237c4d0d1d3c152a0cd Mon Sep 17 00:00:00 2001 From: Pat George Date: Sat, 5 Jun 2010 05:50:16 +0800 Subject: [PATCH] Mail API checker no longer reports false positives from updated Mail files. --- lib/application_checker.rb | 18 ++++++++------ test/application_checker_test.rb | 42 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/lib/application_checker.rb b/lib/application_checker.rb index 21dce00..da43304 100644 --- a/lib/application_checker.rb +++ b/lib/application_checker.rb @@ -165,8 +165,8 @@ module Rails end files = [] - ["recipients ", "attachment ", "subject ", "from "].each do |v| - lines = grep_for(v, "app/models/") + ["recipients ", "attachment(?!s) ", "(? @users\n end") + @checker.check_mailers + + assert ! @checker.alerts.has_key?("Old ActionMailer class API") + end + + def test_new_check_mailer_syntax_subject + make_file("app/models/", "notifications.rb", "def signup\n:subject => @users\n end") + @checker.check_mailers + + assert ! @checker.alerts.has_key?("Old ActionMailer class API") + end + + def test_new_check_mailer_syntax_attachments + make_file("app/models/", "notifications.rb", "def signup\nattachments['an-image.jp'] = File.read('an-image.jpg')\n end") + @checker.check_mailers + + assert ! @checker.alerts.has_key?("Old ActionMailer class API") + end + def test_check_mailer_api make_file("app/controllers/", "thing_controller.rb", "def signup\n Notifications.deliver_signup\n end") @checker.check_mailers