mandrill_mailer 0.3.1 → 0.3.2
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.
@@ -76,9 +76,12 @@ module MandrillMailer
|
|
76
76
|
#
|
77
77
|
# Returns options
|
78
78
|
def self.default(args)
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
@defaults ||= {}
|
80
|
+
@defaults[:from] ||= 'example@email.com'
|
81
|
+
@defaults.merge!(args)
|
82
|
+
end
|
83
|
+
class << self
|
84
|
+
attr_accessor :defaults
|
82
85
|
end
|
83
86
|
|
84
87
|
# Public: setup a way to test mailer methods
|
@@ -101,8 +104,8 @@ module MandrillMailer
|
|
101
104
|
#
|
102
105
|
# Returns the duplicated String.
|
103
106
|
def self.test_setup_for(mailer_method, &block)
|
104
|
-
|
105
|
-
|
107
|
+
@mailer_methods ||= {}
|
108
|
+
@mailer_methods[mailer_method] = block
|
106
109
|
end
|
107
110
|
|
108
111
|
# Public: Executes a test email
|
@@ -121,8 +124,8 @@ module MandrillMailer
|
|
121
124
|
raise InvalidEmail.new 'Please specify a :email option(email to send the test to)'
|
122
125
|
end
|
123
126
|
|
124
|
-
if
|
125
|
-
|
127
|
+
if @mailer_methods[mailer_method]
|
128
|
+
@mailer_methods[mailer_method].call(self.new, options)
|
126
129
|
else
|
127
130
|
raise InvalidMailerMethod.new "The mailer method: #{mailer_method} does not have test setup"
|
128
131
|
end
|
@@ -194,8 +197,8 @@ module MandrillMailer
|
|
194
197
|
# Construct message hash
|
195
198
|
self.message = {
|
196
199
|
"subject" => args[:subject],
|
197
|
-
"from_email" => args[:from] ||
|
198
|
-
"from_name" => args[:from_name] ||
|
200
|
+
"from_email" => args[:from] || self.class.defaults[:from],
|
201
|
+
"from_name" => args[:from_name] || self.class.defaults[:from_name] || self.class.defaults[:from],
|
199
202
|
"to" => args[:to],
|
200
203
|
"headers" => args[:headers],
|
201
204
|
"track_opens" => true,
|
@@ -206,4 +206,18 @@ describe MandrillMailer::TemplateMailer do
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
end
|
209
|
+
|
210
|
+
describe 'defaults' do
|
211
|
+
it 'should not share between different subclasses' do
|
212
|
+
klassA = Class.new(MandrillMailer::TemplateMailer) do
|
213
|
+
default from_name: 'ClassA'
|
214
|
+
end
|
215
|
+
klassB = Class.new(MandrillMailer::TemplateMailer) do
|
216
|
+
default from_name: 'ClassB'
|
217
|
+
end
|
218
|
+
|
219
|
+
klassA.mandrill_mail({vars: {}}).message['from_name'].should eq 'ClassA'
|
220
|
+
klassB.mandrill_mail({vars: {}}).message['from_name'].should eq 'ClassB'
|
221
|
+
end
|
222
|
+
end
|
209
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandrill_mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -139,3 +139,4 @@ test_files:
|
|
139
139
|
- spec/fake_rails/fake_rails.rb
|
140
140
|
- spec/spec_helper.rb
|
141
141
|
- spec/template_mailer_spec.rb
|
142
|
+
has_rdoc:
|