mandrill_mailer 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 050aa30e1863a63c0e023050c83d720fdf952805
4
- data.tar.gz: f2179df6cf50a863c5b70096a8cadbf77ea40dc8
3
+ metadata.gz: 9f3255d5096df33a1fcdbf3d562ff8f3a2cab3fc
4
+ data.tar.gz: 1e4a6d539dc09befe73bdc2054b4c5bfd5210663
5
5
  SHA512:
6
- metadata.gz: 5ccb28b3e20348666f2fe2ba80565a24ce06e2550013de771ab7ac7a03a9d69ef7e4773bef4aa5bbef72f93c764494cbc456e428d8c2b0eb0b881f65f52bd6d7
7
- data.tar.gz: 31deabd8cace6c79cffe3f8004a3ffcb8e865bac0d71a0361da230790dcd7bae607c060c4ae63cf219c491e5422f7b0dbb476ba149ec5bcfa2a44d9a7229070f
6
+ metadata.gz: 9b6c81956a7d72dfd202fd35aa46db470467fd783c2ac48485e3ed630aa735e786925a8d758a67c1b8f41e5beaa15a4a60695b773db228c37e8776d71d3021e4
7
+ data.tar.gz: d47ec51ea5daa756a8d67c8659c0fdb120797a517df0362aa54d8ae31e07277e8240413456381170c654fc7a33ca27434a89cc723b8d98d6826859cedfc79a7c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## 1.0.1
6
+ - Correct regression caused in 1.0.0 that broke defaults in mailers - Credit: @etipton
7
+
5
8
  ## 1.0.0
6
9
  - Update manrill_api gem to 1.0.X
7
10
  - Change how interceptors work to be more flexible and not overwrite data if needed
data/README.md CHANGED
@@ -341,11 +341,11 @@ MandrillMailer.configure do |config|
341
341
  config.interceptor = Proc.new {|params|
342
342
 
343
343
  params[:to] = [
344
- params[:to],
345
- { email: "bccEmailThatWillBeUsedInAll@emailsSent1.com", name: "name", type: "bcc" },
346
- { email: "bccEmailThatWillBeUsedInAll@emailsSent2.com", name: "name", type: "bcc" },
347
- { email: "bccEmailThatWillBeUsedInAll@emailsSent3.com", name: "name", type: "bcc" }
348
- ].flatten
344
+ params[:to],
345
+ { email: "bccEmailThatWillBeUsedInAll@emailsSent1.com", name: "name", type: "bcc" },
346
+ { email: "bccEmailThatWillBeUsedInAll@emailsSent2.com", name: "name", type: "bcc" },
347
+ { email: "bccEmailThatWillBeUsedInAll@emailsSent3.com", name: "name", type: "bcc" }
348
+ ].flatten
349
349
  }
350
350
  end
351
351
  ```
@@ -69,7 +69,7 @@ module MandrillMailer
69
69
  end
70
70
  end
71
71
 
72
- def self.format_messages_api_message_data(args)
72
+ def self.format_messages_api_message_data(args, defaults)
73
73
  # If a merge_language attribute is given and it's not one of the accepted
74
74
  # languages Raise an error
75
75
  if args[:merge_language] && !ACCEPTED_MERGE_LANGUAGES.include?(args[:merge_language])
@@ -111,9 +111,5 @@ module MandrillMailer
111
111
  "images" => images_args(args[:images])
112
112
  }
113
113
  end
114
-
115
- def self.defaults
116
- MandrillMailer::CoreMailer.defaults
117
- end
118
114
  end
119
- end
115
+ end
@@ -242,7 +242,7 @@ module MandrillMailer
242
242
  mandrill_mail_handler(args)
243
243
 
244
244
  # Construct message hash
245
- self.message = MandrillMailer::ArgFormatter.format_messages_api_message_data(args)
245
+ self.message = MandrillMailer::ArgFormatter.format_messages_api_message_data(args, self.class.defaults)
246
246
 
247
247
  # Apply any interceptors that may be present
248
248
  apply_interceptors!(self.message)
@@ -1,3 +1,3 @@
1
1
  module MandrillMailer
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -197,7 +197,7 @@ describe MandrillMailer::ArgFormatter do
197
197
 
198
198
  describe ".format_messages_api_message_data" do
199
199
  it "includes all api values" do
200
- result = formatter.format_messages_api_message_data({})
200
+ result = formatter.format_messages_api_message_data({}, {})
201
201
  api_values = ["html", "text", "subject", "from_email", "from_name", "to",
202
202
  "headers", "important", "track_opens", "track_clicks", "auto_text",
203
203
  "auto_html", "inline_css", "url_strip_qs", "preserve_recipients",
@@ -216,20 +216,20 @@ describe MandrillMailer::ArgFormatter do
216
216
  context "merge_language exists" do
217
217
  context "merge_language is an accepted merge language" do
218
218
  it "does not raise an error" do
219
- expect { formatter.format_messages_api_message_data({merge_language: "handlebars"}) }.not_to raise_error
219
+ expect { formatter.format_messages_api_message_data({merge_language: "handlebars"}, {}) }.not_to raise_error
220
220
  end
221
221
  end
222
222
 
223
223
  context "merge_language is not an accepted merge language" do
224
224
  it "raises an error" do
225
- expect { formatter.format_messages_api_message_data({merge_language: "not_valid"}) }.to raise_error(MandrillMailer::CoreMailer::InvalidMergeLanguageError)
225
+ expect { formatter.format_messages_api_message_data({merge_language: "not_valid"}, {}) }.to raise_error(MandrillMailer::CoreMailer::InvalidMergeLanguageError)
226
226
  end
227
227
  end
228
228
  end
229
229
 
230
230
  context "merge_language does not exist" do
231
231
  it "does not raise an error" do
232
- expect { formatter.format_messages_api_message_data({}) }.not_to raise_error
232
+ expect { formatter.format_messages_api_message_data({}, {}) }.not_to raise_error
233
233
  end
234
234
  end
235
235
  end
@@ -95,6 +95,28 @@ describe MandrillMailer::CoreMailer do
95
95
  mailer.mandrill_mail(args)
96
96
  end
97
97
 
98
+ it "applies defaults" do
99
+ default_from = "default name"
100
+ default_from_email = "default@email.com"
101
+
102
+ unique_mailer = Class.new(core_mailer) do
103
+ default from_name: default_from,
104
+ from: default_from_email
105
+ end
106
+
107
+ # Create a second mailer to make sure we don't get class var pollution
108
+ control_mailer = Class.new(core_mailer) do
109
+ default from_name: "None",
110
+ from: "invalid@email.com"
111
+ end
112
+
113
+ new_unique_mailer = unique_mailer.new
114
+ new_unique_mailer.mandrill_mail({})
115
+
116
+ expect(new_unique_mailer.message['from_name']).to eq default_from
117
+ expect(new_unique_mailer.message['from_email']).to eq default_from_email
118
+ end
119
+
98
120
  describe "vars attribute" do
99
121
  it "returns the vars" do
100
122
  mailer.mandrill_mail(args)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandrill_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Rensel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-16 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport