From 7e37bbed980f6fc5327e9fa786cccaa1d4836894 Mon Sep 17 00:00:00 2001 From: Joel Chippindale Date: Wed, 5 Nov 2008 09:27:03 +0000 Subject: [PATCH] Fix for ActionMailer::Base.method_missing so that it raises NoMethodError when no method is found This was broken in commit 3cf773b187e803e16b8237e5923fa4c1139cde8a --- actionmailer/lib/action_mailer/base.rb | 14 ++++++++------ actionmailer/test/mail_service_test.rb | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 043f56b..ee3e1dc 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -386,12 +386,14 @@ module ActionMailer #:nodoc: end def method_missing(method_symbol, *parameters) #:nodoc: - match = matches_dynamic_method?(method_symbol) - case match[1] - when 'create' then new(match[2], *parameters).mail - when 'deliver' then new(match[2], *parameters).deliver! - when 'new' then nil - else super + if match = matches_dynamic_method?(method_symbol) + case match[1] + when 'create' then new(match[2], *parameters).mail + when 'deliver' then new(match[2], *parameters).deliver! + when 'new' then nil + end + else + super end end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 7f9540c..e7a52bf 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -1031,4 +1031,12 @@ class RespondToTest < Test::Unit::TestCase def test_should_not_respond_to_deliver_with_template_suffix_if_it_begins_with_a_digit assert !RespondToMailer.respond_to?(:deliver_1_template) end + + def test_should_still_raise_exception_with_expected_message_when_calling_an_undefined_method + error = assert_raises NoMethodError do + RespondToMailer.not_a_method + end + + assert_match /undefined method.*not_a_method/, error.message + end end -- 1.6.0.2