Skip to content

Commit

Permalink
mailgun 1.2.4 (#229)
Browse files Browse the repository at this point in the history
* DE-73: default content-type (#216)

* DE-73: default content-type

* DE-73: refactor

* DE-62: reset recipient_variables (#218)

* DE-64: set single track opens-clicks (#219)

* DE-67: accept frozen mailgun options to message body (#221)

* DE-71: fix parse addres when full_name is nil (#222)

* update gem version

* fixes batch add unsubscribes and adds test (#187)

* update version to 1.2.3

* DE-56: ignore mime-version header (#225)

* DE-53: allow string values in custom variables (#226)

* DE-86: update mailgun rails load (#227)

* DE-81: fail if domain is missing (#228)

* update version to 1.2.4

Co-authored-by: Lukas Barry <LukasBBarry@gmail.com>
  • Loading branch information
Petro Smachylo and LukasBarry authored Apr 5, 2021
1 parent e8717b3 commit 51ac3ed
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gem install mailgun-ruby
Gemfile:

```ruby
gem 'mailgun-ruby', '~>1.2.3'
gem 'mailgun-ruby', '~>1.2.4'
```

Usage
Expand Down
2 changes: 2 additions & 0 deletions lib/mailgun/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def self.deliveries
# containing required parameters for the requested resource.
# @return [Mailgun::Response] A Mailgun::Response object.
def send_message(working_domain, data)
fail ParameterError.new('Missing working domain', working_domain) unless working_domain

if test_mode? then
Mailgun::Client.deliveries << data
return Response.from_hash(
Expand Down
8 changes: 6 additions & 2 deletions lib/mailgun/messages/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,12 @@ def set_custom_data(name, data)
# @return [void]
def variable(name, data)
fail(Mailgun::ParameterError, 'Variable name must be specified') if name.to_s.empty?
jsondata = make_json data
set_single("v:#{name}", jsondata)
begin
jsondata = make_json data
set_single("v:#{name}", jsondata)
rescue Mailgun::ParameterError
set_single("v:#{name}", data)
end
end

# Add custom parameter to the message. A custom parameter is any parameter that
Expand Down
2 changes: 1 addition & 1 deletion lib/mailgun/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# It's the version. Yeay!
module Mailgun
VERSION = '1.2.3'
VERSION = '1.2.4'
end
2 changes: 1 addition & 1 deletion lib/railgun/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Railgun
class Mailer

# List of the headers that will be ignored when copying headers from `mail.header_fields`
IGNORED_HEADERS = %w[ to from subject reply-to ]
IGNORED_HEADERS = %w[ to from subject reply-to mime-version ]

# [Hash] config ->
# Requires *at least* `api_key` and `domain` keys.
Expand Down
5 changes: 3 additions & 2 deletions lib/railgun/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

module Railgun
class Railtie < ::Rails::Railtie
config.before_configuration do
ActionMailer::Base.add_delivery_method :mailgun, Railgun::Mailer
ActiveSupport.on_load(:action_mailer) do
add_delivery_method :mailgun, Railgun::Mailer
ActiveSupport.run_load_hooks(:mailgun_mailer, Railgun::Mailer)
end
end
end
10 changes: 7 additions & 3 deletions spec/unit/messages/message_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,13 @@
expect(@mb_obj.message["v:my-data"]).to be_kind_of(String)
expect(@mb_obj.message["v:my-data"].to_s).to eq('{"key":"value"}')
end
it 'throws an exception on broken JSON.' do
data = 'This is some crappy JSON.'
expect {@mb_obj.variable('my-data', data)}.to raise_error(Mailgun::ParameterError)
it 'accepts string values' do
data = 'String Value.'

@mb_obj.variable('my-data', data)

expect(@mb_obj.message["v:my-data"]).to be_kind_of(String)
expect(@mb_obj.message["v:my-data"].to_s).to eq('String Value.')
end
end

Expand Down
13 changes: 13 additions & 0 deletions spec/unit/railgun/mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,19 @@ def message_with_attachment(address, subject)
expect(body['h:reply-to']).to eq('dude@example.com.au')
end

it 'ignores `mime-version` in headers' do
message = UnitTestMailer.plain_message('test@example.org', '', {
'mime-version' => '1.0',
})
message.mailgun_headers = {
'Mime-Version' => '1.1',
}
message.headers({'MIME-VERSION' => '1.2'})

body = Railgun.transform_for_mailgun(message)
expect(body).not_to include('h:mime-version')
end

it 'treats `headers()` names as case-insensitve' do
message = UnitTestMailer.plain_message('test@example.org', '', {
'X-BIG-VALUE' => 1,
Expand Down

0 comments on commit 51ac3ed

Please sign in to comment.