1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

normalize arg for ActionMailer::TestCase tests method

This commit is contained in:
Alexey Vakhov 2011-10-03 11:04:22 +04:00
parent 6f429f375e
commit 0defbc6bfe
2 changed files with 36 additions and 1 deletions

View file

@ -17,7 +17,14 @@ module ActionMailer
module ClassMethods
def tests(mailer)
self._mailer_class = mailer
case mailer
when String, Symbol
self._mailer_class = mailer.to_s.camelize.constantize
when Module
self._mailer_class = mailer
else
raise NonInferrableMailerError.new(mailer)
end
end
def mailer_class

View file

@ -0,0 +1,28 @@
require 'abstract_unit'
class TestTestMailer < ActionMailer::Base
end
class CrazyNameMailerTest < ActionMailer::TestCase
tests TestTestMailer
def test_set_mailer_class_manual
assert_equal TestTestMailer, self.class.mailer_class
end
end
class CrazySymbolNameMailerTest < ActionMailer::TestCase
tests :test_test_mailer
def test_set_mailer_class_manual_using_symbol
assert_equal TestTestMailer, self.class.mailer_class
end
end
class CrazyStringNameMailerTest < ActionMailer::TestCase
tests 'test_test_mailer'
def test_set_mailer_class_manual_using_string
assert_equal TestTestMailer, self.class.mailer_class
end
end