public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Search Repo:
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
mephisto / test / unit / user_mailer_test.rb
100644 38 lines (29 sloc) 1.008 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require File.dirname(__FILE__) + '/../test_helper'
require 'user_mailer'
 
class UserMailerTest < Test::Unit::TestCase
  include ActionController::UrlWriter
  fixtures :users
 
  FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
  CHARSET = "utf-8"
 
  include ActionMailer::Quoting
 
  def setup
    ActionMailer::Base.delivery_method = :test
    ActionMailer::Base.perform_deliveries = true
    ActionMailer::Base.deliveries = []
 
    @expected = TMail::Mail.new
    @expected.set_content_type "text", "plain", { "charset" => CHARSET }
  end
 
  def test_forgot_password
    user = users(:quentin)
    response = UserMailer.deliver_forgot_password(user)
    assert_equal user.email, response.to[0]
    assert_match /#{url_for :controller => 'account', :action => 'activate', :id => user.token}/, response.body
  end
 
  private
    def read_fixture(action)
      IO.readlines("#{FIXTURES_PATH}/user_notifier/#{action}")
    end
 
    def encode(subject)
      quoted_printable(subject, CHARSET)
    end
end