Changeset 453

Show
Ignore:
Timestamp:
06/24/08 10:46:09 (5 months ago)
Author:
deveiant
Message:
  • Added another component to the untainting of keys in the form validator
  • Added a 'timedelta' template tag plugin
Location:
trunk
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/arrow/formvalidator.rb

    r452 r453  
    132132        *(Hash.public_instance_methods(false) - ['[]', '[]=', 'inspect']) 
    133133 
    134  
    135          
    136134 
    137135    ### Stringified description of the validator 
  • trunk/spec/arrow/formvalidator_spec.rb

    r446 r453  
    263263    it "should untaint both keys and values in complex hash fields if untainting is turned on" do 
    264264        profile = { 
     265            :required => [ 
     266                'recipe[ingredient][rarity]', 
     267            ], 
    265268            :optional => [ 
    266269                'recipe[ingredient][name]', 
     
    268271                'recipe[yield]' 
    269272            ], 
     273            :constraints    => { 
     274                'recipe[ingredient][rarity]' => /^([\w\-]+)$/, 
     275            }, 
    270276            :untaint_all_constraints => true, 
    271277        } 
    272278        args = { 
     279            'recipe[ingredient][rarity]'.taint => 'super-rare'.taint, 
    273280            'recipe[ingredient][name]'.taint => 'nutmeg'.taint, 
    274281            'recipe[ingredient][cost]'.taint => '$0.18'.taint, 
     
    280287        @validator.valid.should == { 
    281288            'recipe' => { 
    282                 'ingredient' => { 'name' => 'nutmeg', 'cost' => '$0.18' }, 
     289                'ingredient' => { 'name' => 'nutmeg', 'cost' => '$0.18', 'rarity' => 'super-rare' }, 
    283290                'yield' => '2 loaves' 
    284291            } 
     
    286293 
    287294        @validator.valid.keys.all? {|key| key.should_not be_tainted() } 
    288         @validator.valid.keys.all? {|key| key.should_not be_tainted() } 
     295        @validator.valid.values.all? {|key| key.should_not be_tainted() } 
    289296        @validator.valid['recipe'].keys.all? {|key| key.should_not be_tainted() } 
    290297        @validator.valid['recipe']['ingredient'].keys.all? {|key| key.should_not be_tainted() } 
    291298        @validator.valid['recipe']['yield'].should_not be_tainted() 
     299        @validator.valid['recipe']['ingredient']['rarity'].should_not be_tainted() 
    292300        @validator.valid['recipe']['ingredient']['name'].should_not be_tainted() 
    293301        @validator.valid['recipe']['ingredient']['cost'].should_not be_tainted()