Sha256: b5317ebb1ccfdb52c7292ec7ba03c3c9464486cb9f748cc45b15f5658cd5fa72

Contents?: true

Size: 1.34 KB

Versions: 21

Compression:

Stored size: 1.34 KB

Contents

require 'test_helper'

class HeadstartMailerTest < ActiveSupport::TestCase

  context "A change password email" do
    setup do
      @user  = Factory(:user)
      @user.forgot_password!
      HeadstartMailer.deliver_mimi_change_password @user
      @email = ActionMailer::Base.deliveries.last
    end

    should "be from DO_NOT_REPLY" do
      assert_equal Headstart.configuration.mailer_sender, @email.from
    end

    should "be sent to user" do
      assert_match /#{@user.email}/i, @email.recipients
    end

    should "contain a link to edit the user's password" do
      host = ActionMailer::Base.default_url_options[:host]
      regexp = %r{http://#{host}/users/#{@user.id}/password/edit\?token=#{@user.password_reset_token}}
      assert_match regexp, @email.body[:url]
    end
    
    should "set its subject" do
      assert_match /Change your password/, @email.subject
    end
  end
  
  context "A welcome email" do
    setup do
      @user  = Factory(:user)
      Delayed::Job.work_off
      @email = ActionMailer::Base.deliveries.last
    end

    should "be from DO_NOT_REPLY" do
      assert_equal Headstart.configuration.mailer_sender, @email.from
    end

    should "be sent to user" do
      assert_match /#{@user.email}/i, @email.recipients
    end

    should "set its subject" do
      assert_match /welcome/i, @email.subject
    end
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
headstart-0.11.2 test/models/headstart_mailer_test.rb
headstart-0.11.1 test/models/headstart_mailer_test.rb
headstart-0.9.2 test/models/headstart_mailer_test.rb
headstart-0.9.1 test/models/headstart_mailer_test.rb
headstart-0.9.0 test/models/headstart_mailer_test.rb
headstart-0.8.0 test/models/headstart_mailer_test.rb
headstart-0.7.0 test/models/headstart_mailer_test.rb
headstart-0.6.2 test/models/headstart_mailer_test.rb
headstart-0.6.1 test/models/headstart_mailer_test.rb
headstart-0.6.0 test/models/headstart_mailer_test.rb
headstart-0.5.5 test/models/headstart_mailer_test.rb
headstart-0.5.4 test/models/headstart_mailer_test.rb
headstart-0.5.3 test/models/headstart_mailer_test.rb
headstart-0.5.2 test/models/headstart_mailer_test.rb
headstart-0.5.1 test/models/headstart_mailer_test.rb
headstart-0.5.0 test/models/headstart_mailer_test.rb
headstart-0.4.2 test/models/headstart_mailer_test.rb
headstart-0.4.1 test/models/headstart_mailer_test.rb
headstart-0.4.0 test/models/headstart_mailer_test.rb
headstart-0.3.0 test/models/headstart_mailer_test.rb