class HelperMailer

Public Instance Methods

use_block_format() click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 47
  def use_block_format
    @text = <<-TEXT
This is the
first     paragraph.

The second
   paragraph.

* item1 * item2
  * item3
    TEXT

    mail_with_defaults do |format|
      format.html { render(inline: "<%= block_format @text %>") }
    end
  end
use_cache() click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 64
def use_cache
  mail_with_defaults do |format|
    format.html { render(inline: "<% cache(:foo) do %>Greetings from a cache helper block<% end %>") }
  end
end
use_format_paragraph() click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 19
def use_format_paragraph
  @text = "But soft! What light through yonder window breaks?"

  mail_with_defaults do |format|
    format.html { render(inline: "<%= format_paragraph @text, 15, 1 %>") }
  end
end
use_format_paragraph_with_long_first_word() click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 27
def use_format_paragraph_with_long_first_word
  @text = "Antidisestablishmentarianism is very long."

  mail_with_defaults do |format|
    format.html { render(inline: "<%= format_paragraph @text, 10, 1 %>") }
  end
end
use_mail_helper() click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 6
def use_mail_helper
  @text = "But soft! What light through yonder window breaks? It is the east, " \
          "and Juliet is the sun. Arise, fair sun, and kill the envious moon, " \
          "which is sick and pale with grief that thou, her maid, art far more " \
          "fair than she. Be not her maid, for she is envious! Her vestal " \
          "livery is but sick and green, and none but fools do wear it. Cast " \
          "it off!"

  mail_with_defaults do |format|
    format.html { render(inline: "<%= block_format @text %>") }
  end
end
use_mailer() click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 35
def use_mailer
  mail_with_defaults do |format|
    format.html { render(inline: "<%= mailer.message.subject %>") }
  end
end
use_message() click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 41
def use_message
  mail_with_defaults do |format|
    format.html { render(inline: "<%= message.subject %>") }
  end
end

Private Instance Methods

mail_with_defaults(&block) click to toggle source
# File actionmailer/test/mail_helper_test.rb, line 72
def mail_with_defaults(&block)
  mail(to: "test@localhost", from: "tester@example.com",
        subject: "using helpers", &block)
end