diff options
author | Chris Stephan <cstephan@squaremouth.com> | 2013-08-28 21:21:54 -0400 |
---|---|---|
committer | Chris Stephan <cstephan@squaremouth.com> | 2013-08-28 21:21:54 -0400 |
commit | b8529524969b783e1f6436a7fd3cce9747244659 (patch) | |
tree | 5447576573d58db7071caedde6514d37740b82a2 /spec | |
parent | b4e7679174e9a1fe6b047e7571ddfadd148e7a78 (diff) | |
download | gitlab-ci-b8529524969b783e1f6436a7fd3cce9747244659.tar.gz |
Add display name to runner model
This commit adds a method to the runner model that will return a display
name for the runner. It will return the runner's token if a runner
doesn't have a description or if it's empty. It will return the
description otherwise. This is in order to give each particular runner a
more friendly name when viewing them on a particular project. This
commit also updates the runner_projects index to use this display name
instead of using the token. And finally it adds spec tests to cover the
new method added.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/runner_spec.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/spec/models/runner_spec.rb b/spec/models/runner_spec.rb index 97d5e54..3703de0 100644 --- a/spec/models/runner_spec.rb +++ b/spec/models/runner_spec.rb @@ -2,15 +2,31 @@ # # Table name: runners # -# id :integer not null, primary key -# token :string(255) -# public_key :text -# created_at :datetime not null -# updated_at :datetime not null +# id :integer not null, primary key +# token :string(255) +# public_key :text +# created_at :datetime not null +# updated_at :datetime not null +# description :string(255) # require 'spec_helper' describe Runner do - pending "add some examples to (or delete) #{__FILE__}" + describe '#display_name' do + it 'should return the description if it has a value' do + runner = FactoryGirl.build(:runner, description: 'Linux/Ruby-1.9.3-p448') + expect(runner.display_name).to eq 'Linux/Ruby-1.9.3-p448' + end + + it 'should return the token if it does not have a description' do + runner = FactoryGirl.build(:runner) + expect(runner.display_name).to eq runner.token + end + + it 'should return the token if the description is an empty string' do + runner = FactoryGirl.build(:runner, description: '') + expect(runner.display_name).to eq runner.token + end + end end |