-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mailgun 1.2.4 (#229) * 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> * DE-87: railgun tests Co-authored-by: Lukas Barry <LukasBBarry@gmail.com>
- Loading branch information
1 parent
30479e9
commit 641411a
Showing
4 changed files
with
379 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require 'spec_helper' | ||
require 'json' | ||
require 'logger' | ||
require 'railgun' | ||
require 'mailgun' | ||
require 'mailgun/exceptions/exceptions' | ||
|
||
ActionMailer::Base.raise_delivery_errors = true | ||
Rails.logger = Logger.new('/dev/null') | ||
Rails.logger.level = Logger::DEBUG | ||
|
||
class UnitTestMailer < ActionMailer::Base | ||
default from: 'unittest@example.org' | ||
|
||
def plain_message(address, from, subject, headers) | ||
headers(headers) | ||
mail(to: address, from: from, subject: subject) do |format| | ||
format.text { render plain: 'Test!' } | ||
format.html { render html: '<p>Test!</p>'.html_safe } | ||
end | ||
end | ||
end | ||
|
||
vcr_opts = { :cassette_name => 'message_deliver' } | ||
|
||
describe 'Message deliver', vcr: vcr_opts do | ||
let(:domain) { TESTDOMAIN } | ||
let(:config) do | ||
{ | ||
api_key: APIKEY, | ||
domain: domain | ||
} | ||
end | ||
let(:mail) { UnitTestMailer.plain_message("bob@#{domain}", "bob@#{domain}", 'subject', {}) } | ||
|
||
it 'successfully delivers message' do | ||
result = Railgun::Mailer.new(config).deliver!(mail) | ||
result.to_h! | ||
|
||
expect(result.body['message']).to eq('Queued. Thank you.') | ||
expect(result.body).to include('id') | ||
expect(result.code).to eq(200) | ||
end | ||
end | ||
|
||
vcr_opts = { :cassette_name => 'mailer_invalid_domain' } | ||
|
||
describe 'Invalid domain', vcr: vcr_opts do | ||
let(:domain) { 'not-our-doma.in' } | ||
let(:config) do | ||
{ | ||
api_key: APIKEY, | ||
domain: domain | ||
} | ||
end | ||
let(:mail) { UnitTestMailer.plain_message("bob@#{domain}", 'sally@not-our-doma.in' 'subject', {}) } | ||
|
||
it 'raises expected error' do | ||
|
||
Railgun::Mailer.new(config).deliver!(mail) | ||
rescue Mailgun::CommunicationError => err | ||
expect(err.message).to eq('401 Unauthorized: Forbidden - Invalid Domain or API key') | ||
else | ||
fail | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.