Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

trim leading/tailing whitespace from env var values #467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/travis/model/repository/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/travis/model/repository/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down