padrino-mailer 0.16.0.pre4 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +20 -20
- data/Rakefile +1 -1
- data/lib/padrino-mailer/base.rb +15 -15
- data/lib/padrino-mailer/ext.rb +30 -29
- data/lib/padrino-mailer/helpers.rb +21 -20
- data/lib/padrino-mailer/mime.rb +4 -4
- data/lib/padrino-mailer.rb +2 -4
- data/padrino-mailer.gemspec +17 -17
- data/test/fixtures/padrino_app/app.rb +48 -48
- data/test/fixtures/sinatra_app/app.rb +23 -23
- data/test/helper.rb +5 -5
- data/test/test_email.rb +34 -32
- data/test/test_message.rb +17 -17
- data/test/test_padrino_mailer.rb +54 -54
- data/test/test_part.rb +18 -18
- metadata +6 -6
data/test/test_padrino_mailer.rb
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
|
+
require_relative 'fixtures/sinatra_app/app'
|
|
3
|
+
require_relative 'fixtures/padrino_app/app'
|
|
4
4
|
|
|
5
|
-
describe
|
|
5
|
+
describe 'PadrinoMailer' do
|
|
6
6
|
describe 'for mail delivery in sample Sinatra application' do
|
|
7
7
|
before { @app = SinatraApp }
|
|
8
8
|
|
|
9
9
|
it 'should be able to deliver inline emails using the email helper' do
|
|
10
10
|
post '/deliver/inline'
|
|
11
11
|
assert_equal 'mail delivered', body
|
|
12
|
-
assert_email_sent(:
|
|
13
|
-
:
|
|
14
|
-
:
|
|
15
|
-
:
|
|
12
|
+
assert_email_sent(to: 'john@apple.com',
|
|
13
|
+
from: 'joe@smith.com',
|
|
14
|
+
subject: 'Test Email',
|
|
15
|
+
body: 'Test Body')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it 'should be able to deliver plain text emails' do
|
|
19
19
|
post '/deliver/plain'
|
|
20
20
|
assert_equal 'mail delivered', body
|
|
21
|
-
assert_email_sent(:
|
|
22
|
-
:
|
|
23
|
-
:
|
|
24
|
-
:
|
|
21
|
+
assert_email_sent(to: 'john@fake.com',
|
|
22
|
+
from: 'noreply@birthday.com',
|
|
23
|
+
subject: 'Happy Birthday!',
|
|
24
|
+
body: "Happy Birthday Joey!\nYou are turning 21")
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it 'should be able to deliver emails with custom view' do
|
|
28
28
|
post '/deliver/custom'
|
|
29
29
|
assert_equal 'mail delivered', body
|
|
30
|
-
assert_email_sent(:
|
|
31
|
-
:
|
|
32
|
-
:
|
|
33
|
-
:
|
|
34
|
-
:
|
|
30
|
+
assert_email_sent(template: 'mailers/sample/foo_message',
|
|
31
|
+
to: 'john@fake.com',
|
|
32
|
+
from: 'noreply@custom.com',
|
|
33
|
+
subject: 'Welcome Message!',
|
|
34
|
+
body: 'Hello to Bobby')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it 'should be able to deliver html emails' do
|
|
38
38
|
post '/deliver/html'
|
|
39
39
|
assert_equal 'mail delivered', body
|
|
40
|
-
assert_email_sent(:
|
|
41
|
-
:
|
|
42
|
-
:
|
|
43
|
-
:
|
|
44
|
-
:
|
|
40
|
+
assert_email_sent(to: 'julie@fake.com',
|
|
41
|
+
from: 'noreply@anniversary.com',
|
|
42
|
+
content_type: 'text/html',
|
|
43
|
+
subject: 'Happy anniversary!',
|
|
44
|
+
body: "<p>Yay Joey & Charlotte!</p>\n<p>You have been married 16 years</p>")
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it 'should be able to deliver a basic email using app settings' do
|
|
48
|
-
@app.email(:
|
|
49
|
-
:
|
|
50
|
-
:
|
|
51
|
-
assert_email_sent(:
|
|
52
|
-
:
|
|
48
|
+
@app.email(to: 'john@apple.com', from: 'joe@smith.com',
|
|
49
|
+
subject: 'Test Email', body: 'Test Body',
|
|
50
|
+
via: :test)
|
|
51
|
+
assert_email_sent(to: 'john@apple.com', from: 'joe@smith.com',
|
|
52
|
+
subject: 'Test Email', body: 'Test Body')
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -59,33 +59,33 @@ describe "PadrinoMailer" do
|
|
|
59
59
|
it 'should be able to deliver inline emails using the email helper' do
|
|
60
60
|
post '/deliver/inline'
|
|
61
61
|
assert_equal 'mail delivered', body
|
|
62
|
-
assert_email_sent(:
|
|
63
|
-
:
|
|
64
|
-
:
|
|
62
|
+
assert_email_sent(to: 'john@apple.com', from: 'joe@smith.com',
|
|
63
|
+
subject: 'Test Email',
|
|
64
|
+
body: 'Test Body')
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it 'should be able to deliver plain text emails' do
|
|
68
68
|
post '/deliver/plain'
|
|
69
69
|
assert_equal 'mail delivered', body
|
|
70
|
-
assert_email_sent(:
|
|
71
|
-
:
|
|
72
|
-
:
|
|
70
|
+
assert_email_sent(to: 'john@fake.com', from: 'noreply@birthday.com',
|
|
71
|
+
subject: 'Happy Birthday!',
|
|
72
|
+
body: "Happy Birthday Joey!\nYou are turning 21")
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
it 'should be able to deliver emails with custom view' do
|
|
76
76
|
post '/deliver/custom'
|
|
77
77
|
assert_equal 'mail delivered', body
|
|
78
|
-
assert_email_sent(:
|
|
79
|
-
:
|
|
80
|
-
:
|
|
78
|
+
assert_email_sent(template: 'mailers/sample/foo_message', to: 'john@fake.com',
|
|
79
|
+
from: 'noreply@custom.com',
|
|
80
|
+
subject: 'Welcome Message!', body: 'Hello to Bobby')
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it 'should be able to deliver html emails' do
|
|
84
84
|
post '/deliver/html'
|
|
85
85
|
assert_equal 'mail delivered', body
|
|
86
|
-
assert_email_sent(:
|
|
87
|
-
:
|
|
88
|
-
:
|
|
86
|
+
assert_email_sent(to: 'julie@fake.com', from: 'noreply@anniversary.com',
|
|
87
|
+
content_type: 'text/html',
|
|
88
|
+
subject: 'Happy anniversary!', body: "<p>Yay Joey & Charlotte!</p>\n<p>You have been married 16 years</p>")
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
it 'should be able to deliver emails with views in custom-named folders' do
|
|
@@ -94,48 +94,48 @@ describe "PadrinoMailer" do
|
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
it 'should be able to deliver a basic email using app settings' do
|
|
97
|
-
@app.email(:
|
|
98
|
-
:
|
|
99
|
-
:
|
|
100
|
-
assert_email_sent(:
|
|
101
|
-
:
|
|
97
|
+
@app.email(to: 'john@apple.com', from: 'joe@smith.com',
|
|
98
|
+
subject: 'Test Email', body: 'Test Body',
|
|
99
|
+
via: :test)
|
|
100
|
+
assert_email_sent(to: 'john@apple.com', from: 'joe@smith.com',
|
|
101
|
+
subject: 'Test Email', body: 'Test Body')
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
it 'should be able to deliver a basic email using Padrino::Helpers' do
|
|
105
|
-
skip #FIXME
|
|
105
|
+
skip # FIXME
|
|
106
106
|
post '/deliver/helper'
|
|
107
107
|
assert_equal 'mail delivered', body
|
|
108
|
-
assert_email_sent(:
|
|
109
|
-
:
|
|
110
|
-
:
|
|
108
|
+
assert_email_sent(to: 'jim@fake.com', from: 'noreply@custom.com',
|
|
109
|
+
content_type: 'text/html',
|
|
110
|
+
subject: 'Welcome Helper!', body: '<a href="#">jim</a>')
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it 'should fail with proper message if mailer is not registered' do
|
|
114
114
|
error = assert_raises RuntimeError do
|
|
115
115
|
post '/deliver/failing_mailer'
|
|
116
116
|
end
|
|
117
|
-
assert_match
|
|
117
|
+
assert_match(/is not registered/, error.message)
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
it 'should fail with proper message if message does not exist' do
|
|
121
121
|
error = assert_raises RuntimeError do
|
|
122
122
|
post '/deliver/failing_message'
|
|
123
123
|
end
|
|
124
|
-
assert_match
|
|
124
|
+
assert_match(/has no message/, error.message)
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
it 'should be able to render default mailer names' do
|
|
128
128
|
post '/deliver/default_mailer_name'
|
|
129
129
|
assert_equal 'mail delivered', body
|
|
130
|
-
assert_email_sent(:
|
|
131
|
-
:
|
|
130
|
+
assert_email_sent(to: 'jim@fake.com', from: 'noreply@custom.com',
|
|
131
|
+
content_type: 'text/plain', body: 'dmn')
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
it 'should be able to render default mailer email names' do
|
|
135
135
|
post '/deliver/default_mailer_email_name'
|
|
136
136
|
assert_equal 'mail delivered', body
|
|
137
|
-
assert_email_sent(:
|
|
138
|
-
:
|
|
137
|
+
assert_email_sent(to: 'jim@fake.com', from: 'noreply@custom.com',
|
|
138
|
+
content_type: 'text/plain', body: 'dmen')
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
end
|
data/test/test_part.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
4
|
-
describe
|
|
3
|
+
describe 'Part' do
|
|
4
|
+
describe 'the part' do
|
|
5
5
|
it 'should use correctly parts' do
|
|
6
6
|
message = Mail::Message.new do
|
|
7
|
-
views
|
|
7
|
+
views "#{__dir__}/fixtures/views/mailers"
|
|
8
8
|
to 'padrino@test.lindsaar.net'
|
|
9
9
|
subject 'nested multipart'
|
|
10
10
|
from 'test@example.com'
|
|
@@ -37,7 +37,7 @@ describe "Part" do
|
|
|
37
37
|
|
|
38
38
|
it 'should works with multipart templates' do
|
|
39
39
|
message = Mail::Message.new do
|
|
40
|
-
views
|
|
40
|
+
views "#{__dir__}/fixtures/views/mailers"
|
|
41
41
|
to 'padrino@test.lindsaar.net'
|
|
42
42
|
subject 'nested multipart'
|
|
43
43
|
from 'test@example.com'
|
|
@@ -62,7 +62,7 @@ describe "Part" do
|
|
|
62
62
|
|
|
63
63
|
it 'should works with less explict multipart templates' do
|
|
64
64
|
message = Mail::Message.new do
|
|
65
|
-
views
|
|
65
|
+
views "#{__dir__}/fixtures/views/mailers"
|
|
66
66
|
to 'padrino@test.lindsaar.net'
|
|
67
67
|
subject 'nested multipart'
|
|
68
68
|
from 'test@example.com'
|
|
@@ -82,15 +82,15 @@ describe "Part" do
|
|
|
82
82
|
|
|
83
83
|
it 'should works with provides' do
|
|
84
84
|
message = Mail::Message.new do
|
|
85
|
-
views
|
|
86
|
-
to
|
|
87
|
-
subject
|
|
88
|
-
from
|
|
85
|
+
views "#{__dir__}/fixtures/views/mailers"
|
|
86
|
+
to 'padrino@test.lindsaar.net'
|
|
87
|
+
subject 'nested multipart'
|
|
88
|
+
from 'test@example.com'
|
|
89
89
|
provides :plain, :html
|
|
90
|
-
render
|
|
90
|
+
render 'multipart/basic'
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
assert_match
|
|
93
|
+
assert_match(%r{^multipart/alternative}, message['content-type'].value)
|
|
94
94
|
assert_equal 2, message.parts.length
|
|
95
95
|
assert_equal :plain, message.parts[0].content_type
|
|
96
96
|
assert_equal 'plain text', message.parts[0].body.decoded.chomp
|
|
@@ -101,13 +101,13 @@ describe "Part" do
|
|
|
101
101
|
# it 'should provide a way to instantiate a new part as you go down' do
|
|
102
102
|
# message = Mail::Message.new do
|
|
103
103
|
# to 'padrino@test.lindsaar.net'
|
|
104
|
-
# subject
|
|
105
|
-
# from
|
|
106
|
-
# content_type
|
|
104
|
+
# subject 'nested multipart'
|
|
105
|
+
# from 'test@example.com'
|
|
106
|
+
# content_type 'multipart/mixed'
|
|
107
107
|
#
|
|
108
|
-
# part :
|
|
109
|
-
# p.part :
|
|
110
|
-
# p.part :
|
|
108
|
+
# part content_type: 'multipart/alternative', content_disposition: 'inline', headers: { 'foo' => 'bar' } do |p|
|
|
109
|
+
# p.part content_type: 'text/plain', body: "test text\nline #2"
|
|
110
|
+
# p.part content_type: 'text/html', body: "<b>test</b> HTML<br/>\nline #2"
|
|
111
111
|
# end
|
|
112
112
|
# end
|
|
113
113
|
#
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: padrino-mailer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.16.0
|
|
4
|
+
version: 0.16.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Padrino Team
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2025-
|
|
14
|
+
date: 2025-12-02 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: padrino-core
|
|
@@ -19,14 +19,14 @@ dependencies:
|
|
|
19
19
|
requirements:
|
|
20
20
|
- - '='
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.16.0
|
|
22
|
+
version: 0.16.0
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - '='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.16.0
|
|
29
|
+
version: 0.16.0
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: mime-types
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -125,9 +125,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
125
|
version: '0'
|
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
requirements:
|
|
128
|
-
- - "
|
|
128
|
+
- - ">="
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: 1.3.
|
|
130
|
+
version: 1.3.6
|
|
131
131
|
requirements: []
|
|
132
132
|
rubygems_version: 3.4.19
|
|
133
133
|
signing_key:
|