Permalink
Browse files

Fixed method_missing for ActionMailer so it no longer matches methods…

… where deliver or create are not a suffix [#1318 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
1 parent a62e9e9 commit c65075feb6c4ce15582bc08411e6698d782249a7 @mocoso mocoso committed with josh Nov 11, 2008
Showing with 6 additions and 1 deletion.
  1. +2 −1 actionmailer/lib/action_mailer/base.rb
  2. +4 −0 actionmailer/test/mail_service_test.rb
@@ -391,6 +391,7 @@ def method_missing(method_symbol, *parameters) #:nodoc:
when 'create' then new(match[2], *parameters).mail
when 'deliver' then new(match[2], *parameters).deliver!
when 'new' then nil
+ else super
end
else
super
@@ -442,7 +443,7 @@ def template_root=(root)
private
def matches_dynamic_method?(method_name) #:nodoc:
method_name = method_name.to_s
- /(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
+ /^(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
end
end
@@ -1046,6 +1046,10 @@ def test_should_not_respond_to_deliver_with_template_suffix_if_it_begins_with_a_
assert !RespondToMailer.respond_to?(:deliver_1_template)
end
+ def test_should_not_respond_to_method_where_deliver_is_not_a_suffix
+ assert !RespondToMailer.respond_to?(:foo_deliver_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

1 comment on commit c65075f

Isn’t deliver a prefix here, not a suffix?

Please sign in to comment.