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

Ticket #2926: support_shared_partials_in_actionmailer.diff

File support_shared_partials_in_actionmailer.diff, 1.9 kB (added by sublogical, 1 year ago)

Support for passing relative paths to partials like in 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(:file => "test_mailer/signed_up", :body => { :recipient => recipient }) 
    1616  end 
    1717 
     18  def message_render(recipient) 
     19    recipients recipient 
     20    subject    "using helpers" 
     21    from       "tester@example.com" 
     22    body       render_message("signed_up", { :recipient => recipient }) 
     23  end 
     24 
    1825  def initialize_defaults(method_name) 
    1926    super 
    2027    mailer_name "test_mailer" 
     
    5562    mail = RenderMailer.create_file_template(@recipient) 
    5663    assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip 
    5764  end 
     65 
     66  def test_file_template 
     67    mail = RenderMailer.create_message_render(@recipient) 
     68    assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip 
     69  end 
    5870end 
    5971 
    6072class FirstSecondHelperTest < Test::Unit::TestCase 
  • actionmailer/lib/action_mailer/base.rb

    old new  
    475475      end 
    476476 
    477477      def render_message(method_name, body) 
    478         render :file => method_name, :body => body 
     478        render :file => "#{mailer_name}/#{method_name}", :body => body 
    479479      end 
    480480 
    481481      def render(opts) 
     
    488488      end 
    489489 
    490490      def initialize_template_class(assigns) 
    491         ActionView::Base.new(template_path, assigns, self) 
     491        ActionView::Base.new(template_root, assigns, self) 
    492492      end 
    493493 
    494494      def sort_parts(parts, order = [])