Skip to content

Commit

Permalink
Merge ee230ac into f9dee5b
Browse files Browse the repository at this point in the history
  • Loading branch information
eitoball committed Jan 17, 2015
2 parents f9dee5b + ee230ac commit bba073d
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -9,3 +9,4 @@ gemfile:
- gemfiles/rails3_2.gemfile
- gemfiles/rails4_0.gemfile
- gemfiles/rails4_1.gemfile
- gemfiles/rails4_2.gemfile
4 changes: 4 additions & 0 deletions Appraisals
Expand Up @@ -13,3 +13,7 @@ end
appraise "rails4_1" do
gem 'rails', '~> 4.1.1'
end

appraise "rails4_2" do
gem 'rails', '~> 4.2.0'
end
26 changes: 16 additions & 10 deletions Gemfile.lock
Expand Up @@ -46,14 +46,14 @@ GEM
addressable
celluloid (0.15.2)
timers (~> 1.1.0)
colorize (0.5.8)
connection_pool (2.0.0)
coveralls (0.6.5)
colorize
coveralls (0.7.1)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
docile (1.1.5)
erubis (2.7.0)
eventmachine (1.0.3)
faraday (0.8.7)
Expand Down Expand Up @@ -82,6 +82,7 @@ GEM
multi_json (1.10.1)
multi_xml (0.5.5)
multipart-post (1.2.0)
netrc (0.10.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
Expand Down Expand Up @@ -114,25 +115,29 @@ GEM
resque (1.2.3)
redis
redis-namespace
rest-client (1.6.7)
mime-types (>= 1.16)
rest-client (1.7.2)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
sidekiq (3.0.0)
celluloid (>= 0.15.2)
connection_pool (>= 2.0.0)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
simple_oauth (0.1.9)
simplecov (0.7.1)
simplecov (0.9.1)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slack-notifier (1.0.0)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.15.4)
tilt (1.3.3)
timers (1.1.0)
Expand All @@ -146,6 +151,7 @@ GEM
multi_json (~> 1.0)
multipart-post (~> 1.1)
twitter-stream (~> 0.1)
tins (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
Expand All @@ -161,14 +167,14 @@ PLATFORMS
DEPENDENCIES
appraisal (~> 1.0.0)
carrier-pigeon (>= 0.7.0)
coveralls (~> 0.6.5)
coveralls (= 0.7.1)
exception_notification!
hipchat (>= 1.0.0)
httparty (~> 0.10.2)
mocha (>= 0.13.0)
rails (>= 3.0.4)
resque (~> 1.2.0)
sidekiq (~> 3.0)
sidekiq (~> 3.0.0, < 3.2.2)
slack-notifier (>= 1.0.0)
sqlite3 (>= 1.3.4)
tinder (~> 1.8)
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -276,6 +276,13 @@ A complete list of `smtp_settings` options can be found in the [ActionMailer Con
The parent mailer which ExceptionNotification mailer inherit from.


##### deliver_with

*Symbol, default: :deliver

The method name to send emalis using ActionMailer.


### Campfire notifier

This notifier sends notifications to your Campfire room.
Expand Down
8 changes: 6 additions & 2 deletions exception_notification.gemspec
Expand Up @@ -21,12 +21,16 @@ Gem::Specification.new do |s|

s.add_development_dependency "rails", ">= 3.0.4"
s.add_development_dependency "resque", "~> 1.2.0"
s.add_development_dependency "sidekiq", "~> 3.0"
# Sidekiq 3.2.2 does not support Ruby 1.9.
s.add_development_dependency "sidekiq", "~> 3.0.0", "< 3.2.2"
s.add_development_dependency "tinder", "~> 1.8"
s.add_development_dependency "httparty", "~> 0.10.2"
s.add_development_dependency "mocha", ">= 0.13.0"
s.add_development_dependency "sqlite3", ">= 1.3.4"
s.add_development_dependency "coveralls", "~> 0.6.5"
# coveralls version 0.7.2 depends thor version to 0.18.1,
# but rails 3.1 depends thor 0.14, so coveralls 0.7.1 is
# used here.
s.add_development_dependency "coveralls", "0.7.1"
s.add_development_dependency "appraisal", "~> 1.0.0"
s.add_development_dependency "hipchat", ">= 1.0.0"
s.add_development_dependency "carrier-pigeon", ">= 0.7.0"
Expand Down
7 changes: 7 additions & 0 deletions gemfiles/rails4_2.gemfile
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 4.2.0"

gemspec :path => "../"
9 changes: 5 additions & 4 deletions lib/exception_notifier/email_notifier.rb
Expand Up @@ -7,7 +7,7 @@ module ExceptionNotifier
class EmailNotifier < Struct.new(:sender_address, :exception_recipients,
:email_prefix, :email_format, :sections, :background_sections,
:verbose_subject, :normalize_subject, :delivery_method, :mailer_settings,
:email_headers, :mailer_parent, :template_path)
:email_headers, :mailer_parent, :template_path, :deliver_with)

module Mailer
class MissingController
Expand Down Expand Up @@ -129,7 +129,7 @@ def initialize(options)
:sender_address, :exception_recipients,
:email_prefix, :email_format, :sections, :background_sections,
:verbose_subject, :normalize_subject, :delivery_method, :mailer_settings,
:email_headers, :mailer_parent, :template_path))
:email_headers, :mailer_parent, :template_path, :deliver_with))
end

def options
Expand All @@ -146,7 +146,7 @@ def mailer
end

def call(exception, options={})
create_email(exception, options).deliver
create_email(exception, options).send(deliver_with)
end

def create_email(exception, options={})
Expand All @@ -173,7 +173,8 @@ def self.default_options
:mailer_settings => nil,
:email_headers => {},
:mailer_parent => 'ActionMailer::Base',
:template_path => 'exception_notifier'
:template_path => 'exception_notifier',
:deliver_with => :deliver
}
end

Expand Down
25 changes: 24 additions & 1 deletion test/exception_notifier/email_notifier_test.rb
Expand Up @@ -95,7 +95,7 @@ class EmailNotifierTest < ActiveSupport::TestCase
end

test "mail should have a descriptive subject" do
assert @mail.subject == "[Dummy ERROR] (ZeroDivisionError) \"divided by 0\""
assert unfold(@mail.subject) == unfold("[Dummy ERROR] (ZeroDivisionError) \"divided by 0\"")
end

test "mail should say exception was raised in background at show timestamp" do
Expand Down Expand Up @@ -141,4 +141,27 @@ class EmailNotifierTest < ActiveSupport::TestCase
assert @ignored_exception.class.inspect == "ActiveRecord::RecordNotFound"
assert_nil @ignored_mail
end

if defined?(Rails) && ('4.2'...'5.0').cover?(Rails.version)
test "should be able to specify ActionMailer::MessageDelivery method" do
email_notifier = ExceptionNotifier::EmailNotifier.new(
:email_prefix => '[Dummy ERROR] ',
:sender_address => %{"Dummy Notifier" <dummynotifier@example.com>},
:exception_recipients => %w{dummyexceptions@example.com},
:deliver_with => :deliver_now
)
# In Rails 4.2, it gives deprecation warning like "`#deliver` is
# deprecated and will be removed in Rails 5." when "#deliver" is
# used. If methods like "#deliver_now" is used, it should not
# give any warnings.
assert_silent do
email_notifier.call(@exception)
end
end
end

# shamelessly copied from Mail::Field in mikel/mail
def unfold(string)
string.gsub(/[\r\n \t]+/m, ' ')
end
end

0 comments on commit bba073d

Please sign in to comment.