mailgun-ruby 1.2.3 → 1.2.4

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
  SHA256:
3
- metadata.gz: 4fec3197ad0202b588d430e3bbbc96e822961e0213a9b45882e5f6490bd9b5bf
4
- data.tar.gz: 8db91a5a020812f436900efb0d181baede311ed6a6d8390a28fa907a32099897
3
+ metadata.gz: 64d4a0d5c1b85d58db90763fc5dbcd0f813f29bf30b328fdda6b7a019fbeb445
4
+ data.tar.gz: 2ddef97a1b88cd9d45c5e2d1b41df3b61e7b3a09a5dcbe4c3b0a62191335aeed
5
5
  SHA512:
6
- metadata.gz: 164c3e148cd16078ad96c2f60620720e754a412dc8ae69bb0248b1e0dc599e5f570314e5b668a356ff90e3e12e1e72879276c9ccf91901c9502ad98cf56a7781
7
- data.tar.gz: be6d57fca9b0224ddc99a17831bef724e05a6e63dfef177c9d478bec8efefe943bf3f07886902da015474d0e5c2a33ddf797cf7ba11db1c7ce2eda8648b0ea35
6
+ metadata.gz: 18df9ff784b8c39376420fcebe0b16a195318e63b70e6b6f5fb6139fd4cbd276ef1647844de6fd12c1e272906862ddfcdc85bb59ab29460dee6e0e02ec872ee8
7
+ data.tar.gz: 25547234506d03d471ea3f3bbfb46eb6c10e104147f6fc7cbe3b3228b966d31b5a3e53f423554c22f45360c119c5c015659b819559ef8d664c7c5ac47be09d00
data/README.md CHANGED
@@ -19,7 +19,7 @@ gem install mailgun-ruby
19
19
  Gemfile:
20
20
 
21
21
  ```ruby
22
- gem 'mailgun-ruby', '~>1.2.3'
22
+ gem 'mailgun-ruby', '~>1.2.4'
23
23
  ```
24
24
 
25
25
  Usage
@@ -64,6 +64,8 @@ module Mailgun
64
64
  # containing required parameters for the requested resource.
65
65
  # @return [Mailgun::Response] A Mailgun::Response object.
66
66
  def send_message(working_domain, data)
67
+ fail ParameterError.new('Missing working domain', working_domain) unless working_domain
68
+
67
69
  if test_mode? then
68
70
  Mailgun::Client.deliveries << data
69
71
  return Response.from_hash(
@@ -270,8 +270,12 @@ module Mailgun
270
270
  # @return [void]
271
271
  def variable(name, data)
272
272
  fail(Mailgun::ParameterError, 'Variable name must be specified') if name.to_s.empty?
273
- jsondata = make_json data
274
- set_single("v:#{name}", jsondata)
273
+ begin
274
+ jsondata = make_json data
275
+ set_single("v:#{name}", jsondata)
276
+ rescue Mailgun::ParameterError
277
+ set_single("v:#{name}", data)
278
+ end
275
279
  end
276
280
 
277
281
  # Add custom parameter to the message. A custom parameter is any parameter that
@@ -1,4 +1,4 @@
1
1
  # It's the version. Yeay!
2
2
  module Mailgun
3
- VERSION = '1.2.3'
3
+ VERSION = '1.2.4'
4
4
  end
@@ -11,7 +11,7 @@ module Railgun
11
11
  class Mailer
12
12
 
13
13
  # List of the headers that will be ignored when copying headers from `mail.header_fields`
14
- IGNORED_HEADERS = %w[ to from subject reply-to ]
14
+ IGNORED_HEADERS = %w[ to from subject reply-to mime-version ]
15
15
 
16
16
  # [Hash] config ->
17
17
  # Requires *at least* `api_key` and `domain` keys.
@@ -2,8 +2,9 @@ require 'railgun/mailer'
2
2
 
3
3
  module Railgun
4
4
  class Railtie < ::Rails::Railtie
5
- config.before_configuration do
6
- ActionMailer::Base.add_delivery_method :mailgun, Railgun::Mailer
5
+ ActiveSupport.on_load(:action_mailer) do
6
+ add_delivery_method :mailgun, Railgun::Mailer
7
+ ActiveSupport.run_load_hooks(:mailgun_mailer, Railgun::Mailer)
7
8
  end
8
9
  end
9
10
  end
@@ -567,9 +567,13 @@ describe 'The method variable' do
567
567
  expect(@mb_obj.message["v:my-data"]).to be_kind_of(String)
568
568
  expect(@mb_obj.message["v:my-data"].to_s).to eq('{"key":"value"}')
569
569
  end
570
- it 'throws an exception on broken JSON.' do
571
- data = 'This is some crappy JSON.'
572
- expect {@mb_obj.variable('my-data', data)}.to raise_error(Mailgun::ParameterError)
570
+ it 'accepts string values' do
571
+ data = 'String Value.'
572
+
573
+ @mb_obj.variable('my-data', data)
574
+
575
+ expect(@mb_obj.message["v:my-data"]).to be_kind_of(String)
576
+ expect(@mb_obj.message["v:my-data"].to_s).to eq('String Value.')
573
577
  end
574
578
  end
575
579
 
@@ -191,6 +191,19 @@ describe 'Railgun::Mailer' do
191
191
  expect(body['h:reply-to']).to eq('dude@example.com.au')
192
192
  end
193
193
 
194
+ it 'ignores `mime-version` in headers' do
195
+ message = UnitTestMailer.plain_message('test@example.org', '', {
196
+ 'mime-version' => '1.0',
197
+ })
198
+ message.mailgun_headers = {
199
+ 'Mime-Version' => '1.1',
200
+ }
201
+ message.headers({'MIME-VERSION' => '1.2'})
202
+
203
+ body = Railgun.transform_for_mailgun(message)
204
+ expect(body).not_to include('h:mime-version')
205
+ end
206
+
194
207
  it 'treats `headers()` names as case-insensitve' do
195
208
  message = UnitTestMailer.plain_message('test@example.org', '', {
196
209
  'X-BIG-VALUE' => 1,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailgun-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mailgun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-02 00:00:00.000000000 Z
12
+ date: 2021-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler