Permalink
Browse files

Fixed some incompatibilities with older versions of Rails

  • Loading branch information...
1 parent 6a373ee commit 95e42df57b38a5aad0a5ef106f3637b6fabb0c04 Joe Ferris committed Nov 16, 2009
Showing with 15 additions and 13 deletions.
  1. +8 −7 lib/hoptoad_notifier/catcher.rb
  2. +7 −6 test/catcher_test.rb
@@ -27,14 +27,15 @@ def rescue_action_locally_with_hoptoad(exception)
result = rescue_action_locally_without_hoptoad(exception)
if HoptoadNotifier.configuration.development_lookup
- path = "#{File.dirname(File.dirname(__FILE__))}/templates/rescue.erb"
+ path = File.join(File.dirname(__FILE__), '..', 'templates', 'rescue.erb')
notice = HoptoadNotifier.build_lookup_hash_for(exception, request_data_for_hoptoad)
result << @template.render(
- :file => path,
- :locals => { :host => HoptoadNotifier.configuration.host,
- :api_key => HoptoadNotifier.configuration.api_key,
- :notice => notice })
+ :file => path,
+ :use_full_path => false,
+ :locals => { :host => HoptoadNotifier.configuration.host,
+ :api_key => HoptoadNotifier.configuration.api_key,
+ :notice => notice })
end
result
@@ -56,10 +57,10 @@ def ignore_user_agent? #:nodoc:
def request_data_for_hoptoad
{ :parameters => filter_if_filtering(params.to_hash),
- :session_data => session.to_hash,
+ :session_data => session.data,
:controller => params[:controller],
:action => params[:action],
- :url => request.url,
+ :url => "#{request.protocol}#{request.host}#{request.request_uri}",
:cgi_data => filter_if_filtering(request.env),
:environment_vars => filter_if_filtering(ENV) }
end
View
@@ -8,6 +8,7 @@ def setup
super
reset_config
HoptoadNotifier.sender = CollectingSender.new
+ define_constant('RAILS_ROOT', '/path/to/rails/root')
end
def ignore(exception_class)
@@ -38,11 +39,12 @@ def assert_sent_element(value, xpath)
end
def assert_sent_request_info_for(request)
- params = request.params.to_hash
+ params = request.parameters.to_hash
assert_sent_hash params, '/notice/request/params'
assert_sent_element params['controller'], '/notice/request/component'
assert_sent_element params['action'], '/notice/request/action'
- assert_sent_element request.url, '/notice/request/url'
+ assert_sent_element "#{request.protocol}#{request.host}#{request.request_uri}",
+ '/notice/request/url'
assert_sent_hash request.env, '/notice/request/cgi-data'
end
@@ -84,8 +86,7 @@ def local_request?
controller = klass.new
controller.stubs(:rescue_action_in_public_without_hoptoad)
opts[:request].query_parameters = opts[:request].query_parameters.merge(opts[:params] || {})
- opts[:request].session.clear
- opts[:request].session.merge!(opts[:session] || {})
+ opts[:request].session = ActionController::TestSession.new(opts[:session] || {})
controller.process(opts[:request], opts[:response])
controller
end
@@ -192,13 +193,13 @@ def process_action_with_automatic_notification(args = {})
end
should "send request data for manual notification" do
- params = { 'controller' => "users", 'action' => "create" }
+ params = { 'controller' => "hoptoad_test", 'action' => "index" }
controller = process_action_with_manual_notification(:params => params)
assert_sent_request_info_for controller.request
end
should "send request data for automatic notification" do
- params = { 'controller' => "users", 'action' => "create" }
+ params = { 'controller' => "hoptoad_test", 'action' => "index" }
controller = process_action_with_automatic_notification(:params => params)
assert_sent_request_info_for controller.request
end

0 comments on commit 95e42df

Please sign in to comment.