Changeset 108

Show
Ignore:
Timestamp:
06/13/08 22:45:19 (5 months ago)
Author:
jweiss
Message:

fix #83 - colon in configuration parameter

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/models/configuration_parameter.rb

    r51 r108  
    1111  def validate 
    1212    self.errors.add('value', 'must be empty if prompt on deploy is set') if (self.prompt? && !self.value.blank?) 
     13    self.errors.add('name', 'can\'t contain a colon') if (!self.name.blank? && self.name.strip.starts_with?(":")) 
    1314  end 
    1415   
  • trunk/test/unit/configuration_parameter_test.rb

    r1 r108  
    168168  end 
    169169   
     170  def test_should_not_be_valid_when_name_starts_with_colon 
     171    c = @project.configuration_parameters.build( 
     172      :name => ':password_2',  
     173      :value => 'abc', 
     174      :prompt_on_deploy => 0 
     175    ) 
     176    c.valid? 
     177    assert_equal "can't contain a colon", c.errors.on(:name) 
     178  end 
     179 
     180  def test_should_not_be_valid_when_name_starts_with_spaces_and_colon 
     181    c = @project.configuration_parameters.build( 
     182      :name => '   :password_2',  
     183      :value => 'abc', 
     184      :prompt_on_deploy => 0 
     185    ) 
     186    c.valid? 
     187    assert_equal "can't contain a colon", c.errors.on(:name) 
     188  end 
     189   
    170190end