Sha256: 68b3f1d8a181b9d02e186d94d3bfae907be1fe869d20c7caf0c4dc7ba148c573

Contents?: true

Size: 1.72 KB

Versions: 17

Compression:

Stored size: 1.72 KB

Contents

require File.dirname(__FILE__) + '/../abstract_unit'

class FilterParamController < ActionController::Base
end

class FilterParamTest < Test::Unit::TestCase
  def setup
    @controller = FilterParamController.new
  end
  
  def test_filter_parameters
    assert FilterParamController.respond_to?(:filter_parameter_logging)
    assert !@controller.respond_to?(:filter_parameters)
    
    FilterParamController.filter_parameter_logging
    assert @controller.respond_to?(:filter_parameters)
    
    test_hashes = [[{},{},[]],
    [{'foo'=>nil},{'foo'=>nil},[]],
    [{'foo'=>'bar'},{'foo'=>'bar'},[]],
    [{'foo'=>'bar'},{'foo'=>'bar'},%w'food'],
    [{'foo'=>'bar'},{'foo'=>'[FILTERED]'},%w'foo'],
    [{'foo'=>'bar', 'bar'=>'foo'},{'foo'=>'[FILTERED]', 'bar'=>'foo'},%w'foo baz'],
    [{'foo'=>'bar', 'baz'=>'foo'},{'foo'=>'[FILTERED]', 'baz'=>'[FILTERED]'},%w'foo baz'],
    [{'bar'=>{'foo'=>'bar','bar'=>'foo'}},{'bar'=>{'foo'=>'[FILTERED]','bar'=>'foo'}},%w'fo'],
    [{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana']]
    
    test_hashes.each do |before_filter, after_filter, filter_words|
      FilterParamController.filter_parameter_logging(*filter_words)
      assert_equal after_filter, @controller.filter_parameters(before_filter)
      
      filter_words.push('blah')
      FilterParamController.filter_parameter_logging(*filter_words) do |key, value|
        value.reverse! if key =~ /bargain/
      end

      before_filter['barg'] = {'bargain'=>'gain', 'blah'=>'bar', 'bar'=>{'bargain'=>{'blah'=>'foo'}}}
      after_filter['barg'] = {'bargain'=>'niag', 'blah'=>'[FILTERED]', 'bar'=>{'bargain'=>{'blah'=>'[FILTERED]'}}}

      assert_equal after_filter, @controller.filter_parameters(before_filter)
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
actionpack-1.13.5 test/controller/filter_params_test.rb
actionpack-1.13.4 test/controller/filter_params_test.rb
actionpack-1.13.6 test/controller/filter_params_test.rb
actionpack-2.0.0 test/controller/filter_params_test.rb
actionpack-2.0.2 test/controller/filter_params_test.rb
actionpack-2.0.5 test/controller/filter_params_test.rb
actionpack-2.0.1 test/controller/filter_params_test.rb
actionpack-2.0.4 test/controller/filter_params_test.rb
radiant-0.6.4 vendor/rails/actionpack/test/controller/filter_params_test.rb
radiant-0.6.5.1 vendor/rails/actionpack/test/controller/filter_params_test.rb
radiant-0.6.5 vendor/rails/actionpack/test/controller/filter_params_test.rb
radiant-0.6.6 vendor/rails/actionpack/test/controller/filter_params_test.rb
radiant-0.6.7 vendor/rails/actionpack/test/controller/filter_params_test.rb
radiant-0.6.9 vendor/rails/actionpack/test/controller/filter_params_test.rb
radiant-0.6.8 vendor/rails/actionpack/test/controller/filter_params_test.rb
spree-0.0.9 vendor/rails/actionpack/test/controller/filter_params_test.rb
spree-0.2.0 vendor/rails/actionpack/test/controller/filter_params_test.rb