Sha256: 5cb4988fa67026e84dd88ef8ba1d2a56a251636d402f2639d8a1e1a9dcd2b776

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

require 'test/unit'
require 'rubygems'
require 'active_support'
require 'action_mailer'
require 'action_mailer/ar_mailer'

##
# Pretend mailer

class Mailer < ActionMailer::Base
  self.delivery_method = :activerecord

  def mail
    @mail = Object.new
    def @mail.encoded() 'email' end
    def @mail.from() ['nobody@example.com'] end
    def @mail.destinations() %w[user1@example.com user2@example.com] end
  end

end

class TestARMailer < Test::Unit::TestCase

  def setup
    Mailer.email_class = Email

    Email.records.clear
    Mail.records.clear
  end

  def test_self_email_class_equals
    Mailer.email_class = Mail

    Mailer.deliver_mail

    assert_equal 2, Mail.records.length
  end

  def test_perform_delivery_activerecord
    Mailer.deliver_mail

    assert_equal 2, Email.records.length

    record = Email.records.first
    assert_equal 'email', record.mail
    assert_equal 'user1@example.com', record.to
    assert_equal 'nobody@example.com', record.from

    assert_equal 'user2@example.com', Email.records.last.to
  end

end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
adzap-ar_mailer-2.0.1 test/test_armailer.rb
adzap-ar_mailer-2.0.2 test/test_armailer.rb
adzap-ar_mailer-2.1.0 test/test_armailer.rb
adzap-ar_mailer-2.1.1 test/test_armailer.rb
dvdplm-ar_mailer-2.0.3 test/test_armailer.rb
dvdplm-ar_mailer-2.0.4 test/test_armailer.rb
dvdplm-ar_mailer-2.0.5 test/test_armailer.rb
dvdplm-ar_mailer-2.0.6 test/test_armailer.rb
dvdplm-ar_mailer-2.0.7 test/test_armailer.rb
dvdplm-ar_mailer-2.1 test/test_armailer.rb
matid-ar_mailer-2.0.2.1 test/test_armailer.rb