From d6ca96c7f3a36bed93ba879da7ce0fbc5b96e819 Mon Sep 17 00:00:00 2001 From: emill Date: Fri, 4 Apr 2008 19:29:37 +0000 Subject: [PATCH] Fixed bug related to refactoring of #ignore=, added InvalidAuthenticityToken error as a default ignored error class. git-svn-id: https://svn.thoughtbot.com/plugins/hoptoad_notifier/trunk@436 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa --- README | 1 + lib/hoptoad_notifier.rb | 4 ++-- test/hoptoad_notifier_test.rb | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README b/README index 7115d78..6bf98a6 100644 --- a/README +++ b/README @@ -76,6 +76,7 @@ notifications (when #notify is called directly). Hoptoad ignores the following exceptions by default: ActiveRecord::RecordNotFound CGI::Session::CookieStore::TamperedWithCookie + ActionController::InvalidAuthenticityToken To ignore errors in addition to those, specify their names in your Hoptoad configuration block. diff --git a/lib/hoptoad_notifier.rb b/lib/hoptoad_notifier.rb index 8be3cbe..b48c0a5 100644 --- a/lib/hoptoad_notifier.rb +++ b/lib/hoptoad_notifier.rb @@ -3,7 +3,7 @@ # Plugin for applications to automatically post errors to the Hoptoad of their choice. module HoptoadNotifier - IGNORE_DEFAULT = [ActiveRecord::RecordNotFound, CGI::Session::CookieStore::TamperedWithCookie] + IGNORE_DEFAULT = [ActiveRecord::RecordNotFound, CGI::Session::CookieStore::TamperedWithCookie, ActionController::InvalidAuthenticityToken] class << self attr_accessor :host, :port, :secure, :project_name, :filter_params, :ignore @@ -29,7 +29,7 @@ def ignore # Adds an error to the list of what gets ignored. def ignore=(names) - @ignore += names + @ignore = self.ignore + names end # Sets the list of ignored errors to only what is passed in here. This method diff --git a/test/hoptoad_notifier_test.rb b/test/hoptoad_notifier_test.rb index a751c2c..bce6d22 100644 --- a/test/hoptoad_notifier_test.rb +++ b/test/hoptoad_notifier_test.rb @@ -46,7 +46,7 @@ def manual_notify_ignored end class HoptoadNotifierTest < Test::Unit::TestCase - def request action = nil, method = :get + def request(action = nil, method = :get) @request = ActionController::TestRequest.new({ "controller" => "hoptoad", "action" => action ? action.to_s : "", @@ -74,12 +74,14 @@ def rescue_action e config.port = 3333 config.secure = true config.project_name = "bob" + config.ignore = [RuntimeError] end assert_equal "host", HoptoadNotifier.host assert_equal 3333, HoptoadNotifier.port assert_equal true, HoptoadNotifier.secure assert_equal "bob", HoptoadNotifier.project_name + assert_equal HoptoadNotifier::IGNORE_DEFAULT + [RuntimeError], HoptoadNotifier.ignore end should "add filters to the backtrace_filters" do