malone 1.1.0 → 1.2.0

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: f172561f109c7824a28eebefc1f46b602af464f5
4
- data.tar.gz: 553c691a79fff0dc2b7582e6c13d57c9f83324fd
3
+ metadata.gz: 8b1ca8f31cc283952e8c8695856e8d23b786989f
4
+ data.tar.gz: 590735c66084e4ac868cc84134bf8ada90e1658e
5
5
  SHA512:
6
- metadata.gz: 334ff5a81a3317702616e41adfa8d34fbb82849a280c214a662e8c40208d4cba284d6a1e321d4d65752f61b34f395d7969841faa429422c292861e5aeafaf9c9
7
- data.tar.gz: 1cffdd95f5367221bf2ba17b7bc194036adbe06d8a07faedaf02a7e4b22eeb35ba0ccd384ef2e6a485062c20a7162368df0e93ea2ae61a673bb0f678fc6ef165
6
+ metadata.gz: 4e970f1a1cc960d86a770eefa0ebecaee36acff06b0bf84e1d58829fbf79b4db501e777016f8b78f68be5550626e4f611dee887183a3680042c2aa2c075f600b
7
+ data.tar.gz: 88545a350e515bca0f72043aaa918ea09d77384e7b50f84ab375121373ff8877982c52e3f484cfd19820035526912b467d15016c8ec88a2be8ef2d9ced31f503
@@ -30,6 +30,7 @@ class Malone
30
30
 
31
31
  def deliver(dict)
32
32
  mail = envelope(dict)
33
+ yield mail if block_given?
33
34
 
34
35
  smtp = Net::SMTP.new(config.host, config.port)
35
36
  smtp.enable_starttls_auto if config.tls
@@ -65,8 +66,9 @@ class Malone
65
66
  attr_accessor :user
66
67
  attr_accessor :password
67
68
  attr_accessor :domain
68
- attr_accessor :auth
69
69
  attr_accessor :tls
70
+
71
+ attr :auth
70
72
 
71
73
  def initialize(options)
72
74
  opts = options.dup
@@ -90,8 +92,7 @@ class Malone
90
92
  end
91
93
 
92
94
  def auth=(val)
93
- @auth = val
94
- @auth = @auth.to_sym if @auth
95
+ @auth = val && val.to_sym
95
96
  end
96
97
 
97
98
  private
@@ -5,6 +5,10 @@ class Malone
5
5
  @deliveries ||= []
6
6
  end
7
7
 
8
+ def self.reset_deliveries
9
+ @deliveries = nil
10
+ end
11
+
8
12
  def deliver(*args)
9
13
  self.class.deliveries << OpenStruct.new(*args)
10
14
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'malone'
3
- s.version = "1.1.0"
3
+ s.version = "1.2.0"
4
4
  s.summary = %{The Mailman}
5
5
  s.description = %{Dead-simple Ruby mailing solution which always delivers.}
6
6
  s.date = "2011-01-10"
@@ -186,6 +186,15 @@ scope do
186
186
  assert $smtp[:finish]
187
187
  end
188
188
 
189
+ test "adding custom headers" do |m|
190
+ m.deliver(to: "recipient@me.com", from: "no-reply@mydomain.com",
191
+ subject: "Happy new year!", text: "TEXT") do |mail|
192
+ mail.add_header("X-MC-SendAt", "2016-01-01 00:00:00")
193
+ end
194
+
195
+ assert $smtp[:blob].include?("X-MC-SendAt: 2016-01-01 00:00:00")
196
+ end
197
+
189
198
  test "calls #finish even when it fails during send_message" do |m|
190
199
  class FakeSMTP
191
200
  def send_message(*args)
@@ -221,3 +230,18 @@ test "sandbox" do
221
230
  assert_equal "TEXT", mail.text
222
231
  assert_equal "<h1>TEXT</h1>", mail.html
223
232
  end
233
+
234
+ test "resetting the test sandbox" do
235
+ require "malone/test"
236
+
237
+ m = Malone.connect
238
+
239
+ 2.times do
240
+ m.deliver(to: "recipient@me.com", from: "no-reply@mydomain.com",
241
+ subject: "SUB", text: "test")
242
+ end
243
+
244
+ assert 1 < Malone.deliveries.size
245
+ Malone.reset_deliveries
246
+ assert_equal 0, Malone.deliveries.size
247
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: malone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril David
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.4.5
78
+ rubygems_version: 2.4.5.1
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: The Mailman