diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2019-02-26 19:13:09 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-02-26 19:13:09 +0000 |
commit | 25c10abb80799e24e616e2bb8c0081096b201c29 (patch) | |
tree | c602b75234cd3abdb50cb62a46d539bdb6cfa5b8 /spec/models/environment_spec.rb | |
parent | 9812006568061f0afd8dfb146920e526877d4d9b (diff) | |
download | gitlab-ce-25c10abb80799e24e616e2bb8c0081096b201c29.tar.gz |
Add name_without_type to environments.json
It's needed to show shorter names in environments "folders"
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r-- | spec/models/environment_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 2d554326f05..ab1b306e597 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -164,6 +164,28 @@ describe Environment do end end + describe '#name_without_type' do + context 'when it is inside a folder' do + subject(:environment) do + create(:environment, name: 'staging/review-1') + end + + it 'returns name without folder' do + expect(environment.name_without_type).to eq 'review-1' + end + end + + context 'when the environment if a top-level item itself' do + subject(:environment) do + create(:environment, name: 'production') + end + + it 'returns full name' do + expect(environment.name_without_type).to eq 'production' + end + end + end + describe '#nullify_external_url' do it 'replaces a blank url with nil' do env = build(:environment, external_url: "") |