aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/lib/action_mailer/test_case.rb8
-rw-r--r--actionmailer/test/test_test.rb144
2 files changed, 149 insertions, 3 deletions
diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb
index 251705ae50..e60dda9694 100644
--- a/actionmailer/lib/action_mailer/test_case.rb
+++ b/actionmailer/lib/action_mailer/test_case.rb
@@ -49,9 +49,11 @@ module ActionMailer
end
def determine_default_mailer(name)
- name.sub(/Test$/, '').constantize
- rescue NameError
- raise NonInferrableMailerError.new(name)
+ mailer = determine_constant_from_test_name(name) do |constant|
+ Class === constant && constant < ActionMailer::Base
+ end
+ raise NonInferrableMailerError.new(name) if mailer.nil?
+ mailer
end
end
diff --git a/actionmailer/test/test_test.rb b/actionmailer/test/test_test.rb
index 86fd37bea6..139eb53359 100644
--- a/actionmailer/test/test_test.rb
+++ b/actionmailer/test/test_test.rb
@@ -26,3 +26,147 @@ class CrazyStringNameMailerTest < ActionMailer::TestCase
assert_equal TestTestMailer, self.class.mailer_class
end
end
+
+describe TestTestMailer do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe TestTestMailer, :action do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe TestTestMailer do
+ describe "nested" do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe TestTestMailer, :action do
+ describe "nested" do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe "TestTestMailer" do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe "TestTestMailerTest" do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe "TestTestMailer" do
+ describe "nested" do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe "TestTestMailerTest" do
+ describe "nested" do
+ it "gets the mailer from the test name" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe "AnotherCrazySymbolNameMailerTest" do
+ tests :test_test_mailer
+
+ it "gets the mailer after setting it with a symbol" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe "AnotherCrazyStringNameMailerTest" do
+ tests 'test_test_mailer'
+
+ it "gets the mailer after setting it with a string" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe "Another Crazy Name Mailer Test" do
+ tests TestTestMailer
+
+ it "gets the mailer after setting it manually" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe "Another Crazy Symbol Name Mailer Test" do
+ tests :test_test_mailer
+
+ it "gets the mailer after setting it with a symbol" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe "Another Crazy String Name Mailer Test" do
+ tests 'test_test_mailer'
+
+ it "gets the mailer after setting it with a string" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end
+
+describe "AnotherCrazySymbolNameMailerTest" do
+ tests :test_test_mailer
+
+ describe "nested" do
+ it "gets the mailer after setting it with a symbol" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe "AnotherCrazyStringNameMailerTest" do
+ tests 'test_test_mailer'
+
+ describe "nested" do
+ it "gets the mailer after setting it with a string" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe "Another Crazy Name Mailer Test" do
+ tests TestTestMailer
+
+ describe "nested" do
+ it "gets the mailer after setting it manually" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe "Another Crazy Symbol Name Mailer Test" do
+ tests :test_test_mailer
+
+ describe "nested" do
+ it "gets the mailer after setting it with a symbol" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+ end
+end
+
+describe "Another Crazy String Name Mailer Test" do
+ tests 'test_test_mailer'
+
+ it "gets the mailer after setting it with a string" do
+ assert_equal TestTestMailer, self.class.mailer_class
+ end
+end