exception_notification 1.0.20090728 → 2.3.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -17,13 +17,13 @@ First, include the ExceptionNotifiable mixin in whichever controller you want
17
17
  to generate error emails (typically ApplicationController):
18
18
 
19
19
  class ApplicationController < ActionController::Base
20
- include ExceptionNotifiable
20
+ include ExceptionNotification::Notifiable
21
21
  ...
22
22
  end
23
23
 
24
24
  Then, specify the email recipients in your environment:
25
25
 
26
- ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com)
26
+ ExceptionNotification::Notifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com)
27
27
 
28
28
  And that's it! The defaults take care of the rest.
29
29
 
@@ -33,11 +33,20 @@ You can tweak other values to your liking, as well. In your environment file,
33
33
  just set any or all of the following values:
34
34
 
35
35
  # defaults to exception.notifier@default.com
36
- ExceptionNotifier.sender_address =
36
+ ExceptionNotification::Notifier.sender_address =
37
37
  %("Application Error" <app.error@myapp.com>)
38
38
 
39
39
  # defaults to "[ERROR] "
40
- ExceptionNotifier.email_prefix = "[APP] "
40
+ ExceptionNotification::Notifier.email_prefix = "[APP] "
41
+
42
+ Even if you have mixed into ApplicationController you can skip notification in
43
+ some controllers by
44
+
45
+ class MyController < ApplicationController
46
+ skip_exception_notifications
47
+ end
48
+
49
+ == Deprecated local_request? overriding
41
50
 
42
51
  Email notifications will only occur when the IP address is determined not to
43
52
  be local. You can specify certain addresses to always be local so that you'll
@@ -57,6 +66,19 @@ NOT be considered local), you can simply do, somewhere in your controller:
57
66
 
58
67
  local_addresses.clear
59
68
 
69
+ NOTE: The above functionality has has been pulled out to consider_local.rb,
70
+ as interfering with rails local determination is orthogonal to notification,
71
+ unnecessarily clutters backtraces, and even occasionally errs on odd ip or
72
+ requests bugs. To return original functionality add an initializer with:
73
+
74
+ ActionController::Base.send :include, ConsiderLocal
75
+
76
+ or just include it per controller that wants it
77
+
78
+ class MyController < ApplicationController
79
+ include ExceptionNotification::ConsiderLocal
80
+ end
81
+
60
82
  == Customization
61
83
 
62
84
  By default, the notification email includes four parts: request, session,
@@ -75,7 +97,7 @@ access to the following variables:
75
97
  * @sections: the array of sections to include in the email
76
98
 
77
99
  You can reorder the sections, or exclude sections completely, by altering the
78
- ExceptionNotifier.sections variable. You can even add new sections that
100
+ ExceptionNotification::Notifier.sections variable. You can even add new sections that
79
101
  describe application-specific data--just add the section's name to the list
80
102
  (whereever you'd like), and define the corresponding partial. Then, if your
81
103
  new section requires information that isn't available by default, make sure
@@ -97,16 +119,22 @@ In the above case, @document and @person would be made available to the email
97
119
  renderer, allowing your new section(s) to access and display them. See the
98
120
  existing sections defined by the plugin for examples of how to write your own.
99
121
 
100
- == Advanced Customization
122
+ == 404s errors
123
+
124
+ Notification is skipped if you return a 404 status, which happens by default
125
+ for an ActiveRecord::RecordNotFound or ActionController::UnknownAction error.
101
126
 
102
- By default, the email notifier will only notify on critical errors. For
103
- ActiveRecord::RecordNotFound and ActionController::UnknownAction, it will
104
- simply render the contents of your public/404.html file. Other exceptions
105
- will render public/500.html and will send the email notification. If you want
106
- to use different rules for the notification, you will need to implement your
107
- own rescue_action_in_public method. You can look at the default implementation
108
- in ExceptionNotifiable for an example of how to go about that.
127
+ == Manually notifying of error in a rescue block
109
128
 
129
+ If your controller action manually handles an error, the notifier will never be
130
+ run. To manually notify of an error call notify_about_exception from within the
131
+ rescue block
132
+
133
+ def index
134
+ #risky operation here
135
+ rescue StandardError => error
136
+ #custom error handling here
137
+ notify_about_exception(error)
138
+ end
110
139
 
111
- Copyright (c) 2005 Jamis Buck, released under the MIT license
112
- Copyright (c) 2008-2009 Jeremy Evans
140
+ Copyright (c) 2005 Jamis Buck, released under the MIT license
@@ -1,2 +1,7 @@
1
- require 'exception_notifiable'
2
- require 'exception_notifier'
1
+ require "action_mailer"
2
+ module ExceptionNotification
3
+ autoload :Notifiable, 'exception_notification/notifiable'
4
+ autoload :Notifier, 'exception_notification/notifier'
5
+ #autoload :NotifierHelper, 'exception_notification/notifier_helper'
6
+ autoload :ConsiderLocal, 'exception_notification/consider_local'
7
+ end
@@ -0,0 +1,31 @@
1
+ #This didn't belong on ExceptionNotifier and made backtraces worse. To keep original functionality in place
2
+ #'ActionController::Base.send :include, ExceptionNotification::ConsiderLocal' or just include in your controller
3
+ module ExceptionNotification::ConsiderLocal
4
+ module ClassMethods
5
+ def self.included(target)
6
+ require 'ipaddr'
7
+ target.extend(ClassMethods)
8
+ end
9
+
10
+ def consider_local(*args)
11
+ local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) })
12
+ end
13
+
14
+ def local_addresses
15
+ addresses = read_inheritable_attribute(:local_addresses)
16
+ unless addresses
17
+ addresses = [IPAddr.new("127.0.0.1")]
18
+ write_inheritable_attribute(:local_addresses, addresses)
19
+ end
20
+ addresses
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def local_request?
27
+ remote = IPAddr.new(request.remote_ip)
28
+ !self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil?
29
+ end
30
+
31
+ end
@@ -0,0 +1,66 @@
1
+ # Copyright (c) 2005 Jamis Buck
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ module ExceptionNotification::Notifiable
22
+ def self.included(target)
23
+ target.extend(ClassMethods)
24
+ target.skip_exception_notifications false
25
+ end
26
+
27
+ module ClassMethods
28
+ def exception_data(deliverer=self)
29
+ if deliverer == self
30
+ read_inheritable_attribute(:exception_data)
31
+ else
32
+ write_inheritable_attribute(:exception_data, deliverer)
33
+ end
34
+ end
35
+
36
+ def skip_exception_notifications(boolean=true)
37
+ write_inheritable_attribute(:skip_exception_notifications, boolean)
38
+ end
39
+
40
+ def skip_exception_notifications?
41
+ read_inheritable_attribute(:skip_exception_notifications)
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def rescue_action_in_public(exception)
48
+ super
49
+ notify_about_exception(exception) if deliver_exception_notification?
50
+ end
51
+
52
+ def deliver_exception_notification?
53
+ !self.class.skip_exception_notifications? && ![404, "404 Not Found"].include?(response.status)
54
+ end
55
+
56
+ def notify_about_exception(exception)
57
+ deliverer = self.class.exception_data
58
+ data = case deliverer
59
+ when nil then {}
60
+ when Symbol then send(deliverer)
61
+ when Proc then deliverer.call(self)
62
+ end
63
+
64
+ ExceptionNotification::Notifier.deliver_exception_notification(exception, self, request, data)
65
+ end
66
+ end
@@ -20,7 +20,10 @@ require 'pathname'
20
20
  # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- class ExceptionNotifier < ActionMailer::Base
23
+ class ExceptionNotification::Notifier < ActionMailer::Base
24
+ self.mailer_name = 'exception_notifier'
25
+ self.view_paths << "#{File.dirname(__FILE__)}/../../views"
26
+
24
27
  @@sender_address = %("Exception Notifier" <exception.notifier@default.com>)
25
28
  cattr_accessor :sender_address
26
29
 
@@ -33,34 +36,40 @@ class ExceptionNotifier < ActionMailer::Base
33
36
  @@sections = %w(request session environment backtrace)
34
37
  cattr_accessor :sections
35
38
 
36
- self.template_root = "#{File.dirname(__FILE__)}/../views"
37
-
38
39
  def self.reloadable?() false end
39
40
 
40
41
  def exception_notification(exception, controller, request, data={})
42
+ source = self.class.exception_source(controller)
41
43
  content_type "text/plain"
42
44
 
43
- subject "#{email_prefix}#{controller.controller_name}##{controller.action_name} (#{exception.class}) #{exception.message.inspect}"
45
+ subject "#{email_prefix}#{source} (#{exception.class}) #{exception.message.inspect}"
44
46
 
45
47
  recipients exception_recipients
46
48
  from sender_address
47
49
 
48
50
  body data.merge({ :controller => controller, :request => request,
49
- :exception => exception, :host => (request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"]),
51
+ :exception => exception, :exception_source => source, :host => (request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"]),
50
52
  :backtrace => sanitize_backtrace(exception.backtrace),
51
53
  :rails_root => rails_root, :data => data,
52
54
  :sections => sections })
53
55
  end
54
56
 
55
- private
56
-
57
- def sanitize_backtrace(trace)
58
- re = Regexp.new(/^#{Regexp.escape(rails_root)}/)
59
- trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }
57
+ def self.exception_source(controller)
58
+ if controller.respond_to?(:controller_name)
59
+ "in #{controller.controller_name}##{controller.action_name}"
60
+ else
61
+ "outside of a controller"
60
62
  end
63
+ end
61
64
 
62
- def rails_root
63
- @rails_root ||= Pathname.new(RAILS_ROOT).cleanpath.to_s
64
- end
65
+ private
65
66
 
67
+ def sanitize_backtrace(trace)
68
+ re = Regexp.new(/^#{Regexp.escape(rails_root)}/)
69
+ trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }
70
+ end
71
+
72
+ def rails_root
73
+ @rails_root ||= Pathname.new(RAILS_ROOT).cleanpath.to_s
74
+ end
66
75
  end
@@ -20,32 +20,20 @@ require 'pp'
20
20
  # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- module ExceptionNotifierHelper
24
- VIEW_PATH = "views/exception_notifier"
25
- APP_PATH = "#{RAILS_ROOT}/app/#{VIEW_PATH}"
23
+ module ExceptionNotification::NotifierHelper
26
24
  PARAM_FILTER_REPLACEMENT = "[FILTERED]"
27
25
 
28
26
  def render_section(section)
29
27
  RAILS_DEFAULT_LOGGER.info("rendering section #{section.inspect}")
30
- summary = render_overridable(section).strip
28
+ summary = render("exception_notifier/#{section}").strip
31
29
  unless summary.blank?
32
- title = render_overridable(:title, :locals => { :title => section }).strip
30
+ title = render("exception_notifier/title", :locals => { :title => section }).strip
33
31
  "#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
34
32
  end
35
33
  end
36
34
 
37
- def render_overridable(partial, options={})
38
- if File.exist?(path = "#{APP_PATH}/_#{partial}.rhtml")
39
- render(options.merge(:file => path, :use_full_path => false))
40
- elsif File.exist?(path = "#{File.dirname(__FILE__)}/../#{VIEW_PATH}/_#{partial}.rhtml")
41
- render(options.merge(:file => path, :use_full_path => false))
42
- else
43
- ""
44
- end
45
- end
46
-
47
35
  def inspect_model_object(model, locals={})
48
- render_overridable(:inspect_model,
36
+ render('exception_notifier/inspect_model',
49
37
  :locals => { :inspect_model => model,
50
38
  :show_instance_variables => true,
51
39
  :show_attributes => true }.merge(locals))
@@ -67,12 +55,13 @@ module ExceptionNotifierHelper
67
55
  end
68
56
 
69
57
  def filter_sensitive_post_data_parameters(parameters)
70
- exclude_raw_post_parameters? ? @controller.send(:filter_parameters, parameters) : parameters
58
+ exclude_raw_post_parameters? ? @controller.__send__(:filter_parameters, parameters) : parameters
71
59
  end
72
60
 
73
61
  def filter_sensitive_post_data_from_env(env_key, env_value)
74
62
  return env_value unless exclude_raw_post_parameters?
75
63
  return PARAM_FILTER_REPLACEMENT if (env_key =~ /RAW_POST_DATA/i)
76
- return @controller.send(:filter_parameters, {env_key => env_value}).values[0]
64
+ return @controller.__send__(:filter_parameters, {env_key => env_value}).values[0]
77
65
  end
66
+
78
67
  end
@@ -4,4 +4,4 @@
4
4
  <% end -%>
5
5
 
6
6
  * Process: <%= $$ %>
7
- * Server : <%= Socket.gethostname %>
7
+ * Server : <%= `hostname -s`.chomp %>
@@ -1 +1,2 @@
1
- * session: <%= @request.session.inspect %>
1
+ * session id: <%= @request.session_options[:id] %>
2
+ * data: <%= @request.session.inspect %>
@@ -1,4 +1,4 @@
1
- A <%= @exception.class %> occurred in <%= @controller.controller_name %>#<%= @controller.action_name %>:
1
+ A <%= @exception.class %> occurred <%= @exception_source %>:
2
2
 
3
3
  <%= @exception.message %>
4
4
  <%= @backtrace.first %>
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.20090728
4
+ version: 2.3.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Rails Core Team
7
+ - Jamis Buck
8
+ - Josh Peek
9
+ - Tim Connor
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
13
 
12
- date: 2009-07-28 00:00:00 +02:00
14
+ date: 2010-03-13 00:00:00 -08:00
13
15
  default_executable:
14
16
  dependencies: []
15
17
 
16
18
  description:
17
- email: code@jeremyevans.net
19
+ email: timocratic@gmail.com
18
20
  executables: []
19
21
 
20
22
  extensions: []
21
23
 
22
- extra_rdoc_files:
23
- - README
24
+ extra_rdoc_files: []
25
+
24
26
  files:
25
- - lib/exception_notifiable.rb
26
- - lib/exception_notification.rb
27
- - lib/exception_notifier.rb
28
- - lib/exception_notifier_helper.rb
29
- - rails/init.rb
30
27
  - README
31
- - test/exception_notifier_helper_test.rb
32
- - test/test_helper.rb
28
+ - lib/exception_notification/consider_local.rb
29
+ - lib/exception_notification/notifiable.rb
30
+ - lib/exception_notification/notifier.rb
31
+ - lib/exception_notification/notifier_helper.rb
32
+ - lib/exception_notification.rb
33
33
  - views/exception_notifier/_backtrace.rhtml
34
34
  - views/exception_notifier/_environment.rhtml
35
35
  - views/exception_notifier/_inspect_model.rhtml
@@ -38,13 +38,12 @@ files:
38
38
  - views/exception_notifier/_title.rhtml
39
39
  - views/exception_notifier/exception_notification.rhtml
40
40
  has_rdoc: true
41
- homepage: http://github.com/jeremyevans/exception_notification
41
+ homepage:
42
42
  licenses: []
43
43
 
44
44
  post_install_message:
45
- rdoc_options:
46
- - --main
47
- - README
45
+ rdoc_options: []
46
+
48
47
  require_paths:
49
48
  - lib
50
49
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -65,7 +64,6 @@ rubyforge_project:
65
64
  rubygems_version: 1.3.5
66
65
  signing_key:
67
66
  specification_version: 3
68
- summary: Gemified exception_notification rails plugin, compatible with Rails 2.3
69
- test_files:
70
- - test/exception_notifier_helper_test.rb
71
- - test/test_helper.rb
67
+ summary: Exception notification by email for Rails apps - 2.3-stable compatible version
68
+ test_files: []
69
+
@@ -1,98 +0,0 @@
1
- require 'ipaddr'
2
-
3
- # Copyright (c) 2005 Jamis Buck
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining
6
- # a copy of this software and associated documentation files (the
7
- # "Software"), to deal in the Software without restriction, including
8
- # without limitation the rights to use, copy, modify, merge, publish,
9
- # distribute, sublicense, and/or sell copies of the Software, and to
10
- # permit persons to whom the Software is furnished to do so, subject to
11
- # the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be
14
- # included in all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- module ExceptionNotifiable
24
- def self.included(target)
25
- target.extend(ClassMethods)
26
- end
27
-
28
- module ClassMethods
29
- def consider_local(*args)
30
- local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) })
31
- end
32
-
33
- def local_addresses
34
- addresses = read_inheritable_attribute(:local_addresses)
35
- unless addresses
36
- addresses = [IPAddr.new("127.0.0.1")]
37
- write_inheritable_attribute(:local_addresses, addresses)
38
- end
39
- addresses
40
- end
41
-
42
- def exception_data(deliverer=self)
43
- if deliverer == self
44
- read_inheritable_attribute(:exception_data)
45
- else
46
- write_inheritable_attribute(:exception_data, deliverer)
47
- end
48
- end
49
-
50
- def exceptions_to_treat_as_404
51
- exceptions = [ActionController::UnknownController, ActionController::UnknownAction]
52
- exceptions << ActionController::RoutingError if ActionController.const_defined?(:RoutingError)
53
- exceptions << ActiveRecord::RecordNotFound if Object.const_defined?(:ActiveRecord)
54
- exceptions
55
- end
56
- end
57
-
58
- private
59
-
60
- def local_request?
61
- remote = IPAddr.new(request.remote_ip)
62
- !self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil?
63
- end
64
-
65
- def render_404
66
- respond_to do |type|
67
- type.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" }
68
- type.all { render :nothing => true, :status => "404 Not Found" }
69
- end
70
- end
71
-
72
- def render_500
73
- respond_to do |type|
74
- type.html { render :file => "#{RAILS_ROOT}/public/500.html", :status => "500 Error" }
75
- type.all { render :nothing => true, :status => "500 Error" }
76
- end
77
- end
78
-
79
- def rescue_action_in_public(exception)
80
- case exception
81
- when *self.class.exceptions_to_treat_as_404
82
- render_404
83
-
84
- else
85
- render_500
86
-
87
- deliverer = self.class.exception_data
88
- data = case deliverer
89
- when nil then {}
90
- when Symbol then send(deliverer)
91
- when Proc then deliverer.call(self)
92
- end
93
-
94
- ExceptionNotifier.deliver_exception_notification(exception, self,
95
- request, data)
96
- end
97
- end
98
- end
data/rails/init.rb DELETED
@@ -1 +0,0 @@
1
- require "action_mailer"
@@ -1,61 +0,0 @@
1
- require 'test_helper'
2
- require 'exception_notifier_helper'
3
-
4
- class ExceptionNotifierHelperTest < Test::Unit::TestCase
5
-
6
- class ExceptionNotifierHelperIncludeTarget
7
- include ExceptionNotifierHelper
8
- end
9
-
10
- def setup
11
- @helper = ExceptionNotifierHelperIncludeTarget.new
12
- end
13
-
14
- # No controller
15
-
16
- def test_should_not_exclude_raw_post_parameters_if_no_controller
17
- assert !@helper.exclude_raw_post_parameters?
18
- end
19
-
20
- # Controller, no filtering
21
-
22
- class ControllerWithoutFilterParameters; end
23
-
24
- def test_should_not_filter_env_values_for_raw_post_data_keys_if_controller_can_not_filter_parameters
25
- stub_controller(ControllerWithoutFilterParameters.new)
26
- assert @helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
27
- end
28
- def test_should_not_exclude_raw_post_parameters_if_controller_can_not_filter_parameters
29
- stub_controller(ControllerWithoutFilterParameters.new)
30
- assert !@helper.exclude_raw_post_parameters?
31
- end
32
- def test_should_return_params_if_controller_can_not_filter_parameters
33
- stub_controller(ControllerWithoutFilterParameters.new)
34
- assert_equal :params, @helper.filter_sensitive_post_data_parameters(:params)
35
- end
36
-
37
- # Controller with filtering
38
-
39
- class ControllerWithFilterParameters
40
- def filter_parameters(params); :filtered end
41
- end
42
-
43
- def test_should_filter_env_values_for_raw_post_data_keys_if_controller_can_filter_parameters
44
- stub_controller(ControllerWithFilterParameters.new)
45
- assert !@helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
46
- assert @helper.filter_sensitive_post_data_from_env("SOME_OTHER_KEY", "secret").include?("secret")
47
- end
48
- def test_should_exclude_raw_post_parameters_if_controller_can_filter_parameters
49
- stub_controller(ControllerWithFilterParameters.new)
50
- assert @helper.exclude_raw_post_parameters?
51
- end
52
- def test_should_delegate_param_filtering_to_controller_if_controller_can_filter_parameters
53
- stub_controller(ControllerWithFilterParameters.new)
54
- assert_equal :filtered, @helper.filter_sensitive_post_data_parameters(:params)
55
- end
56
-
57
- private
58
- def stub_controller(controller)
59
- @helper.instance_variable_set(:@controller, controller)
60
- end
61
- end
data/test/test_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'test/unit'
2
- require 'rubygems'
3
- require 'active_support'
4
-
5
- $:.unshift File.join(File.dirname(__FILE__), '../lib')
6
-
7
- RAILS_ROOT = '.' unless defined?(RAILS_ROOT)