padrino-mailer 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
3
  === Overview
4
4
 
5
- This component creates an easy and intuitive interface for delivering email within a Sinatra application. The mail library is utilized
6
- to do the bulk of the work. There is full support for rendering email templates, using an html content type and for file attachments.
7
- The Padrino Mailer uses a familiar Sinatra syntax similar to that of defining routes for a controller.
5
+ This component creates an easy and intuitive interface for delivering email within a Sinatra
6
+ application. The mail library is utilized to do the bulk of the work. There is full support for
7
+ rendering email templates, using an html content type and for file attachments. The Padrino Mailer
8
+ uses a familiar Sinatra syntax similar to that of defining routes for a controller.
8
9
 
9
10
  === Usage
10
11
 
11
12
  Let's take a look at using the Mailer in an application. By default, the Mailer uses the built-in sendmail
12
- command on the server. However, smtp is also supported using the following configuration:
13
+ command on the server. However, SMTP is also supported using the following configuration:
13
14
 
14
15
  # Example for configuring gmail smtp
15
16
  set :delivery_method, :smtp => {
@@ -22,7 +23,8 @@ command on the server. However, smtp is also supported using the following confi
22
23
  :enable_starttls_auto => true
23
24
  }
24
25
 
25
- Once the delivery settings have been defined, the default will become smtp delivery but can be overwritten in each message.
26
+ Once the delivery settings have been defined, the default will become smtp delivery but can be
27
+ overwritten in each message.
26
28
 
27
29
  Padrino supports sending quick emails (using either sendmail or smtp) right from your controllers.
28
30
  This is ideal for one-off emails where the full mailer declaration is simply unnecessary.
@@ -93,11 +95,11 @@ Once the mailer definition has been completed and the template has been defined,
93
95
 
94
96
  deliver(:sample, :registration, "Bob", "21")
95
97
 
96
- And that will then deliver the email according the the configured options. This is all you need to send basic emails.
98
+ And that will then deliver the email according the configured options. This is all you need to send basic emails.
97
99
 
98
100
  The mailer also supports the attachment of files and various other options. Be sure to check out the
99
101
  {Padrino Mailer}[http://www.padrinorb.com/guides/padrino-mailer] guide for more details on usage.
100
102
 
101
103
  == Copyright
102
104
 
103
- Copyright (c) 2011 Padrino. See LICENSE for details.
105
+ Copyright (c) Padrino. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- # coding:utf-8
1
+ # encoding: utf-8
2
2
  RAKE_ROOT = __FILE__
3
3
 
4
4
  require 'rubygems'
5
- require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
5
+ require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
@@ -1,4 +1,3 @@
1
- # requires tilt if available; falls back on bundled version.
2
1
  begin
3
2
  require 'tilt'
4
3
  rescue LoadError
@@ -1,7 +1,7 @@
1
1
  module Padrino
2
2
  module Mailer
3
3
  ##
4
- # This is the abstract class that other mailers will inherit from in order to send mail
4
+ # This is the abstract class that other mailers will inherit from in order to send mail.
5
5
  #
6
6
  # You can set the default delivery settings from your app through:
7
7
  #
@@ -57,7 +57,7 @@ module Padrino
57
57
  #
58
58
  # @see Padrino::Mailer::Helpers::ClassMethods#mailer
59
59
  # @api private
60
- def initialize(app, name, &block) # @private
60
+ def initialize(app, name, &block)
61
61
  @mailer_name = name
62
62
  @messages = {}
63
63
  @defaults = {}
@@ -65,8 +65,7 @@ module Padrino
65
65
  instance_eval(&block)
66
66
  end
67
67
 
68
- ##
69
- # Defines a mailer object allowing the definition of various email messages that can be delivered
68
+ # Defines a mailer object allowing the definition of various email messages that can be delivered.
70
69
  #
71
70
  # @param [Symbol] name
72
71
  # The name of this email message.
@@ -95,7 +94,7 @@ module Padrino
95
94
  end
96
95
  alias :message :email
97
96
 
98
- # Defines the default attributes for a message in this mailer (including app-wide defaults)
97
+ # Defines the default attributes for a message in this mailer (including app-wide defaults).
99
98
  #
100
99
  # @param [Hash] attributes
101
100
  # The hash of message options to use as default.
@@ -24,7 +24,6 @@ module Mail # @private
24
24
  end
25
25
  alias_method_chain :initialize, :app
26
26
 
27
- ##
28
27
  # Setup like in Sinatra/Padrino apps content_type and template lookup.
29
28
  #
30
29
  # @example
@@ -46,8 +45,7 @@ module Mail # @private
46
45
  end
47
46
  end
48
47
 
49
- ##
50
- # Helper to add a text part to a multipart/alternative email. If this and
48
+ # Helper to add a text part to a multipart/alternative email. If this and
51
49
  # html_part are both defined in a message, then it will be a multipart/alternative
52
50
  # message and set itself that way.
53
51
  #
@@ -56,14 +54,13 @@ module Mail # @private
56
54
  # text_part { render('multipart/basic.text') }
57
55
  #
58
56
  def text_part(value = nil, &block)
59
- add_resolved_part(:variable => :text_part,
60
- :value => value,
57
+ add_resolved_part(:variable => :text_part,
58
+ :value => value,
61
59
  :content_type => 'text/plain',
62
60
  &block)
63
61
  end
64
62
 
65
- ##
66
- # Helper to add a html part to a multipart/alternative email. If this and
63
+ # Helper to add a html part to a multipart/alternative email. If this and
67
64
  # text_part are both defined in a message, then it will be a multipart/alternative
68
65
  # message and set itself that way.
69
66
  #
@@ -72,24 +69,25 @@ module Mail # @private
72
69
  # html_part { render('multipart/basic.html') }
73
70
  #
74
71
  def html_part(value = nil, &block)
75
- add_resolved_part(:variable => :html_part,
76
- :value => value,
77
- :content_type => 'text/html',
72
+ add_resolved_part(:variable => :html_part,
73
+ :value => value,
74
+ :content_type => 'text/html',
78
75
  &block)
79
76
  end
80
77
 
81
78
  def add_resolved_part(attributes = {}, &block)
82
79
  variable, value, content_type = attributes.values_at(:variable, :value, :content_type)
83
80
  if block_given? || value
84
- instance_variable_set "@#{variable}", self.part(:content_type => content_type, :body => value, :part_block => block)
81
+ instance_variable_set "@#{variable}", self.part(:content_type => content_type,
82
+ :body => value,
83
+ :part_block => block)
85
84
  add_multipart_alternate_header unless self.send(variable).blank?
86
85
  else
87
86
  instance_variable_get("@#{variable}") || find_first_mime_type(content_type)
88
87
  end
89
88
  end
90
89
 
91
- ##
92
- # Allows you to add a part in block form to an existing mail message object
90
+ # Allows you to add a part in block form to an existing mail message object.
93
91
  #
94
92
  # @example
95
93
  # mail = Mail.new do
@@ -116,86 +114,75 @@ module Mail # @private
116
114
  end
117
115
  alias_method_chain :do_delivery, :logging if Padrino.respond_to?(:logger)
118
116
 
119
- ##
120
- # Sinatra and Padrino compatibility
117
+ # Sinatra and Padrino compatibility.
121
118
  #
122
119
  def settings
123
120
  self.class
124
121
  end
125
122
 
126
- ##
127
- # Sets the message defined template path to the given view path
123
+ # Sets the message defined template path to the given view path.
128
124
  #
129
125
  def views(value)
130
126
  settings.views = value
131
127
  end
132
128
 
133
129
  ##
134
- # Sets the local variables available within the message template
130
+ # Sets the local variables available within the message template.
135
131
  #
136
132
  def locals(value)
137
133
  @_locals = value
138
134
  end
139
135
 
140
- ##
141
- # Returns the templates for this message
136
+ # Returns the templates for this message.
142
137
  #
143
138
  def self.templates
144
139
  @_templates ||= {}
145
140
  end
146
141
 
147
- ##
148
- # Sets the message defined template path to the given view path
142
+ # Sets the message defined template path to the given view path.
149
143
  #
150
144
  def self.views=(value)
151
145
  @_views = value
152
146
  end
153
147
 
154
- ##
155
- # Returns the template view path defined for this message
148
+ # Returns the template view path defined for this message.
156
149
  #
157
150
  def self.views
158
151
  @_views
159
152
  end
160
153
 
161
- ##
162
- # Modify whether templates should be reloaded (for development)
154
+ # Modify whether templates should be reloaded (for development).
163
155
  #
164
156
  def self.reload_templates=(value)
165
157
  @_reload_templates = value
166
158
  end
167
159
 
168
- ##
169
160
  # Returns true if the templates will be reloaded; false otherwise.
170
161
  #
171
162
  def self.reload_templates?
172
163
  @_reload_templates
173
164
  end
174
165
 
175
- ##
176
- # Return the path of this file, only for compatiblity with sinatra rendering methods
166
+ # Return the path of this file, only for compatibility with Sinatra rendering methods.
177
167
  #
178
168
  def self.caller_locations
179
169
  [[File.dirname(__FILE__), 1]]
180
170
  end
181
171
 
182
- ##
183
- # Return the default encoding
172
+ # Return the default encoding.
184
173
  #
185
174
  def self.default_encoding
186
175
  "utf-8"
187
176
  end
188
177
 
189
- ##
190
- # Modify the default attributes for this message (if not explicitly specified)
178
+ # Modify the default attributes for this message (if not explicitly specified).
191
179
  #
192
180
  def defaults=(attributes)
193
181
  @_defaults = attributes
194
182
  @_defaults.each_pair { |k, v| default(k.to_sym, v) } if @_defaults.is_a?(Hash)
195
183
  end
196
184
 
197
- ##
198
- # Check if we can log
185
+ # Check if we can log.
199
186
  #
200
187
  def self.logging?
201
188
  @_logging
@@ -205,7 +192,7 @@ module Mail # @private
205
192
  @_logging = value
206
193
  end
207
194
 
208
- # Shortcut for delivery_method with smarter smtp overwrites
195
+ # Shortcut for delivery_method with smarter SMTP overwrites
209
196
  def via(method = nil, settings = {})
210
197
  if method.nil?
211
198
  delivery_method
@@ -216,8 +203,7 @@ module Mail # @private
216
203
  end
217
204
  end
218
205
 
219
- ##
220
- # If the value is empty return a symbol that rappresent the content type so:
206
+ # If the value is empty return a symbol that represent the content type so:
221
207
  #
222
208
  # "text/plain" => :plain
223
209
  #
@@ -232,28 +218,28 @@ module Mail # @private
232
218
 
233
219
  private
234
220
 
235
- # Defines the render for the mailer utilizing the padrino 'rendering' module
236
- def render(engine, data=nil, options={}, locals={}, &block)
237
- locals = @_locals if options[:locals].blank? && locals.blank?
238
- # Reload templates
239
- @template_cache.clear if settings.reload_templates?
240
- # Setup provides
241
- provides.each do |format|
242
- part do |p|
243
- p.content_type(format)
244
- p.send(:render, engine, data, options, locals, &block)
245
- add_multipart_alternate_header if html_part.present? || provides.include?(:html)
246
- end
221
+ # Defines the render for the mailer utilizing the padrino 'rendering' module
222
+ def render(engine, data=nil, options={}, locals={}, &block)
223
+ locals = @_locals if options[:locals].blank? && locals.blank?
224
+ # Reload templates
225
+ @template_cache.clear if settings.reload_templates?
226
+
227
+ provides.each do |format|
228
+ part do |p|
229
+ p.content_type(format)
230
+ p.send(:render, engine, data, options, locals, &block)
231
+ add_multipart_alternate_header if html_part.present? || provides.include?(:html)
247
232
  end
248
- # Setup the body if we don't have provides
249
- self.body = super(engine, data, options, locals, &block) if provides.empty?
250
233
  end
251
234
 
252
- # register all special template configurations Padrino has to our fake settings object.
253
- def initialize_template_settings!
254
- Padrino::Rendering.engine_configurations.each do |name, value|
255
- settings.class.instance_eval { define_method(name) { value } }
256
- end
235
+ self.body = super(engine, data, options, locals, &block) if provides.empty?
236
+ end
237
+
238
+ # Register all special template configurations Padrino has to our fake settings object.
239
+ def initialize_template_settings!
240
+ Padrino::Rendering.engine_configurations.each do |name, value|
241
+ settings.class.instance_eval { define_method(name) { value } }
257
242
  end
243
+ end
258
244
  end # Message
259
245
  end # Mail
@@ -8,11 +8,10 @@ module Padrino
8
8
  base.extend(ClassMethods)
9
9
  end
10
10
 
11
- ##
12
11
  # Delivers an email with the given mail attributes.
13
12
  #
14
13
  # @param [Hash] mail_attributes
15
- # The attributes for this message (to, from, subject, cc, bcc, body, etc)
14
+ # The attributes for this message (to, from, subject, cc, bcc, body, etc).
16
15
  # @param [Proc] block
17
16
  # The block mail attributes for this message.
18
17
  #
@@ -31,7 +30,6 @@ module Padrino
31
30
  settings.email(mail_attributes, &block)
32
31
  end
33
32
 
34
- ##
35
33
  # Delivers a mailer message email with the given attributes.
36
34
  #
37
35
  # @param [Symbol] mailer_name
@@ -51,7 +49,6 @@ module Padrino
51
49
  settings.deliver(mailer_name, message_name, *attributes)
52
50
  end
53
51
 
54
- ##
55
52
  # Class methods responsible for registering mailers, configuring settings and delivering messages.
56
53
  #
57
54
  module ClassMethods
@@ -60,14 +57,13 @@ module Padrino
60
57
  super(subclass)
61
58
  end
62
59
 
63
- ##
64
- # Returns all registered mailers for this application
60
+ # Returns all registered mailers for this application.
61
+ #
65
62
  # @private
66
63
  def registered_mailers
67
64
  @_registered_mailers ||= {}
68
65
  end
69
66
 
70
- ##
71
67
  # Defines a mailer object allowing the definition of various email messages that can be delivered.
72
68
  #
73
69
  # @param [Symbol] name
@@ -93,8 +89,7 @@ module Padrino
93
89
  end
94
90
  alias :mailers :mailer
95
91
 
96
- ##
97
- # Delivers a mailer message email with the given attributes
92
+ # Delivers a mailer message email with the given attributes.
98
93
  #
99
94
  # @param [Symbol] mailer_name
100
95
  # The name of the mailer.
@@ -114,11 +109,10 @@ module Padrino
114
109
  message.deliver
115
110
  end
116
111
 
117
- ##
118
112
  # Delivers an email with the given mail attributes with specified and default settings.
119
113
  #
120
114
  # @param [Hash] mail_attributes
121
- # The attributes for this message (to, from, subject, cc, bcc, body, etc)
115
+ # The attributes for this message (to, from, subject, cc, bcc, body, etc).
122
116
  # @param [Proc] block
123
117
  # The block mail attributes for this message.
124
118
  #
@@ -145,18 +139,17 @@ module Padrino
145
139
  end
146
140
 
147
141
  private
148
- ##
149
- # Returns the parsed delivery method options
150
- #
151
- def delivery_settings
152
- @_delivery_setting ||= begin
153
- raise "You must setup :delivery_method, see api for more details" if RUBY_PLATFORM =~ /win32/ && !respond_to?(:delivery_method)
154
- return [:sendmail, { :location => `which sendmail`.chomp }] unless respond_to?(:delivery_method)
155
- return [delivery_method.keys[0], delivery_method.values[0]] if delivery_method.is_a?(Hash)
156
- return [delivery_method, {}] if delivery_method.is_a?(Symbol)
157
- [nil, {}]
158
- end
142
+ # Returns the parsed delivery method options.
143
+ #
144
+ def delivery_settings
145
+ @_delivery_setting ||= begin
146
+ raise "You must setup :delivery_method, see api for more details" if RUBY_PLATFORM =~ /win32/ && !respond_to?(:delivery_method)
147
+ return [:sendmail, { :location => `which sendmail`.chomp }] unless respond_to?(:delivery_method)
148
+ return [delivery_method.keys[0], delivery_method.values[0]] if delivery_method.is_a?(Hash)
149
+ return [delivery_method, {}] if delivery_method.is_a?(Symbol)
150
+ [nil, {}]
159
151
  end
152
+ end
160
153
  end
161
154
  end # Helpers
162
155
  end # Mailer
@@ -1,12 +1,10 @@
1
1
  module Padrino
2
2
  module Mailer
3
3
 
4
- ##
5
4
  # Handles MIME type declarations for mail delivery.
6
5
  #
7
6
  module Mime
8
7
 
9
- ##
10
8
  # Returns Symbol with mime type if found, otherwise use +fallback+.
11
9
  # +mime+ should be the content type like "text/plain"
12
10
  # +fallback+ may be any symbol
data/test/helper.rb CHANGED
@@ -30,7 +30,6 @@ class MiniTest::Spec
30
30
  def assert_email_sent(mail_attributes, options={})
31
31
  mail_message = Mail::TestMailer.deliveries.last
32
32
  raise "No mail message has been sent!" unless mail_message.present?
33
- smtp_settings = options.delete(:smtp) || mail_attributes.delete(:smtp)
34
33
  delivery_attributes = mail_attributes
35
34
  delivery_attributes = { :to => Array(mail_attributes[:to]), :from => Array(mail_attributes[:from]) }
36
35
  delivery_attributes.each_pair do |k, v|
data/test/test_email.rb CHANGED
@@ -3,7 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + '/helper')
3
3
  describe "Email" do
4
4
 
5
5
  context 'the mailer in a app' do
6
-
7
6
  should 'send a basic inline email' do
8
7
  mock_app do
9
8
  register Padrino::Mailer
@@ -4,61 +4,78 @@ require File.expand_path(File.dirname(__FILE__) + '/fixtures/padrino_app/app')
4
4
 
5
5
  describe "PadrinoMailer" do
6
6
 
7
- context 'for mail delivery in sample sinatra application' do
7
+ context 'for mail delivery in sample Sinatra application' do
8
8
  setup { @app = SinatraApp }
9
9
 
10
10
  should "be able to deliver inline emails using the email helper" do
11
11
  post '/deliver/inline'
12
12
  assert_equal 'mail delivered', body
13
- assert_email_sent(:to => 'john@apple.com', :from => 'joe@smith.com',
14
- :subject => 'Test Email', :body => 'Test Body', :delivery_method => @app.delivery_method)
13
+ assert_email_sent(:to => 'john@apple.com',
14
+ :from => 'joe@smith.com',
15
+ :subject => 'Test Email',
16
+ :body => 'Test Body',
17
+ :delivery_method => @app.delivery_method)
15
18
  end
16
19
 
17
20
  should 'be able to deliver plain text emails' do
18
21
  post '/deliver/plain'
19
22
  assert_equal 'mail delivered', body
20
- assert_email_sent(:to => 'john@fake.com', :from => 'noreply@birthday.com', :delivery_method => @app.delivery_method,
21
- :subject => "Happy Birthday!", :body => "Happy Birthday Joey!\nYou are turning 21")
23
+ assert_email_sent(:to => 'john@fake.com',
24
+ :from => 'noreply@birthday.com',
25
+ :delivery_method => @app.delivery_method,
26
+ :subject => "Happy Birthday!",
27
+ :body => "Happy Birthday Joey!\nYou are turning 21")
22
28
  end
23
29
 
24
30
  should 'be able to deliver emails with custom view' do
25
31
  post '/deliver/custom'
26
32
  assert_equal 'mail delivered', body
27
- assert_email_sent(:template => 'mailers/sample/foo_message', :to => 'john@fake.com',
28
- :from => 'noreply@custom.com', :delivery_method => @app.delivery_method,
29
- :subject => "Welcome Message!", :body => "Hello to Bobby")
33
+ assert_email_sent(:template => 'mailers/sample/foo_message',
34
+ :to => 'john@fake.com',
35
+ :from => 'noreply@custom.com',
36
+ :delivery_method => @app.delivery_method,
37
+ :subject => 'Welcome Message!',
38
+ :body => 'Hello to Bobby')
30
39
  end
31
40
 
32
41
  should 'be able to deliver html emails' do
33
42
  post '/deliver/html'
34
43
  assert_equal 'mail delivered', body
35
- assert_email_sent(:to => 'julie@fake.com', :from => 'noreply@anniversary.com',
36
- :content_type => 'text/html', :delivery_method => @app.delivery_method,
37
- :subject => "Happy anniversary!", :body => "<p>Yay Joey & Charlotte!</p>\n<p>You have been married 16 years</p>")
44
+ assert_email_sent(:to => 'julie@fake.com',
45
+ :from => 'noreply@anniversary.com',
46
+ :content_type => 'text/html',
47
+ :delivery_method => @app.delivery_method,
48
+ :subject => 'Happy anniversary!',
49
+ :body => "<p>Yay Joey & Charlotte!</p>\n<p>You have been married 16 years</p>")
38
50
  end
39
51
 
40
52
  should 'be able to deliver a basic email using app settings' do
41
- @app.email(:to => 'john@apple.com', :from => 'joe@smith.com', :subject => 'Test Email', :body => 'Test Body', :via => :test)
53
+ @app.email(:to => 'john@apple.com', :from => 'joe@smith.com',
54
+ :subject => 'Test Email', :body => 'Test Body',
55
+ :via => :test)
42
56
  assert_email_sent(:to => 'john@apple.com', :from => 'joe@smith.com',
43
- :subject => 'Test Email', :body => 'Test Body', :delivery_method => @app.delivery_method)
57
+ :subject => 'Test Email', :body => 'Test Body',
58
+ :delivery_method => @app.delivery_method)
44
59
  end
45
60
  end
46
61
 
47
- context 'for mail delivery in sample padrino application' do
62
+ context 'for mail delivery in sample Padrino application' do
48
63
  setup { @app = PadrinoApp }
49
64
 
50
65
  should "be able to deliver inline emails using the email helper" do
51
66
  post '/deliver/inline'
52
67
  assert_equal 'mail delivered', body
53
- assert_email_sent(:to => 'john@apple.com', :from => 'joe@smith.com', :delivery_method => @app.delivery_method,
54
- :subject => 'Test Email', :body => 'Test Body')
68
+ assert_email_sent(:to => 'john@apple.com', :from => 'joe@smith.com',
69
+ :delivery_method => @app.delivery_method, :subject => 'Test Email',
70
+ :body => 'Test Body')
55
71
  end
56
72
 
57
73
  should 'be able to deliver plain text emails' do
58
74
  post '/deliver/plain'
59
75
  assert_equal 'mail delivered', body
60
- assert_email_sent(:to => 'john@fake.com', :from => 'noreply@birthday.com', :delivery_method => @app.delivery_method,
61
- :subject => "Happy Birthday!", :body => "Happy Birthday Joey!\nYou are turning 21")
76
+ assert_email_sent(:to => 'john@fake.com', :from => 'noreply@birthday.com',
77
+ :delivery_method => @app.delivery_method, :subject => "Happy Birthday!",
78
+ :body => "Happy Birthday Joey!\nYou are turning 21")
62
79
  end
63
80
 
64
81
  should 'be able to deliver emails with custom view' do
@@ -66,7 +83,7 @@ describe "PadrinoMailer" do
66
83
  assert_equal 'mail delivered', body
67
84
  assert_email_sent(:template => 'mailers/sample/foo_message', :to => 'john@fake.com',
68
85
  :from => 'noreply@custom.com', :delivery_method => @app.delivery_method,
69
- :subject => "Welcome Message!", :body => "Hello to Bobby")
86
+ :subject => 'Welcome Message!', :body => 'Hello to Bobby')
70
87
  end
71
88
 
72
89
  should 'be able to deliver html emails' do
@@ -74,13 +91,16 @@ describe "PadrinoMailer" do
74
91
  assert_equal 'mail delivered', body
75
92
  assert_email_sent(:to => 'julie@fake.com', :from => 'noreply@anniversary.com',
76
93
  :content_type => 'text/html', :delivery_method => @app.delivery_method,
77
- :subject => "Happy anniversary!", :body => "<p>Yay Joey & Charlotte!</p>\n<p>You have been married 16 years</p>")
94
+ :subject => 'Happy anniversary!', :body => "<p>Yay Joey & Charlotte!</p>\n<p>You have been married 16 years</p>")
78
95
  end
79
96
 
80
97
  should 'be able to deliver a basic email using app settings' do
81
- @app.email(:to => 'john@apple.com', :from => 'joe@smith.com', :subject => 'Test Email', :body => 'Test Body', :via => :test)
98
+ @app.email(:to => 'john@apple.com', :from => 'joe@smith.com',
99
+ :subject => 'Test Email', :body => 'Test Body',
100
+ :via => :test)
82
101
  assert_email_sent(:to => 'john@apple.com', :from => 'joe@smith.com',
83
- :subject => 'Test Email', :body => 'Test Body', :delivery_method => @app.delivery_method)
102
+ :subject => 'Test Email', :body => 'Test Body',
103
+ :delivery_method => @app.delivery_method)
84
104
  end
85
105
 
86
106
  should_eventually 'be able to deliver a basic email using Padrino::Helpers' do
@@ -88,8 +108,7 @@ describe "PadrinoMailer" do
88
108
  assert_equal 'mail delivered', body
89
109
  assert_email_sent(:to => 'jim@fake.com', :from => 'noreply@custom.com',
90
110
  :content_type => 'text/html', :delivery_method => @app.delivery_method,
91
- :subject => "Welcome Helper!", :body => "<a href=\"#\">jim</a>")
111
+ :subject => 'Welcome Helper!', :body => "<a href=\"#\">jim</a>")
92
112
  end
93
-
94
113
  end
95
114
  end
data/test/test_part.rb CHANGED
@@ -7,8 +7,8 @@ describe "Part" do
7
7
  message = Mail::Message.new do
8
8
  views File.dirname(__FILE__) + '/fixtures/views/mailers'
9
9
  to 'padrino@test.lindsaar.net'
10
- subject "nested multipart"
11
- from "test@example.com"
10
+ subject 'nested multipart'
11
+ from 'test@example.com'
12
12
 
13
13
  text_part do
14
14
  body 'plain text'
@@ -27,19 +27,19 @@ describe "Part" do
27
27
  assert_not_nil message.text_part
28
28
  assert_equal 4, message.parts.length
29
29
  assert_equal :plain, message.parts[0].content_type
30
- assert_equal "plain text", message.parts[0].body.decoded
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.chomp
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
- assert_equal "other", message.parts[2].body.decoded
34
+ assert_equal 'other', message.parts[2].body.decoded
35
35
  end
36
36
 
37
37
  should "works with multipart templates" do
38
38
  message = Mail::Message.new do
39
39
  views File.dirname(__FILE__) + '/fixtures/views/mailers'
40
40
  to 'padrino@test.lindsaar.net'
41
- subject "nested multipart"
42
- from "test@example.com"
41
+ subject 'nested multipart'
42
+ from 'test@example.com'
43
43
 
44
44
  text_part do
45
45
  render 'multipart/basic.text'
@@ -54,17 +54,17 @@ describe "Part" do
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.chomp
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.chomp
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
63
63
  message = Mail::Message.new do
64
64
  views File.dirname(__FILE__) + '/fixtures/views/mailers'
65
65
  to 'padrino@test.lindsaar.net'
66
- subject "nested multipart"
67
- from "test@example.com"
66
+ subject 'nested multipart'
67
+ from 'test@example.com'
68
68
 
69
69
  text_part { render('multipart/basic.plain') }
70
70
  html_part { render('multipart/basic.html') }
@@ -74,17 +74,17 @@ describe "Part" do
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.chomp
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.chomp
79
+ assert_equal 'text html', message.parts[1].body.decoded.chomp
80
80
  end
81
81
 
82
82
  should "works with provides" do
83
83
  message = Mail::Message.new do
84
84
  views File.dirname(__FILE__) + '/fixtures/views/mailers'
85
85
  to 'padrino@test.lindsaar.net'
86
- subject "nested multipart"
87
- from "test@example.com"
86
+ subject 'nested multipart'
87
+ from 'test@example.com'
88
88
  provides :plain, :html
89
89
  render 'multipart/basic'
90
90
  end
@@ -92,9 +92,9 @@ describe "Part" do
92
92
  assert_match /^multipart\/alternative/, message['content-type'].value
93
93
  assert_equal 2, message.parts.length
94
94
  assert_equal :plain, message.parts[0].content_type
95
- assert_equal "plain text", message.parts[0].body.decoded.chomp
95
+ assert_equal 'plain text', message.parts[0].body.decoded.chomp
96
96
  assert_equal :html, message.parts[1].content_type
97
- assert_equal "text html", message.parts[1].body.decoded.chomp
97
+ assert_equal 'text html', message.parts[1].body.decoded.chomp
98
98
  end
99
99
 
100
100
  # should "provide a way to instantiate a new part as you go down" do
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.11.1
4
+ version: 0.11.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-04-07 00:00:00.000000000 Z
15
+ date: 2013-05-21 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: padrino-core
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - '='
23
23
  - !ruby/object:Gem::Version
24
- version: 0.11.1
24
+ version: 0.11.2
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.11.1
32
+ version: 0.11.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: mail
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  segments:
108
108
  - 0
109
- hash: -4568177476945030144
109
+ hash: 1089152754397280349
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements: