Sha256: de66391a0913c94062fc3aa39af4aac3a6629d0ef256706e33bbc4bcdace2079

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

$:.unshift(File.dirname(__FILE__) + "/../lib/")

require 'test/unit'
require 'action_mailer'

class RenderMailer < ActionMailer::Base
  def inline_template(recipient)
    recipients recipient
    subject    "using helpers"
    from       "tester@example.com"
    body       render(:inline => "Hello, <%= @world %>", :body => { :world => "Earth" })
  end

  def file_template(recipient)
    recipients recipient
    subject    "using helpers"
    from       "tester@example.com"
    body       render(:file => "signed_up", :body => { :recipient => recipient })
  end

  def initialize_defaults(method_name)
    super
    mailer_name "test_mailer"
  end
end

RenderMailer.template_root = File.dirname(__FILE__) + "/fixtures"

class RenderHelperTest < Test::Unit::TestCase
  def setup
    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries = []

    @recipient = 'test@localhost'
  end

  def test_inline_template
    mail = RenderMailer.create_inline_template(@recipient)
    assert_equal "Hello, Earth", mail.body.strip
  end

  def test_file_template
    mail = RenderMailer.create_file_template(@recipient)
    assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
actionmailer-1.1.4 test/mail_render_test.rb
actionmailer-1.2.0 test/mail_render_test.rb
actionmailer-1.2.4 test/mail_render_test.rb
actionmailer-1.1.1 test/mail_render_test.rb
actionmailer-1.1.2 test/mail_render_test.rb
actionmailer-1.1.3 test/mail_render_test.rb
actionmailer-1.1.5 test/mail_render_test.rb
actionmailer-1.2.1 test/mail_render_test.rb
actionmailer-1.2.2 test/mail_render_test.rb
actionmailer-1.2.3 test/mail_render_test.rb
actionmailer-1.2.5 test/mail_render_test.rb