Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for ActionMailer::Base.method_missing so that it raises NoMethodE…

…rror when no method is found [#1330 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit a62e9e90d8f47a643c9355f782ab4891fa8fefaa 1 parent 78a1839
@mocoso mocoso authored josh committed
View
14 actionmailer/lib/action_mailer/base.rb
@@ -386,12 +386,14 @@ def respond_to?(method_symbol, include_private = false) #: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
View
8 actionmailer/test/mail_service_test.rb
@@ -1045,4 +1045,12 @@ def test_should_not_respond_to_create_with_template_suffix_if_it_begins_with_a_d
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
Please sign in to comment.
Something went wrong with that request. Please try again.