action_mailer_test_via_smtp 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile +10 -0
- data/README.rdoc +9 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/action_mailer_test_via_smtp.gemspec +10 -9
- data/lib/action_mailer_test_via_smtp.rb +19 -9
- data/test/action_mailer_test_via_smtp_test.rb +25 -0
- data/test/templates/notifier/multipart_email.text.html.erb +3 -0
- data/test/templates/notifier/multipart_email.text.plain.erb +3 -0
- data/test/templates/notifier/plain_text_email.erb +3 -0
- data/test/test_helper.rb +33 -0
- metadata +13 -20
- data/test/helper.rb +0 -10
- data/test/test_action_mailer_test_via_smtp.rb +0 -7
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/README.rdoc
CHANGED
@@ -19,6 +19,15 @@ and in you staging.rb (environment file) you can configure this mode
|
|
19
19
|
|
20
20
|
now every single mail will be sent to the test_recipient, prefixed with the original recipient.
|
21
21
|
|
22
|
+
Since 0.2.0 you can also test 'sendmail' and even 'test':
|
23
|
+
|
24
|
+
config.action_mailer.delivery_method = :test_via_sendmail
|
25
|
+
|
26
|
+
or
|
27
|
+
|
28
|
+
config.action_mailer.delivery_method = :test_via_test
|
29
|
+
|
30
|
+
I know, the gem name is not valid anymore.
|
22
31
|
|
23
32
|
== Note on Patches/Pull Requests
|
24
33
|
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
gem.email = "andi@galaxycats.com"
|
11
11
|
gem.homepage = "http://github.com/galaxycats/action_mailer_test_via_smtp"
|
12
12
|
gem.authors = ["Andi Bade"]
|
13
|
-
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
13
|
+
# gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
14
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
15
|
end
|
16
16
|
Jeweler::GemcutterTasks.new
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
require 'rake/testtask'
|
22
22
|
Rake::TestTask.new(:test) do |test|
|
23
23
|
test.libs << 'lib' << 'test'
|
24
|
-
test.pattern = 'test
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
25
|
test.verbose = true
|
26
26
|
end
|
27
27
|
|
@@ -29,7 +29,7 @@ begin
|
|
29
29
|
require 'rcov/rcovtask'
|
30
30
|
Rcov::RcovTask.new do |test|
|
31
31
|
test.libs << 'test'
|
32
|
-
test.pattern = 'test
|
32
|
+
test.pattern = 'test/**/*_test.rb'
|
33
33
|
test.verbose = true
|
34
34
|
end
|
35
35
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{action_mailer_test_via_smtp}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andi Bade"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-12}
|
13
13
|
s.description = %q{Set one test-reciepient which gets all mails from th app in for example a test/staging environment }
|
14
14
|
s.email = %q{andi@galaxycats.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,14 +19,18 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
"Gemfile",
|
22
23
|
"LICENSE",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
25
26
|
"VERSION",
|
26
27
|
"action_mailer_test_via_smtp.gemspec",
|
27
28
|
"lib/action_mailer_test_via_smtp.rb",
|
28
|
-
"test/
|
29
|
-
"test/
|
29
|
+
"test/action_mailer_test_via_smtp_test.rb",
|
30
|
+
"test/templates/notifier/multipart_email.text.html.erb",
|
31
|
+
"test/templates/notifier/multipart_email.text.plain.erb",
|
32
|
+
"test/templates/notifier/plain_text_email.erb",
|
33
|
+
"test/test_helper.rb"
|
30
34
|
]
|
31
35
|
s.homepage = %q{http://github.com/galaxycats/action_mailer_test_via_smtp}
|
32
36
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -34,8 +38,8 @@ Gem::Specification.new do |s|
|
|
34
38
|
s.rubygems_version = %q{1.3.6}
|
35
39
|
s.summary = %q{test mails via smtp with actionmailer}
|
36
40
|
s.test_files = [
|
37
|
-
"test/
|
38
|
-
"test/
|
41
|
+
"test/action_mailer_test_via_smtp_test.rb",
|
42
|
+
"test/test_helper.rb"
|
39
43
|
]
|
40
44
|
|
41
45
|
if s.respond_to? :specification_version then
|
@@ -43,12 +47,9 @@ Gem::Specification.new do |s|
|
|
43
47
|
s.specification_version = 3
|
44
48
|
|
45
49
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
47
50
|
else
|
48
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
49
51
|
end
|
50
52
|
else
|
51
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
@@ -3,20 +3,30 @@ module ActionMailer
|
|
3
3
|
@@test_recipient = false
|
4
4
|
cattr_accessor :test_recipient
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
------------------------------- Test-Mail (#{Rails.env}) -------------------------------
|
6
|
+
def generate_test_mail_header(mail)
|
7
|
+
%Q{------------------------------- Test-Mail (#{Rails.env}) -------------------------------
|
9
8
|
Original-Recipient: #{mail.to.join(", ")}
|
10
9
|
CC: #{mail.cc ? mail.cc.join(", ") : "no CC"}
|
11
10
|
BCC: #{mail.bcc ? mail.bcc.join(", ") : "no BCC"}
|
12
11
|
----------------------------------------------------------------------------------
|
13
|
-
|
14
|
-
}
|
15
|
-
mail.to = self.class.test_recipient
|
16
|
-
mail.cc = nil
|
17
|
-
mail.bcc = nil
|
18
|
-
perform_delivery_smtp(mail)
|
12
|
+
}
|
19
13
|
end
|
20
14
|
|
15
|
+
[:sendmail, :smtp, :test].each do |meth|
|
16
|
+
define_method "perform_delivery_test_via_#{meth}" do |mail|
|
17
|
+
if mail.multipart?
|
18
|
+
test_mail_header = generate_test_mail_header(mail)
|
19
|
+
mail.each_part do |part|
|
20
|
+
part.body = test_mail_header + part.body
|
21
|
+
end
|
22
|
+
else
|
23
|
+
mail.body = generate_test_mail_header(mail) + mail.body
|
24
|
+
end
|
25
|
+
mail.to = self.class.test_recipient
|
26
|
+
mail.cc = nil
|
27
|
+
mail.bcc = nil
|
28
|
+
send("perform_delivery_#{meth}", mail)
|
29
|
+
end
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ActionMailerTestViaSmtpTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "should add content to body" do
|
6
|
+
Notifier.deliveries = []
|
7
|
+
Rails.expects(:env).returns(:test)
|
8
|
+
assert Notifier.deliver_plain_text_email
|
9
|
+
assert_equal 1, Notifier.deliveries.size
|
10
|
+
assert_match /Original-Recipient: test@galaxycats.com/, Notifier.deliveries.first.body
|
11
|
+
end
|
12
|
+
|
13
|
+
test "should add content to every body of multipart email" do
|
14
|
+
Notifier.deliveries = []
|
15
|
+
Rails.expects(:env).returns(:test)
|
16
|
+
assert Notifier.deliver_multipart_email
|
17
|
+
assert_equal 1, Notifier.deliveries.size
|
18
|
+
mail = Notifier.deliveries.first
|
19
|
+
assert Notifier.deliveries.first.parts.size > 0
|
20
|
+
Notifier.deliveries.first.each_part do |part|
|
21
|
+
assert_match /Original-Recipient: test@galaxycats.com/, part.body
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
This is the HTML part of the multipart mail
|
2
|
+
|
3
|
+
HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code HTML Code
|
@@ -0,0 +1,3 @@
|
|
1
|
+
This is the PLAIN part of the multipart mail
|
2
|
+
|
3
|
+
Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text Plain Text
|
@@ -0,0 +1,3 @@
|
|
1
|
+
This is the plain-text E-Mail
|
2
|
+
|
3
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
$:.reject! { |e| e.include? 'TextMate' }
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
|
5
|
+
require "rubygems"
|
6
|
+
require "bundler"
|
7
|
+
Bundler.setup
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require "active_support"
|
11
|
+
require "active_support/test_case"
|
12
|
+
require "active_support/core_ext"
|
13
|
+
require "action_mailer"
|
14
|
+
require "action_mailer_test_via_smtp"
|
15
|
+
require "mocha"
|
16
|
+
|
17
|
+
ActionMailer::Base.delivery_method = :test_via_test
|
18
|
+
ActionMailer::Base.test_recipient = "tester@galaxycats.com"
|
19
|
+
ActionMailer::Base.template_root = "test/templates"
|
20
|
+
|
21
|
+
class Rails; end
|
22
|
+
|
23
|
+
class Notifier < ActionMailer::Base
|
24
|
+
|
25
|
+
def plain_text_email
|
26
|
+
recipients ["test@galaxycats.com"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def multipart_email
|
30
|
+
recipients ["test@galaxycats.com"]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andi Bade
|
@@ -14,21 +14,10 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-12 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
name: thoughtbot-shoulda
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
version: "0"
|
30
|
-
type: :development
|
31
|
-
version_requirements: *id001
|
19
|
+
dependencies: []
|
20
|
+
|
32
21
|
description: "Set one test-reciepient which gets all mails from th app in for example a test/staging environment "
|
33
22
|
email: andi@galaxycats.com
|
34
23
|
executables: []
|
@@ -41,14 +30,18 @@ extra_rdoc_files:
|
|
41
30
|
files:
|
42
31
|
- .document
|
43
32
|
- .gitignore
|
33
|
+
- Gemfile
|
44
34
|
- LICENSE
|
45
35
|
- README.rdoc
|
46
36
|
- Rakefile
|
47
37
|
- VERSION
|
48
38
|
- action_mailer_test_via_smtp.gemspec
|
49
39
|
- lib/action_mailer_test_via_smtp.rb
|
50
|
-
- test/
|
51
|
-
- test/
|
40
|
+
- test/action_mailer_test_via_smtp_test.rb
|
41
|
+
- test/templates/notifier/multipart_email.text.html.erb
|
42
|
+
- test/templates/notifier/multipart_email.text.plain.erb
|
43
|
+
- test/templates/notifier/plain_text_email.erb
|
44
|
+
- test/test_helper.rb
|
52
45
|
has_rdoc: true
|
53
46
|
homepage: http://github.com/galaxycats/action_mailer_test_via_smtp
|
54
47
|
licenses: []
|
@@ -80,5 +73,5 @@ signing_key:
|
|
80
73
|
specification_version: 3
|
81
74
|
summary: test mails via smtp with actionmailer
|
82
75
|
test_files:
|
83
|
-
- test/
|
84
|
-
- test/
|
76
|
+
- test/action_mailer_test_via_smtp_test.rb
|
77
|
+
- test/test_helper.rb
|
data/test/helper.rb
DELETED