Permalink
Browse files

Merge pull request #2 from rafaelfranca/master

I started to make the Action Mailer related tests pass
  • Loading branch information...
steveklabnik committed Sep 20, 2012
2 parents 5be3306 + a882736 commit 899cc6be90c4b99007858dd3f1ef5e3ce12f811c
View
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in active_record-observers.gemspec
gemspec
-gem 'active_record_deprecated_finders', git: 'git://github.com/rails/active_record_deprecated_finders'
+gem 'activerecord-deprecated_finders', git: 'git://github.com/rails/activerecord-deprecated_finders'
gem 'journey', git: 'https://github.com/rails/journey.git'
if ENV['RAILS']
@@ -16,6 +16,8 @@ Gem::Specification.new do |gem|
gem.version = ActiveRecord::Observers::VERSION
gem.add_development_dependency 'minitest', '>= 3'
+ gem.add_development_dependency 'mocha'
gem.add_development_dependency 'activerecord', '~> 4.0.0.beta'
+ gem.add_development_dependency 'actionmailer', '~> 4.0.0.beta'
gem.add_development_dependency 'sqlite3', '~> 1.3'
end
@@ -1,3 +1,46 @@
+require 'minitest/autorun'
+require 'action_mailer'
+
+FIXTURE_LOAD_PATH = File.expand_path('fixtures', File.dirname(__FILE__))
+ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH
+
+class MockSMTP
+ def self.deliveries
+ @@deliveries
+ end
+
+ def initialize
+ @@deliveries = []
+ end
+
+ def sendmail(mail, from, to)
+ @@deliveries << [mail, from, to]
+ end
+
+ def start(*args)
+ yield self
+ end
+end
+
+class Net::SMTP
+ def self.new(*args)
+ MockSMTP.new
+ end
+end
+
+class BaseMailer < ActionMailer::Base
+ self.mailer_name = "base_mailer"
+
+ default :to => 'system@test.lindsaar.net',
+ :from => 'jose@test.plataformatec.com',
+ :reply_to => 'mikel@test.lindsaar.net'
+
+ def welcome(hash = {})
+ headers['X-SPAM'] = "Not SPAM"
+ mail({:subject => "The first email on new API!"}.merge!(hash))
+ end
+end
+
class BaseTest < ActiveSupport::TestCase
class MyObserver
def self.delivered_email(mail)

0 comments on commit 899cc6b

Please sign in to comment.