Sha256: 5034b02be042721d4500aaed8202124dfb7438e872ef15c7d451352894898803

Contents?: true

Size: 1.67 KB

Versions: 7

Compression:

Stored size: 1.67 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'
require 'user_mailer'

class InviteMailerTest < ActiveSupport::TestCase

  context "deliver emails" do

    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" => 'utf-8' }
    end

    should "send invite notification email" do
      user = Factory(:user)
      contact_email = Factory.next(:email)
      response = InviteMailer.deliver_invite_notification(user, contact_email)
      assert !ActionMailer::Base.deliveries.empty?, "No email was sent"
      assert_match "#{user.full_name}", response.body, "User's name was not found in the email"
      assert_match "/#{user.id}", response.body, "A link to the inviter's profile was not found in the email"
      email = ActionMailer::Base.deliveries.last
      assert_equal email.to, [contact_email]
      assert_equal email.from, [GlobalConfig.from_email]
    end

    should "send invited joined notification email" do
      user = Factory(:user)
      inviter = Factory(:user)
      response = InviteMailer.deliver_invited_joined_notification(user, inviter)
      assert !ActionMailer::Base.deliveries.empty?, "No email was sent"
      assert_match "#{user.full_name}", response.body, "Inviter's name was not found in the email"
      assert_match "/#{inviter.id}", response.body, "A link to the new user's profile was not found in the email"
      email = ActionMailer::Base.deliveries.last
      assert_equal email.to, [inviter.email]
      assert_equal email.from, [GlobalConfig.from_email]
    end

  end  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
muck-invites-0.1.7 test/rails_root/test/unit/invite_mailer_test.rb
muck-invites-0.1.6 test/rails_root/test/unit/invite_mailer_test.rb
muck-invites-0.1.5 test/rails_root/test/unit/invite_mailer_test.rb
muck-invites-0.1.4 test/rails_root/test/unit/invite_mailer_test.rb
muck-invites-0.1.3 test/rails_root/test/unit/invite_mailer_test.rb
muck-invites-0.1.2 test/rails_root/test/unit/invite_mailer_test.rb
muck-invites-0.1.1 test/rails_root/test/unit/invite_mailer_test.rb