Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11557: action_mailer_render_message_implicit_body_hash.diff

File action_mailer_render_message_implicit_body_hash.diff, 2.1 kB (added by Henrik N, 3 months ago)
  • rails/actionmailer/test/mail_render_test.rb

    old new  
    1212    recipients recipient 
    1313    subject    "using helpers" 
    1414    from       "tester@example.com" 
    15     body       render(:file => "signed_up", :body => { :recipient => recipient }) 
     15    body       render_message("signed_up", { :recipient => recipient }) 
    1616  end 
     17   
     18  def file_template_with_implicit_body_hash(recipient) 
     19    recipients recipient 
     20    subject    "using helpers" 
     21    from       "tester@example.com" 
     22    body[:recipient] = recipient 
     23    body       render_message("signed_up") 
     24  end 
     25   
     26  def file_template_without_body_hash(recipient) 
     27    recipients recipient 
     28    subject    "using helpers" 
     29    from       "tester@example.com" 
     30    body       render_message("signed_up") 
     31  end 
    1732 
    1833  def rxml_template(recipient) 
    1934    recipients recipient 
     
    7893    mail = RenderMailer.create_file_template(@recipient) 
    7994    assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip 
    8095  end 
     96   
     97  def test_file_template_with_implicit_body_hash 
     98    mail = RenderMailer.create_file_template_with_implicit_body_hash(@recipient) 
     99    assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip 
     100  end 
     101   
     102  def test_file_template_without_body_hash 
     103    mail = RenderMailer.create_file_template_without_body_hash(@recipient) 
     104    assert_equal "Hello there, \n\nMr.", mail.body.strip 
     105  end 
    81106 
    82107  def test_rxml_template 
    83108    mail = RenderMailer.deliver_rxml_template(@recipient) 
  • rails/actionmailer/lib/action_mailer/base.rb

    old new  
    502502        @mime_version = @@default_mime_version.dup if @@default_mime_version 
    503503      end 
    504504 
    505       def render_message(method_name, body
     505      def render_message(method_name, body = @body
    506506        render :file => method_name, :body => body 
    507507      end 
    508508