resque_mailer 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,7 +1,10 @@
1
1
  = ResqueMailer
2
2
 
3
- A gem plugin which allows messages prepared by ActionMailer to be delivered asynchronously.
4
- Assumes that you're using Resque (http://github.com/defunkt/resque) for your background jobs.
3
+ A gem plugin which allows messages prepared by ActionMailer to be delivered
4
+ asynchronously. Assumes you're using Resque (http://github.com/defunkt/resque)
5
+ for your background jobs.
6
+
7
+ Works in both Rails 2.x and Rails 3.x.
5
8
 
6
9
  == Usage
7
10
 
@@ -11,35 +14,50 @@ Include Resque::Mailer in your ActionMailer subclass(es) like this:
11
14
  include Resque::Mailer
12
15
  end
13
16
 
14
- Or if you want to always use asynchronous delivery by default, create an initializer in your
15
- Rails project or piggyback on your load_resque.rb initializer:
17
+ Now, when <tt>MyMailer.deliver_subject_email</tt> is called, an entry will be
18
+ created in the job queue. Your Resque workers will be able to deliver this
19
+ message for you. The queue we're using is imaginatively named +mailer+, so
20
+ just make sure your workers know about it and are loading your environment:
16
21
 
17
- class ActionMailer::Base
18
- include Resque::Mailer
19
- end
22
+ QUEUE=mailer rake environment resque:work
20
23
 
21
- Now, when MyMailer.deliver_subject_email is called, an entry will be created in the job queue.
22
- Your Resque workers will be able to deliver this for you; the queue we're using is imaginatively
23
- named +mailer+. Just make sure your workers know about it and are loading your environment:
24
+ Note that you can still have mail delivered synchronously by using the bang
25
+ method variant:
24
26
 
25
- QUEUE=mailer rake environment resque:work
27
+ MyMailer.deliver_subject_email!
26
28
 
27
- Note that you can still have mail delivered synchronously by using the bang method variant:
28
- MyMailer.deliver_subject_email!
29
+ Oh, by the way. Don't forget that your async mailer jobs will be processed by
30
+ a separate worker. This means that you should resist the temptation to pass
31
+ database-backed objects as parameters in your mailer and instead pass record
32
+ identifiers. Then, in your delivery method, you can look up the record from
33
+ the id and use it as needed.
34
+
35
+ == Rails 3 Support
36
+
37
+ Rails 3 has made some changes to the ActionMailer interface. Instead of
38
+ calling <tt>MyMailer.deliver_subject_email(params)</tt>, you'll want to call
39
+ <tt>MyMailer.subject_email(params).deliver</tt>.
40
+
41
+ You still need to include <tt>Resque::Mailer</tt> in your mailer as described
42
+ above. Everything else should work as expected.
29
43
 
30
44
  == Installation
31
45
 
32
- Install it as a plugin or as a gem plugin.
46
+ Install it as a plugin or as a gem plugin from Gemcutter:
33
47
 
48
+ gem install resque_mailer
34
49
  script/plugin install git://github.com/zapnap/resque_mailer.git
35
50
 
36
- # config/environment.rb
51
+ # Rails 2: edit config/environment.rb
37
52
  config.gem 'resque_mailer'
38
53
 
54
+ # Rails 3: add it to your Gemfile
55
+ gem 'resque_mailer'
56
+
39
57
  == Testing
40
58
 
41
- You don't want to be sending actual emails in the test environment, so you can configure the
42
- environments that should be excluded like so:
59
+ You don't want to be sending actual emails in the test environment, so you can
60
+ configure the environments that should be excluded like so:
43
61
 
44
62
  # config/initializers/resque_mailer.rb
45
63
  Resque::Mailer.excluded_environments = [:test, :cucumber]
@@ -55,5 +73,6 @@ environments that should be excluded like so:
55
73
 
56
74
  == Credits
57
75
 
58
- This work is essentially a forked version of delayed_job_mailer (http://github.com/andersondias/delayed_job_mailer) by Anderson Dias
59
- (which in turn was inspired by Alexander Lang's workling_mailer). Enhanced and modified to work with Resque by Nick Plante.
76
+ This work is essentially a forked version of delayed_job_mailer
77
+ (http://github.com/andersondias/delayed_job_mailer) by Anderson Dias. Enhanced
78
+ and modified to work with Resque by Nick Plante.
data/Rakefile CHANGED
@@ -9,10 +9,10 @@ begin
9
9
  gem.description = %Q{Rails plugin for sending asynchronous email with ActionMailer and Resque}
10
10
  gem.email = "nap@zerosum.org"
11
11
  gem.homepage = "http://github.com/zapnap/resque_mailer"
12
- gem.authors = ["Nick Plante"]
12
+ gem.authors = ["Nick Plante", "Marcin Kulik"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  gem.add_development_dependency "resque", ">= 1.2.3"
15
- gem.add_development_dependency "actionmailer", ">= 2.2.2"
15
+ gem.add_development_dependency "actionmailer", ">= 2.3.4"
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
@@ -20,19 +20,32 @@ rescue LoadError
20
20
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
21
  end
22
22
 
23
- require 'spec/rake/spectask'
24
- Spec::Rake::SpecTask.new(:spec) do |spec|
25
- spec.libs << 'lib' << 'spec'
26
- spec.spec_files = FileList['spec/**/*_spec.rb']
27
- end
23
+ begin
24
+ require 'spec/rake/spectask'
25
+
26
+ puts "Using RSpec 1.x / Rails 2.x"
28
27
 
29
- Spec::Rake::SpecTask.new(:rcov) do |spec|
30
- spec.libs << 'lib' << 'spec'
31
- spec.pattern = 'spec/**/*_spec.rb'
32
- spec.rcov = true
28
+ desc "Run specs for Rails 2.x"
29
+ Spec::Rake::SpecTask.new(:spec) do |spec|
30
+ spec.spec_files = FileList['spec/common_spec.rb', 'spec/rails2_spec.rb']
31
+ end
32
+ rescue LoadError
33
+ puts "RSpec 1.x unavailable"
33
34
  end
34
35
 
35
- task :spec => :check_dependencies
36
+ begin
37
+ require 'rspec/core'
38
+ require 'rspec/core/rake_task'
39
+
40
+ puts "Using RSpec 2.x / Rails 3.x"
41
+
42
+ desc "Run specs for Rails 3.x"
43
+ RSpec::Core::RakeTask.new(:spec) do |spec|
44
+ spec.pattern = ["spec/common_spec.rb","spec/rails3_spec.rb"]
45
+ end
46
+ rescue LoadError
47
+ puts "RSpec 2.x unavailable"
48
+ end
36
49
 
37
50
  task :default => :spec
38
51
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 1.0.0
data/lib/resque_mailer.rb CHANGED
@@ -1,41 +1,7 @@
1
- module Resque
2
- module Mailer
3
-
4
- def self.included(base)
5
- base.extend(ClassMethods)
6
- end
1
+ require "resque_mailer/common"
7
2
 
8
- module ClassMethods
9
- def method_missing(method_symbol, *params)
10
-
11
- if ::Resque::Mailer.excluded_environments &&
12
- ::Resque::Mailer.excluded_environments.include?(::RAILS_ENV.to_sym)
13
- return super(method_symbol, *params)
14
- end
15
-
16
- case method_symbol.id2name
17
- when /^deliver_([_a-z]\w*)\!/ then super(method_symbol, *params)
18
- when /^deliver_([_a-z]\w*)/ then ::Resque.enqueue(self, "#{method_symbol}!", *params)
19
- else super(method_symbol, *params)
20
- end
21
- end
22
-
23
- def queue
24
- :mailer
25
- end
26
-
27
- def perform(cmd, *args)
28
- send(cmd, *args)
29
- end
30
- end
31
-
32
- def self.excluded_environments=(*environments)
33
- @@excluded_environments = environments && environments.flatten.collect! { |env| env.to_sym }
34
- end
35
-
36
- def self.excluded_environments
37
- @@excluded_environments ||= []
38
- end
39
-
40
- end
3
+ if defined?(Rails.version) && Rails.version.to_i >= 3
4
+ require "resque_mailer/rails3"
5
+ else
6
+ require "resque_mailer/rails2"
41
7
  end
@@ -0,0 +1,34 @@
1
+ module Resque
2
+ module Mailer
3
+
4
+ class << self
5
+ attr_accessor :default_queue_name
6
+ attr_reader :excluded_environments
7
+
8
+ def excluded_environments=(envs)
9
+ @excluded_environments = [*envs].map { |e| e.to_sym }
10
+ end
11
+
12
+ def included(base)
13
+ base.extend(ClassMethods)
14
+ end
15
+ end
16
+
17
+ self.default_queue_name = "mailer"
18
+ self.excluded_environments = [:test]
19
+
20
+ module ClassMethods
21
+ def environment_excluded?
22
+ excluded_environment?(current_env)
23
+ end
24
+
25
+ def queue
26
+ ::Resque::Mailer.default_queue_name
27
+ end
28
+
29
+ def excluded_environment?(name)
30
+ ::Resque::Mailer.excluded_environments && ::Resque::Mailer.excluded_environments.include?(name.to_sym)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ module Resque
2
+ module Mailer
3
+ module ClassMethods
4
+
5
+ def current_env
6
+ RAILS_ENV
7
+ end
8
+
9
+ def method_missing(method_name, *args)
10
+ return super if environment_excluded?
11
+
12
+ case method_name.id2name
13
+ when /^deliver_([_a-z]\w*)\!/ then super(method_name, *args)
14
+ when /^deliver_([_a-z]\w*)/ then ::Resque.enqueue(self, "#{method_name}!", *args)
15
+ else super(method_name, *args)
16
+ end
17
+ end
18
+
19
+ def perform(cmd, *args)
20
+ send(cmd, *args)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,42 @@
1
+ module Resque
2
+ module Mailer
3
+
4
+ class Rails3MailerProxy
5
+ def initialize(mailer_class, action, *args)
6
+ @mailer_class = mailer_class
7
+ @action = action
8
+ @args = args
9
+ end
10
+
11
+ def deliver
12
+ ::Resque.enqueue(@mailer_class, @action, *@args)
13
+ end
14
+
15
+ def deliver!
16
+ @mailer_class.send(:new, @action, *@args).message.deliver
17
+ end
18
+ end
19
+
20
+ module ClassMethods
21
+
22
+ def current_env
23
+ ::Rails.env
24
+ end
25
+
26
+ def method_missing(method_name, *args)
27
+ return super if environment_excluded?
28
+
29
+ if action_methods.include?(method_name.to_s)
30
+ Rails3MailerProxy.new(self, method_name, *args)
31
+ else
32
+ super
33
+ end
34
+ end
35
+
36
+ def perform(action, *args)
37
+ Rails3MailerProxy.new(self, action, *args).deliver!
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ class CommonMailer
4
+ include Resque::Mailer
5
+ end
6
+
7
+ describe Resque::Mailer do
8
+ describe ".queue" do
9
+ context "when not changed" do
10
+ it "should return 'mailer'" do
11
+ CommonMailer.queue.should == "mailer"
12
+ end
13
+ end
14
+
15
+ context "when changed" do
16
+ before do
17
+ @my_default_queue = "foobar"
18
+ Resque::Mailer.should_receive(:default_queue_name).and_return(@my_default_queue)
19
+ end
20
+
21
+ it "should return proper queue name" do
22
+ CommonMailer.queue.should == @my_default_queue
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,71 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ gem 'actionmailer', '~>2.3.4'
4
+ require 'action_mailer'
5
+ require 'resque_mailer/rails2'
6
+
7
+ ActionMailer::Base.delivery_method = :test
8
+
9
+ class Rails2Mailer < ActionMailer::Base
10
+ include Resque::Mailer
11
+ MAIL_PARAMS = { :to => "misio@example.org" }
12
+
13
+ def test_mail(opts={})
14
+ @subject = 'subject'
15
+ @body = 'mail body'
16
+ @recipients = opts[:to]
17
+ @from = 'from@example.org'
18
+ @sent_on = Time.now
19
+ @headers = {}
20
+ end
21
+ end
22
+
23
+ describe Rails2Mailer do
24
+ before do
25
+ Rails2Mailer.stub(:current_env => :test)
26
+ end
27
+
28
+ describe '#deliver' do
29
+ before(:all) do
30
+ @delivery = lambda {
31
+ Rails2Mailer.deliver_test_mail(Rails2Mailer::MAIL_PARAMS)
32
+ }
33
+ end
34
+
35
+ before(:each) do
36
+ Resque.stub(:enqueue)
37
+ end
38
+
39
+ it 'should not deliver the email synchronously' do
40
+ lambda { @delivery.call }.should_not change(ActionMailer::Base.deliveries, :size)
41
+ end
42
+
43
+ it 'should place the deliver action on the Resque "mailer" queue' do
44
+ Resque.should_receive(:enqueue).with(Rails2Mailer, "deliver_test_mail!", Rails2Mailer::MAIL_PARAMS)
45
+ @delivery.call
46
+ end
47
+
48
+ context "when current env is excluded" do
49
+ it 'should not deliver through Resque for excluded environments' do
50
+ Resque::Mailer.stub(:excluded_environments => [:custom])
51
+ Rails2Mailer.should_receive(:current_env).and_return(:custom)
52
+ Resque.should_not_receive(:enqueue)
53
+ @delivery.call
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '#deliver!' do
59
+ it 'should deliver the email synchronously' do
60
+ lambda { Rails2Mailer.deliver_test_mail!(Rails2Mailer::MAIL_PARAMS) }.should change(ActionMailer::Base.deliveries, :size).by(1)
61
+ end
62
+ end
63
+
64
+ describe ".perform" do
65
+ it 'should perform a queued mailer job' do
66
+ lambda {
67
+ Rails2Mailer.perform("deliver_test_mail!", Rails2Mailer::MAIL_PARAMS)
68
+ }.should change(ActionMailer::Base.deliveries, :size).by(1)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,67 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
2
+
3
+ gem 'actionmailer', '>=3.0.0.beta4'
4
+ require 'action_mailer'
5
+ require 'resque_mailer/rails3'
6
+
7
+ ActionMailer::Base.delivery_method = :test
8
+
9
+ class Rails3Mailer < ActionMailer::Base
10
+ include Resque::Mailer
11
+ default :from => "from@example.org", :subject => "Subject"
12
+ MAIL_PARAMS = { :to => "misio@example.org" }
13
+
14
+ def test_mail(*params)
15
+ mail(*params)
16
+ end
17
+ end
18
+
19
+ describe Rails3Mailer do
20
+ before do
21
+ Rails3Mailer.stub(:current_env => :test)
22
+ end
23
+
24
+ describe '#deliver' do
25
+ before(:all) do
26
+ @delivery = lambda {
27
+ Rails3Mailer.test_mail(Rails3Mailer::MAIL_PARAMS).deliver
28
+ }
29
+ end
30
+
31
+ before(:each) do
32
+ Resque.stub(:enqueue)
33
+ end
34
+
35
+ it 'should not deliver the email synchronously' do
36
+ lambda { @delivery.call }.should_not change(ActionMailer::Base.deliveries, :size)
37
+ end
38
+
39
+ it 'should place the deliver action on the Resque "mailer" queue' do
40
+ Resque.should_receive(:enqueue).with(Rails3Mailer, :test_mail, Rails3Mailer::MAIL_PARAMS)
41
+ @delivery.call
42
+ end
43
+
44
+ context "when current env is excluded" do
45
+ it 'should not deliver through Resque for excluded environments' do
46
+ Resque::Mailer.stub(:excluded_environments => [:custom])
47
+ Rails3Mailer.should_receive(:current_env).and_return(:custom)
48
+ Resque.should_not_receive(:enqueue)
49
+ @delivery.call
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '#deliver!' do
55
+ it 'should deliver the email synchronously' do
56
+ lambda { Rails3Mailer.test_mail(Rails3Mailer::MAIL_PARAMS).deliver! }.should change(ActionMailer::Base.deliveries, :size).by(1)
57
+ end
58
+ end
59
+
60
+ describe ".perform" do
61
+ it 'should perform a queued mailer job' do
62
+ lambda {
63
+ Rails3Mailer.perform(:test_mail, Rails3Mailer::MAIL_PARAMS)
64
+ }.should change(ActionMailer::Base.deliveries, :size).by(1)
65
+ end
66
+ end
67
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'resque_mailer'
4
- require 'spec'
5
- require 'spec/autorun'
6
3
 
7
- Spec::Runner.configure do |config|
8
-
4
+ require 'resque_mailer/common'
5
+
6
+ begin
7
+ require 'rspec/autorun'
8
+ rescue LoadError
9
+ require 'spec/autorun'
9
10
  end
11
+
12
+ Resque::Mailer.excluded_environments = []
metadata CHANGED
@@ -1,47 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Nick Plante
14
+ - Marcin Kulik
8
15
  autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2010-01-08 00:00:00 -05:00
19
+ date: 2010-07-28 00:00:00 -04:00
13
20
  default_executable:
14
21
  dependencies:
15
22
  - !ruby/object:Gem::Dependency
16
23
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
20
27
  requirements:
21
28
  - - ">="
22
29
  - !ruby/object:Gem::Version
30
+ hash: 13
31
+ segments:
32
+ - 1
33
+ - 2
34
+ - 9
23
35
  version: 1.2.9
24
- version:
36
+ type: :development
37
+ version_requirements: *id001
25
38
  - !ruby/object:Gem::Dependency
26
39
  name: resque
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
30
43
  requirements:
31
44
  - - ">="
32
45
  - !ruby/object:Gem::Version
46
+ hash: 25
47
+ segments:
48
+ - 1
49
+ - 2
50
+ - 3
33
51
  version: 1.2.3
34
- version:
52
+ type: :development
53
+ version_requirements: *id002
35
54
  - !ruby/object:Gem::Dependency
36
55
  name: actionmailer
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
40
59
  requirements:
41
60
  - - ">="
42
61
  - !ruby/object:Gem::Version
43
- version: 2.2.2
44
- version:
62
+ hash: 11
63
+ segments:
64
+ - 2
65
+ - 3
66
+ - 4
67
+ version: 2.3.4
68
+ type: :development
69
+ version_requirements: *id003
45
70
  description: Rails plugin for sending asynchronous email with ActionMailer and Resque
46
71
  email: nap@zerosum.org
47
72
  executables: []
@@ -59,8 +84,13 @@ files:
59
84
  - Rakefile
60
85
  - VERSION
61
86
  - lib/resque_mailer.rb
87
+ - lib/resque_mailer/common.rb
88
+ - lib/resque_mailer/rails2.rb
89
+ - lib/resque_mailer/rails3.rb
62
90
  - rails/init.rb
63
- - spec/resque_mailer_spec.rb
91
+ - spec/common_spec.rb
92
+ - spec/rails2_spec.rb
93
+ - spec/rails3_spec.rb
64
94
  - spec/spec.opts
65
95
  - spec/spec_helper.rb
66
96
  has_rdoc: true
@@ -73,24 +103,32 @@ rdoc_options:
73
103
  require_paths:
74
104
  - lib
75
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
76
107
  requirements:
77
108
  - - ">="
78
109
  - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
79
113
  version: "0"
80
- version:
81
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
82
116
  requirements:
83
117
  - - ">="
84
118
  - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
85
122
  version: "0"
86
- version:
87
123
  requirements: []
88
124
 
89
125
  rubyforge_project:
90
- rubygems_version: 1.3.5
126
+ rubygems_version: 1.3.7
91
127
  signing_key:
92
128
  specification_version: 3
93
129
  summary: Rails plugin for sending asynchronous email with ActionMailer and Resque
94
130
  test_files:
95
- - spec/resque_mailer_spec.rb
131
+ - spec/common_spec.rb
132
+ - spec/rails2_spec.rb
133
+ - spec/rails3_spec.rb
96
134
  - spec/spec_helper.rb
@@ -1,76 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- require 'rubygems'
4
- gem 'actionmailer', '>= 2.2.2'
5
- require 'action_mailer'
6
-
7
- ActionMailer::Base.delivery_method = :test
8
-
9
- class AsynchTestMailer < ActionMailer::Base
10
- include Resque::Mailer
11
-
12
- def test_mail(from, to)
13
- @subject = 'subject'
14
- @body = 'mail body'
15
- @recipients = to
16
- @from = from
17
- @sent_on = Time.now
18
- @headers = {}
19
- end
20
- end
21
-
22
- describe AsynchTestMailer do
23
- before do
24
- Object.const_set 'RAILS_ENV', 'test' unless defined?(::RAILS_ENV)
25
- end
26
-
27
- describe 'deliver_test_mail' do
28
- before(:each) do
29
- @emails = ActionMailer::Base.deliveries
30
- @emails.clear
31
- @params = 'info@mogoterra.com', 'test@test.net'
32
- Resque.stub(:enqueue)
33
- end
34
-
35
- it 'should not deliver the email synchronously' do
36
- AsynchTestMailer.deliver_test_mail *@params
37
- @emails.size.should == 0
38
- end
39
-
40
- it 'should place the deliver action one the Resque mailer queue' do
41
- Resque.should_receive(:enqueue).with(AsynchTestMailer, 'deliver_test_mail!', *@params)
42
- AsynchTestMailer.deliver_test_mail *@params
43
- end
44
-
45
- it 'should not send deliver action to queue for environments where asychronous delivery is disabled' do
46
- excluded_environments = [:cucumber, :foo, 'bar']
47
- ::Resque::Mailer.excluded_environments = excluded_environments
48
-
49
- excluded_environments.each do |env|
50
- Object.send :remove_const, 'RAILS_ENV'
51
- Object.const_set 'RAILS_ENV', env.to_s
52
-
53
- Resque.should_not_receive(:enqueue)
54
- AsynchTestMailer.deliver_test_mail *@params
55
- end
56
- end
57
- end
58
-
59
- describe 'deliver_test_mail!' do
60
- it 'should deliver the mail' do
61
- emails = ActionMailer::Base.deliveries
62
- emails.clear
63
- AsynchTestMailer.deliver_test_mail! 'info@mogoterra.com', 'test@test.net'
64
- emails.size.should == 1
65
- end
66
- end
67
-
68
- it 'should have a queue' do
69
- AsynchTestMailer.queue.should == :mailer
70
- end
71
-
72
- it 'should perform a queued mailer job' do
73
- AsynchTestMailer.should_receive("deliver_test_mail!").with(1, { :foo => 'bar' })
74
- AsynchTestMailer.perform("deliver_test_mail!", 1, { :foo => 'bar' })
75
- end
76
- end