Permalink
Browse files

Prepend view path on background notifications. Fixes #68.

  • Loading branch information...
1 parent 5db75e7 commit 41562cc59592bf8b961aa0097af1d5420eda880a @smartinez87 committed Apr 20, 2012
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- exception_notification (2.5.2)
+ exception_notification (2.6.0)
actionmailer (>= 3.0.4)
GEM
@@ -46,7 +46,7 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
- multi_json (1.2.0)
+ multi_json (1.3.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -77,13 +77,13 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
+ sqlite3 (1.3.6)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.32)
+ tzinfo (0.3.33)
PLATFORMS
ruby
@@ -89,6 +89,8 @@ def exception_notification(env, exception, options={})
end
def background_exception_notification(exception, options={})
+ self.append_view_path Rails.root.nil? ? "app/views" : "#{Rails.root}/app/views" if defined?(Rails)
@yfeldblum

yfeldblum Apr 23, 2012

Prefer Rails.configuration.paths["app/views"] to "app/views".

+
if @notifier = Rails.application.config.middleware.detect{ |x| x.klass == ExceptionNotifier }
@options = (@notifier.args.first || {}).reverse_merge(self.class.default_options)
@exception = exception
@@ -0,0 +1 @@
+* New background section for testing
@@ -5,7 +5,8 @@
:email_prefix => "[Dummy ERROR] ",
:sender_address => %{"Dummy Notifier" <dummynotifier@example.com>},
:exception_recipients => %w{dummyexceptions@example.com},
- :sections => ['new_section', 'request', 'session', 'environment', 'backtrace']
+ :sections => ['new_section', 'request', 'session', 'environment', 'backtrace'],
+ :background_sections => %w(new_bkg_section) + ExceptionNotifier::Notifier.default_background_sections
# Initialize the rails application
Dummy::Application.initialize!
@@ -165,3 +165,19 @@ class PostsControllerTestBadRequestData < ActionController::TestCase
assert_match /ERROR: Failed to generate exception summary/, @mail.body.to_s
end
end
+
+class PostsControllerTestBackgroundNotification < ActionController::TestCase
+ tests PostsController
+ setup do
+ begin
+ @post = posts(:one)
+ post :create, :post => @post.attributes
+ rescue => exception
+ @mail = ExceptionNotifier::Notifier.background_exception_notification(exception)
+ end
+ end
+
+ test "mail should contain the specified section" do
+ assert @mail.body.include? "* New background section for testing"
+ end
+end
@@ -20,7 +20,9 @@ class ExceptionNotificationTest < ActiveSupport::TestCase
end
test "should have default background sections" do
- assert ExceptionNotifier::Notifier.default_background_sections == %w(backtrace data)
+ for section in %w(backtrace data)
+ assert ExceptionNotifier::Notifier.default_background_sections.include? section
+ end
end
test "should have verbose subject by default" do

0 comments on commit 41562cc

Please sign in to comment.