Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:thoughtbot/hoptoad_notifier

  • Loading branch information...
commit 7220d02fe76578ce09f3d938556809497fca66b1 2 parents d621c00 + bf10c56
@jyurek jyurek authored
View
25 README.rdoc
@@ -26,7 +26,7 @@ Remove the vendor/plugins/exception_notifier directory.
from your project's RAILS_ROOT, run:
- script/plugin install git://github.com/thoughtbot/hoptoad_notifier.git
+ script/plugin install -f git://github.com/thoughtbot/hoptoad_notifier.git
=== Configuration
@@ -109,9 +109,9 @@ You can also pass a hash to notify_hoptoad method and store whatever you want, n
my_unpredicable_method(params)
rescue => e
HoptoadNotifier.notify(
- :error_class => "Special Error",
+ :error_class => "Special Error",
:error_message => "Special Error: #{e.message}",
- :request => { :params => params }
+ :parameters => params
)
end
@@ -119,19 +119,17 @@ While in your controllers you use the notify_hoptoad method, anywhere else in yo
* :error_class – Use this to group similar errors together. When Hoptoad catches an exception it sends the class name of that exception object.
* :error_message – This is the title of the error you see in the errors list. For exceptions it is "#{exception.class.name}: #{exception.message}"
-* :request – While there are several ways to send additional data to Hoptoad, passing a Hash with :params key as :request as in the example above is the most common use case. When Hoptoad catches an exception in a controller, the actual HTTP client request is being sent using this key.
+* :parameters – While there are several ways to send additional data to Hoptoad, passing a Hash as :parameters as in the example above is the most common use case. When Hoptoad catches an exception in a controller, the actual HTTP client request parameters are sent using this key.
Hoptoad merges the hash you pass with these default options:
- def default_notice_options
- {
- :api_key => HoptoadNotifier.api_key,
- :error_message => 'Notification',
- :backtrace => caller,
- :request => {},
- :session => {}
- }
- end
+ {
+ :api_key => HoptoadNotifier.api_key,
+ :error_message => 'Notification',
+ :backtrace => caller,
+ :parameters => {},
+ :session => {}
+ }
You can override any of those parameters.
@@ -215,6 +213,7 @@ the notifier currently supports the following versions of Rails:
* 1.2.6
* 2.0.2
+* 2.1.0
* 2.1.2
* 2.2.2
* 2.3.2
View
1  init.rb
@@ -0,0 +1 @@
+require File.join(File.dirname(__FILE__), 'rails', 'init')
View
2  lib/hoptoad_notifier.rb
@@ -11,7 +11,7 @@
# Plugin for applications to automatically post errors to the Hoptoad of their choice.
module HoptoadNotifier
- VERSION = "2.0.4"
+ VERSION = "2.0.8"
API_VERSION = "2.0"
LOG_PREFIX = "** [Hoptoad] "
View
10 lib/hoptoad_notifier/catcher.rb
@@ -57,7 +57,7 @@ def ignore_user_agent? #:nodoc:
def request_data_for_hoptoad
{ :parameters => filter_if_filtering(params.to_hash),
- :session_data => session.data,
+ :session_data => session_data,
:controller => params[:controller],
:action => params[:action],
:url => "#{request.protocol}#{request.host}#{request.request_uri}",
@@ -73,5 +73,13 @@ def filter_if_filtering(hash)
end
end
+ def session_data
+ if session.respond_to?(:to_hash)
+ session.to_hash
+ else
+ session.data
+ end
+ end
+
end
end
View
5 recipes/hoptoad.rb
@@ -11,10 +11,11 @@
namespace :deploy do
desc "Notify Hoptoad of the deployment"
- task :notify_hoptoad do
+ task :notify_hoptoad, :except => { :no_release => true } do
rails_env = fetch(:hoptoad_env, fetch(:rails_env, "production"))
local_user = ENV['USER'] || ENV['USERNAME']
- notify_command = "rake hoptoad:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
+ executable = RUBY_PLATFORM.downcase.include?('mswin') ? 'rake.bat' : 'rake'
+ notify_command = "#{executable} hoptoad:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
puts "Notifying Hoptoad of Deploy (#{notify_command})"
`#{notify_command}`
puts "Hoptoad Notification Complete."
View
31 test/catcher_test.rb
@@ -255,4 +255,35 @@ def process_action_with_automatic_notification(args = {})
end
end
+ should "call session.to_hash if available" do
+ hash_data = {:key => :value}
+
+ session = ActionController::TestSession.new
+ ActionController::TestSession.stubs(:new).returns(session)
+ session.stubs(:to_hash).returns(hash_data)
+
+ process_action_with_automatic_notification
+ assert_received(session, :to_hash)
+ assert_received(session, :data) { |expect| expect.never }
+ assert_caught_and_sent
+ end
+
+ should "call session.data if session.to_hash is undefined" do
+ hash_data = {:key => :value}
+
+ session = ActionController::TestSession.new
+ ActionController::TestSession.stubs(:new).returns(session)
+ session.stubs(:data).returns(hash_data)
+ if session.respond_to?(:to_hash)
+ class << session
+ undef to_hash
+ end
+ end
+
+ process_action_with_automatic_notification
+ assert_received(session, :to_hash) { |expect| expect.never }
+ assert_received(session, :data) { |expect| expect.at_least_once }
+ assert_caught_and_sent
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.