Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

normalize arg for ActionMailer::TestCase tests method

  • Loading branch information...
commit 0defbc6bfeff053983ef65739b2dcc080b2ad227 1 parent 6f429f3
@avakhov avakhov authored
View
9 actionmailer/lib/action_mailer/test_case.rb
@@ -17,7 +17,14 @@ module Behavior
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
28 actionmailer/test/test_test.rb
@@ -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

0 comments on commit 0defbc6

Please sign in to comment.
Something went wrong with that request. Please try again.