Sha256: ff81f4fdbaa63eab431ab3f44ddc0580fbaa7bebfba1fd3070fd7d8adb175df2

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

class UserMailerTest < ActionController::TestCase
  context "UserMailer" do
    should "has sendgrid header" do
      assert UserMailer.sendgrid_config.to_hash["X-SMTPAPI"].present?
    end

    should "send to safe mail address" do
      replacement_email = "xxx@xxx.com"
      MailSafe::Config.internal_address_definition = /#{replacement_email}/
      MailSafe::Config.replacement_address = replacement_email

      UserMailer.notify("x@x.com").deliver
      assert UserMailer.sendgrid_config.to_hash["X-SMTPAPI"].include?("[\"#{replacement_email}\"]")
    end

    should "only send mail to the receiver" do
      UserMailer.notify("x@x.com").deliver
      assert UserMailer.sendgrid_config.to_hash["X-SMTPAPI"].include?("[\"x@x.com\"]")

      UserMailer.notify("y@y.com").deliver
      assert UserMailer.sendgrid_config.to_hash["X-SMTPAPI"].include?("[\"y@y.com\"]")
    end

    should "override subject by db tempate.subject" do
      @template = FactoryGirl.build(:system_mail_template_with_footer, :format => "html")
      assert_equal "subject in mailer", UserMailer.notify("x@x.com").subject
      @template.save
      assert_equal @template.subject, UserMailer.notify("x@x.com").subject
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mail_engine-0.1.6 test/functional/user_mailer_test.rb
mail_engine-0.1.5 test/functional/user_mailer_test.rb