Sha256: 2e92cf97de4f7c6c09c77dd4cf4a69a711bb29fda1820025cd36074684310b55

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 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
      MailEngine::Base.current_config["replacement_email"] = "xxx@xxx.com"
      mail = UserMailer.notify("x@x.com").deliver
      assert_equal mail.to, ["xxx@xxx.com"]
      assert UserMailer.sendgrid_config.to_hash["X-SMTPAPI"].include?("[\"xxx@xxx.com\"]")
    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

5 entries across 5 versions & 1 rubygems

Version Path
mail_engine-0.1.12 test/functional/user_mailer_test.rb
mail_engine-0.1.11 test/functional/user_mailer_test.rb
mail_engine-0.1.10 test/functional/user_mailer_test.rb
mail_engine-0.1.9 test/functional/user_mailer_test.rb
mail_engine-0.1.8 test/functional/user_mailer_test.rb