mail_view

Visual email testing

  • 所有者: basecamp/mail_view
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

MailView -- Visual email testing

Preview plain text and html mail templates in your browser without redelivering it every time you make a change.

Rails 4.1

NOTE: MailView is part of Rails 4.1+. No need for the plugin anymore!

Install

Add the gem to your Gemfile:

  gem 'mail_view', :git => 'https://github.com/basecamp/mail_view.git'
  # or
  gem "mail_view", "~> 2.0.4"

And run bundle install.

Usage

Since most emails do something interesting with database data, you'll need to write some scenarios to load messages with fake data. Its similar to writing mailer unit tests but you see a visual representation of the output instead.

  # app/mailers/mail_preview.rb or lib/mail_preview.rb
  class MailPreview < MailView
    # Pull data from existing fixtures
    def invitation
      account = Account.first
      inviter, invitee = account.users[0, 2]
      Notifier.invitation(inviter, invitee) 
    end

    # Factory-like pattern
    def welcome
      user = User.create!
      mail = Notifier.welcome(user)
      user.destroy
      mail
    end

    # Stub-like
    def forgot_password
      user = Struct.new(:email, :name).new('name@example.com', 'Jill Smith')
      mail = UserMailer.forgot_password(user)
    end
  end

Methods must return a Mail or TMail object. Using ActionMailer, call Notifier.create_action_name(args) to return a compatible TMail object. Now on ActionMailer 3.x, Notifier.action_name(args) will return a Mail object.

Routing

A mini router middleware is bundled for Rails 2.x support.

  # config/environments/development.rb
  config.middleware.use MailView::Mapper, [MailPreview]

For Rails³ you can map the app inline in your routes config.

  # config/routes.rb
  if Rails.env.development?
    mount MailPreview => 'mail_view'
  end

Now just load up http://localhost:3000/mail_view.

Interface

Plain text view
HTML view

主要指標

概覽
名稱與所有者basecamp/mail_view
主編程語言Ruby
編程語言Ruby (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2010-04-21 04:39:59
推送於2018-02-08 08:07:12
最后一次提交2014-09-09 12:52:21
發布數0
用户参与
星數1.3k
關注者數26
派生數128
提交數74
已啟用問題?
問題數32
打開的問題數5
拉請求數24
打開的拉請求數6
關閉的拉請求數24
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?