Initial commit of foodsoft 2

This commit is contained in:
Benjamin Meichsner 2009-01-06 11:49:19 +01:00
commit 5b9a7e05df
657 changed files with 70444 additions and 0 deletions

View file

@ -0,0 +1,61 @@
require 'test_helper'
require 'exception_notifier_helper'
class ExceptionNotifierHelperTest < Test::Unit::TestCase
class ExceptionNotifierHelperIncludeTarget
include ExceptionNotifierHelper
end
def setup
@helper = ExceptionNotifierHelperIncludeTarget.new
end
# No controller
def test_should_not_exclude_raw_post_parameters_if_no_controller
assert !@helper.exclude_raw_post_parameters?
end
# Controller, no filtering
class ControllerWithoutFilterParameters; end
def test_should_not_filter_env_values_for_raw_post_data_keys_if_controller_can_not_filter_parameters
stub_controller(ControllerWithoutFilterParameters.new)
assert @helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
end
def test_should_not_exclude_raw_post_parameters_if_controller_can_not_filter_parameters
stub_controller(ControllerWithoutFilterParameters.new)
assert !@helper.exclude_raw_post_parameters?
end
def test_should_return_params_if_controller_can_not_filter_parameters
stub_controller(ControllerWithoutFilterParameters.new)
assert_equal :params, @helper.filter_sensitive_post_data_parameters(:params)
end
# Controller with filtering
class ControllerWithFilterParameters
def filter_parameters(params); :filtered end
end
def test_should_filter_env_values_for_raw_post_data_keys_if_controller_can_filter_parameters
stub_controller(ControllerWithFilterParameters.new)
assert !@helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
assert @helper.filter_sensitive_post_data_from_env("SOME_OTHER_KEY", "secret").include?("secret")
end
def test_should_exclude_raw_post_parameters_if_controller_can_filter_parameters
stub_controller(ControllerWithFilterParameters.new)
assert @helper.exclude_raw_post_parameters?
end
def test_should_delegate_param_filtering_to_controller_if_controller_can_filter_parameters
stub_controller(ControllerWithFilterParameters.new)
assert_equal :filtered, @helper.filter_sensitive_post_data_parameters(:params)
end
private
def stub_controller(controller)
@helper.instance_variable_set(:@controller, controller)
end
end

View file

@ -0,0 +1,7 @@
require 'test/unit'
require 'rubygems'
require 'active_support'
$:.unshift File.join(File.dirname(__FILE__), '../lib')
RAILS_ROOT = '.' unless defined?(RAILS_ROOT)