padrino-mailer 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/padrino-mailer.rb +1 -1
  3. data/lib/padrino-mailer/base.rb +2 -2
  4. data/lib/padrino-mailer/ext.rb +4 -4
  5. data/lib/padrino-mailer/helpers.rb +3 -3
  6. data/lib/padrino-mailer/mime.rb +1 -1
  7. data/padrino-mailer.gemspec +1 -1
  8. data/test/fixtures/basic.erb +1 -1
  9. data/test/fixtures/layout.erb +1 -1
  10. data/test/fixtures/padrino_app/app.rb +1 -1
  11. data/test/fixtures/padrino_app/views/mailers/demo/sample_mail.erb +1 -1
  12. data/test/fixtures/padrino_app/views/mailers/sample/anniversary.erb +1 -1
  13. data/test/fixtures/padrino_app/views/mailers/sample/birthday.erb +1 -1
  14. data/test/fixtures/padrino_app/views/mailers/sample/foo_message.erb +1 -1
  15. data/test/fixtures/padrino_app/views/mailers/sample/helper_message.erb +1 -1
  16. data/test/fixtures/sinatra_app/views/mailers/demo/sample_mail.erb +1 -1
  17. data/test/fixtures/sinatra_app/views/mailers/sample/anniversary.erb +1 -1
  18. data/test/fixtures/sinatra_app/views/mailers/sample/birthday.erb +1 -1
  19. data/test/fixtures/sinatra_app/views/mailers/sample/foo_message.erb +1 -1
  20. data/test/fixtures/views/mailers/alternate/foo.erb +1 -1
  21. data/test/fixtures/views/mailers/bar.erb +1 -1
  22. data/test/fixtures/views/mailers/i18n/hello.en.erb +1 -1
  23. data/test/fixtures/views/mailers/i18n/hello.it.erb +1 -1
  24. data/test/fixtures/views/mailers/layouts/sample.erb +1 -1
  25. data/test/fixtures/views/mailers/multipart/basic.html.erb +1 -1
  26. data/test/fixtures/views/mailers/multipart/basic.plain.erb +1 -1
  27. data/test/fixtures/views/mailers/sample/foo.erb +1 -1
  28. data/test/helper.rb +1 -1
  29. data/test/test_email.rb +5 -5
  30. data/test/test_message.rb +10 -10
  31. data/test/test_padrino_mailer.rb +1 -1
  32. data/test/test_part.rb +9 -8
  33. metadata +26 -3
data/README.rdoc CHANGED
@@ -100,4 +100,4 @@ The mailer also supports the attachment of files and various other options. Be s
100
100
 
101
101
  == Copyright
102
102
 
103
- Copyright (c) 2011 Padrino. See LICENSE for details.
103
+ Copyright (c) 2011 Padrino. See LICENSE for details.
@@ -31,4 +31,4 @@ module Padrino
31
31
  alias :included :registered
32
32
  end
33
33
  end # Mailer
34
- end # Padrino
34
+ end # Padrino
@@ -27,7 +27,7 @@ module Padrino
27
27
  class Base
28
28
  attr_accessor :delivery_settings, :app, :mailer_name, :messages
29
29
 
30
- def initialize(app, name, &block) #:nodoc:
30
+ def initialize(app, name, &block) # @private
31
31
  @mailer_name = name
32
32
  @messages = {}
33
33
  @defaults = {}
@@ -78,4 +78,4 @@ module Padrino
78
78
  end
79
79
  end # Base
80
80
  end # Mailer
81
- end # Padrino
81
+ end # Padrino
@@ -1,5 +1,5 @@
1
- module Mail #:nodoc:
2
- class Message #:nodoc:
1
+ module Mail # @private
2
+ class Message # @private
3
3
  include Sinatra::Templates
4
4
  include Padrino::Rendering if defined?(Padrino::Rendering)
5
5
  attr_reader :template_cache
@@ -228,7 +228,7 @@ module Mail #:nodoc:
228
228
  part do |p|
229
229
  p.content_type(format)
230
230
  p.send(:render, engine, data, options, locals, &block)
231
- add_multipart_alternate_header unless html_part.blank?
231
+ add_multipart_alternate_header if html_part.present? || provides.include?(:html)
232
232
  end
233
233
  end
234
234
  # Setup the body if we don't have provides
@@ -236,4 +236,4 @@ module Mail #:nodoc:
236
236
  end
237
237
 
238
238
  end # Message
239
- end # Mail
239
+ end # Mail
@@ -1,7 +1,7 @@
1
1
  module Padrino
2
2
  module Mailer
3
3
  module Helpers
4
- def self.included(base) #:nodoc:
4
+ def self.included(base) # @private
5
5
  base.extend(ClassMethods)
6
6
  end
7
7
 
@@ -35,7 +35,7 @@ module Padrino
35
35
  end
36
36
 
37
37
  module ClassMethods
38
- def inherited(subclass) #:nodoc:
38
+ def inherited(subclass) # @private
39
39
  @_registered_mailers ||= {}
40
40
  super(subclass)
41
41
  end
@@ -124,4 +124,4 @@ module Padrino
124
124
  end
125
125
  end # Helpers
126
126
  end # Mailer
127
- end # Padrino
127
+ end # Padrino
@@ -39,4 +39,4 @@ module Padrino
39
39
  }
40
40
  end # Mime
41
41
  end # Mailer
42
- end # Padrino
42
+ end # Padrino
@@ -25,4 +25,4 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency("padrino-core", Padrino.version)
26
26
  s.add_dependency("mail", "~> 2.3.0")
27
27
  s.add_dependency("tlsmail") if RUBY_VERSION == "1.8.6"
28
- end
28
+ end
@@ -1 +1 @@
1
- This is a body of text from a template
1
+ This is a body of text from a template
@@ -1 +1 @@
1
- Layout Basic <%= yield %>
1
+ Layout Basic <%= yield %>
@@ -76,4 +76,4 @@ class PadrinoApp < Padrino::Application
76
76
  end
77
77
 
78
78
  Padrino.mount("PadrinoApp").to("/")
79
- Padrino.load!
79
+ Padrino.load!
@@ -1 +1 @@
1
- This is a sample message
1
+ This is a sample message
@@ -1,2 +1,2 @@
1
1
  <p>Yay <%= names %>!</p>
2
- <p>You have been married <%= years_married %> years</p>
2
+ <p>You have been married <%= years_married %> years</p>
@@ -1,2 +1,2 @@
1
1
  Happy Birthday <%= name %>!
2
- You are turning <%= age %>
2
+ You are turning <%= age %>
@@ -1 +1 @@
1
- Hello to <%= name %>
1
+ Hello to <%= name %>
@@ -1 +1 @@
1
- <%= link_to name, "#" %>
1
+ <%= link_to name, "#" %>
@@ -1 +1 @@
1
- This is a sample message
1
+ This is a sample message
@@ -1,2 +1,2 @@
1
1
  <p>Yay <%= names %>!</p>
2
- <p>You have been married <%= years_married %> years</p>
2
+ <p>You have been married <%= years_married %> years</p>
@@ -1,2 +1,2 @@
1
1
  Happy Birthday <%= name %>!
2
- You are turning <%= age %>
2
+ You are turning <%= age %>
@@ -1 +1 @@
1
- Hello to <%= name %>
1
+ Hello to <%= name %>
@@ -1 +1 @@
1
- This is a foo message in mailers/alternate dir
1
+ This is a foo message in mailers/alternate dir
@@ -1 +1 @@
1
- This is a bar message in mailers dir
1
+ This is a bar message in mailers dir
@@ -1 +1 @@
1
- Hello World
1
+ Hello World
@@ -1 +1 @@
1
- Salve Mondo
1
+ Salve Mondo
@@ -1 +1 @@
1
- Layout Sample <%= yield %>
1
+ Layout Sample <%= yield %>
@@ -1 +1 @@
1
- text html
1
+ text html
@@ -1 +1 @@
1
- plain text
1
+ plain text
@@ -1 +1 @@
1
- This is a foo message in mailers/sample dir
1
+ This is a foo message in mailers/sample dir
data/test/helper.rb CHANGED
@@ -68,4 +68,4 @@ class Test::Unit::TestCase
68
68
  end
69
69
  end
70
70
  alias :response :last_response
71
- end
71
+ end
data/test/test_email.rb CHANGED
@@ -68,7 +68,7 @@ class TestEmail < Test::Unit::TestCase
68
68
  assert_equal ['padrino@me.com'], email.from
69
69
  assert_equal ['padrino@you.com'], email.to
70
70
  assert_equal 'Hello there Padrino', email.subject
71
- assert_equal 'This is a body of text from a template', email.body.to_s
71
+ assert_equal 'This is a body of text from a template', email.body.to_s.chomp
72
72
  end
73
73
 
74
74
  should 'send emails with scoped mailer defaults' do
@@ -93,7 +93,7 @@ class TestEmail < Test::Unit::TestCase
93
93
  assert_equal ['padrino@from.com'], email.from, "should have used default value"
94
94
  assert_equal ['padrino@different.com'], email.to, "should have overwritten default value"
95
95
  assert_equal 'Hello there again Padrino', email.subject
96
- assert_equal 'This is a foo message in mailers/alternate dir', email.body.to_s
96
+ assert_equal 'This is a foo message in mailers/alternate dir', email.body.to_s.chomp
97
97
  end
98
98
 
99
99
  should 'send emails with app mailer defaults' do
@@ -117,7 +117,7 @@ class TestEmail < Test::Unit::TestCase
117
117
  assert_equal ['padrino@from.com'], email.from, "should have used default value"
118
118
  assert_equal ['padrino@different.com'], email.to, "should have overwritten default value"
119
119
  assert_equal 'This is a test', email.subject
120
- assert_equal 'This is a foo message in mailers/alternate dir', email.body.to_s
120
+ assert_equal 'This is a foo message in mailers/alternate dir', email.body.to_s.chomp
121
121
  end
122
122
 
123
123
  should 'send emails without layout' do
@@ -142,7 +142,7 @@ class TestEmail < Test::Unit::TestCase
142
142
  assert_equal ['padrino@me.com'], email.from
143
143
  assert_equal ['padrino@you.com'], email.to
144
144
  assert_equal 'Hello there Padrino', email.subject
145
- assert_equal 'This is a foo message in mailers/alternate dir', email.body.to_s
145
+ assert_equal 'This is a foo message in mailers/alternate dir', email.body.to_s.chomp
146
146
  assert_match /TestMailer/, email.delivery_method.to_s
147
147
  end
148
148
 
@@ -158,4 +158,4 @@ class TestEmail < Test::Unit::TestCase
158
158
  end
159
159
  end
160
160
  end
161
- end
161
+ end
data/test/test_message.rb CHANGED
@@ -14,7 +14,7 @@ class TestMessage < Test::Unit::TestCase
14
14
  assert_equal ['padrino@me.com'], message.from
15
15
  assert_equal ['padrino@you.com'], message.to
16
16
  assert_equal 'Hello there Padrino', message.subject
17
- assert_equal 'This is a body of text', message.body.to_s
17
+ assert_equal 'This is a body of text', message.body.to_s.chomp
18
18
  end
19
19
 
20
20
  should "raise an error if template was not found" do
@@ -40,7 +40,7 @@ class TestMessage < Test::Unit::TestCase
40
40
  assert_equal ['padrino@me.com'], message.from
41
41
  assert_equal ['padrino@you.com'], message.to
42
42
  assert_equal 'Hello there Padrino', message.subject
43
- assert_equal 'Im Foo!', message.body.to_s
43
+ assert_equal 'Im Foo!', message.body.to_s.chomp
44
44
  end
45
45
 
46
46
  should "use views paths" do
@@ -55,7 +55,7 @@ class TestMessage < Test::Unit::TestCase
55
55
  assert_equal ['padrino@me.com'], message.from
56
56
  assert_equal ['padrino@you.com'], message.to
57
57
  assert_equal 'Hello there Padrino', message.subject
58
- assert_equal 'This is a bar message in mailers dir', message.body.to_s
58
+ assert_equal 'This is a bar message in mailers dir', message.body.to_s.chomp
59
59
  end
60
60
 
61
61
  should "use views and mailers paths" do
@@ -70,7 +70,7 @@ class TestMessage < Test::Unit::TestCase
70
70
  assert_equal ['padrino@me.com'], message.from
71
71
  assert_equal ['padrino@you.com'], message.to
72
72
  assert_equal 'Hello there Padrino', message.subject
73
- assert_equal 'This is a foo message in mailers/alternate dir', message.body.to_s
73
+ assert_equal 'This is a foo message in mailers/alternate dir', message.body.to_s.chomp
74
74
  end
75
75
 
76
76
  should "use layouts" do
@@ -85,7 +85,7 @@ class TestMessage < Test::Unit::TestCase
85
85
  assert_equal ['padrino@me.com'], message.from
86
86
  assert_equal ['padrino@you.com'], message.to
87
87
  assert_equal 'Hello there Padrino', message.subject
88
- assert_equal 'Layout Sample This is a foo message in mailers/sample dir', message.body.to_s
88
+ assert_equal 'Layout Sample This is a foo message in mailers/sample dir', message.body.to_s.strip
89
89
  end
90
90
 
91
91
  should "use i18n" do
@@ -102,7 +102,7 @@ class TestMessage < Test::Unit::TestCase
102
102
  assert_equal ['padrino@me.com'], message.from
103
103
  assert_equal ['padrino@you.com'], message.to
104
104
  assert_equal 'Hello there Padrino', message.subject
105
- assert_equal 'Hello World', message.body.to_s
105
+ assert_equal 'Hello World', message.body.to_s.chomp
106
106
 
107
107
  I18n.locale = :it
108
108
 
@@ -117,7 +117,7 @@ class TestMessage < Test::Unit::TestCase
117
117
  assert_equal ['padrino@me.com'], message.from
118
118
  assert_equal ['padrino@you.com'], message.to
119
119
  assert_equal 'Hello there Padrino', message.subject
120
- assert_equal 'Salve Mondo', message.body.to_s
120
+ assert_equal 'Salve Mondo', message.body.to_s.chomp
121
121
  end
122
122
 
123
123
  should "auto lookup template for the given content_type" do
@@ -133,7 +133,7 @@ class TestMessage < Test::Unit::TestCase
133
133
  assert_equal ['padrino@me.com'], message.from
134
134
  assert_equal ['padrino@you.com'], message.to
135
135
  assert_equal 'Hello there Padrino', message.subject
136
- assert_equal 'text html', message.body.to_s
136
+ assert_equal 'text html', message.body.to_s.chomp
137
137
 
138
138
  message = Mail::Message.new do
139
139
  views File.dirname(__FILE__) + '/fixtures/views/mailers'
@@ -147,7 +147,7 @@ class TestMessage < Test::Unit::TestCase
147
147
  assert_equal ['padrino@me.com'], message.from
148
148
  assert_equal ['padrino@you.com'], message.to
149
149
  assert_equal 'Hello there Padrino', message.subject
150
- assert_equal 'plain text', message.body.to_s
150
+ assert_equal 'plain text', message.body.to_s.chomp
151
151
  end
152
152
  end
153
- end
153
+ end
@@ -92,4 +92,4 @@ class TestPadrinoMailer < Test::Unit::TestCase
92
92
  end
93
93
 
94
94
  end
95
- end
95
+ end
data/test/test_part.rb CHANGED
@@ -29,7 +29,7 @@ class TestPart < Test::Unit::TestCase
29
29
  assert_equal :plain, message.parts[0].content_type
30
30
  assert_equal "plain text", message.parts[0].body.decoded
31
31
  assert_equal :html, message.parts[1].content_type
32
- assert_equal "This is a foo message in mailers/sample dir", message.parts[1].body.decoded
32
+ assert_equal "This is a foo message in mailers/sample dir", message.parts[1].body.decoded.chomp
33
33
  assert_equal :plain, message.parts[2].content_type
34
34
  assert_equal "other", message.parts[2].body.decoded
35
35
  end
@@ -54,9 +54,9 @@ class TestPart < Test::Unit::TestCase
54
54
  assert_not_nil message.text_part
55
55
  assert_equal 2, message.parts.length
56
56
  assert_equal :plain, message.parts[0].content_type
57
- assert_equal "plain text", message.parts[0].body.decoded
57
+ assert_equal "plain text", message.parts[0].body.decoded.chomp
58
58
  assert_equal :html, message.parts[1].content_type
59
- assert_equal "text html", message.parts[1].body.decoded
59
+ assert_equal "text html", message.parts[1].body.decoded.chomp
60
60
  end
61
61
 
62
62
  should "works with less explict multipart templates" do
@@ -74,9 +74,9 @@ class TestPart < Test::Unit::TestCase
74
74
  assert_not_nil message.text_part
75
75
  assert_equal 2, message.parts.length
76
76
  assert_equal :plain, message.parts[0].content_type
77
- assert_equal "plain text", message.parts[0].body.decoded
77
+ assert_equal "plain text", message.parts[0].body.decoded.chomp
78
78
  assert_equal :html, message.parts[1].content_type
79
- assert_equal "text html", message.parts[1].body.decoded
79
+ assert_equal "text html", message.parts[1].body.decoded.chomp
80
80
  end
81
81
 
82
82
  should "works with provides" do
@@ -89,11 +89,12 @@ class TestPart < Test::Unit::TestCase
89
89
  render 'multipart/basic'
90
90
  end
91
91
 
92
+ assert_match /^multipart\/alternative/, message['content-type'].value
92
93
  assert_equal 2, message.parts.length
93
94
  assert_equal :plain, message.parts[0].content_type
94
- assert_equal "plain text", message.parts[0].body.decoded
95
+ assert_equal "plain text", message.parts[0].body.decoded.chomp
95
96
  assert_equal :html, message.parts[1].content_type
96
- assert_equal "text html", message.parts[1].body.decoded
97
+ assert_equal "text html", message.parts[1].body.decoded.chomp
97
98
  end
98
99
 
99
100
  # should "provide a way to instantiate a new part as you go down" do
@@ -116,4 +117,4 @@ class TestPart < Test::Unit::TestCase
116
117
  # assert_equal "<b>test</b> HTML<br/>\nline #2", message.parts.first.parts[1].body.decoded
117
118
  # end
118
119
  end
119
- end
120
+ end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-mailer
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 51
4
5
  prerelease:
5
- version: 0.10.1
6
+ segments:
7
+ - 0
8
+ - 10
9
+ - 2
10
+ version: 0.10.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - Padrino Team
@@ -13,7 +18,7 @@ autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
20
 
16
- date: 2011-08-01 00:00:00 -07:00
21
+ date: 2011-08-31 00:00:00 -07:00
17
22
  default_executable:
18
23
  dependencies:
19
24
  - !ruby/object:Gem::Dependency
@@ -24,7 +29,12 @@ dependencies:
24
29
  requirements:
25
30
  - - "="
26
31
  - !ruby/object:Gem::Version
27
- version: 0.10.1
32
+ hash: 51
33
+ segments:
34
+ - 0
35
+ - 10
36
+ - 2
37
+ version: 0.10.2
28
38
  type: :runtime
29
39
  version_requirements: *id001
30
40
  - !ruby/object:Gem::Dependency
@@ -35,6 +45,11 @@ dependencies:
35
45
  requirements:
36
46
  - - ~>
37
47
  - !ruby/object:Gem::Version
48
+ hash: 3
49
+ segments:
50
+ - 2
51
+ - 3
52
+ - 0
38
53
  version: 2.3.0
39
54
  type: :runtime
40
55
  version_requirements: *id002
@@ -98,12 +113,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
113
  requirements:
99
114
  - - ">="
100
115
  - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
101
119
  version: "0"
102
120
  required_rubygems_version: !ruby/object:Gem::Requirement
103
121
  none: false
104
122
  requirements:
105
123
  - - ">="
106
124
  - !ruby/object:Gem::Version
125
+ hash: 23
126
+ segments:
127
+ - 1
128
+ - 3
129
+ - 6
107
130
  version: 1.3.6
108
131
  requirements: []
109
132