diff options
| author | hukl <contact@smyck.org> | 2009-10-31 18:59:01 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-10-31 18:59:01 +0100 |
| commit | a2671e54c3abfcdc14b95f262d0bb6d016a938ff (patch) | |
| tree | 36fb152b93ac11fe2c97b91f6fde5b39408eed15 /vendor/plugins/exception_notification/test | |
| parent | 3781bd31ff137e6bc0a3b1d0c5506dfb42878a5c (diff) | |
added exception notifier plugin to catch all exceptions
Diffstat (limited to 'vendor/plugins/exception_notification/test')
| -rw-r--r-- | vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb | 61 | ||||
| -rw-r--r-- | vendor/plugins/exception_notification/test/test_helper.rb | 7 |
2 files changed, 68 insertions, 0 deletions
diff --git a/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb b/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb new file mode 100644 index 0000000..dd47637 --- /dev/null +++ b/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb | |||
| @@ -0,0 +1,61 @@ | |||
| 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 \ No newline at end of file | ||
diff --git a/vendor/plugins/exception_notification/test/test_helper.rb b/vendor/plugins/exception_notification/test/test_helper.rb new file mode 100644 index 0000000..bbe6fc5 --- /dev/null +++ b/vendor/plugins/exception_notification/test/test_helper.rb | |||
| @@ -0,0 +1,7 @@ | |||
| 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) | ||
