diff --git a/lib/travis/model/repository/settings.rb b/lib/travis/model/repository/settings.rb index eaa87a712..02c12dd12 100644 --- a/lib/travis/model/repository/settings.rb +++ b/lib/travis/model/repository/settings.rb @@ -14,6 +14,10 @@ class EnvVar < Travis::Settings::Model attribute :repository_id, Integer validates :name, presence: true + + def value=(value) + super(value.strip) + end end class SshKey < Travis::Settings::Model diff --git a/spec/travis/model/repository/settings_spec.rb b/spec/travis/model/repository/settings_spec.rb index 146d6ad0b..5bfa0eb6e 100644 --- a/spec/travis/model/repository/settings_spec.rb +++ b/spec/travis/model/repository/settings_spec.rb @@ -11,6 +11,12 @@ settings.env_vars.public.length.should == 1 settings.env_vars.public.first.name.should == 'PUBLIC_VAR' end + + it 'strips leading whitespace from the variable value' do + var = Repository::Settings::EnvVar.new + var.update(name: 'FOO', value: ' foo', public: false) + var.value.decrypt.should == 'foo' + end end describe '#maximum_number_of_builds' do