summaryrefslogtreecommitdiff
path: root/app/models/environment.rb
diff options
context:
space:
mode:
authorVladimir Shushlin <vshushlin@gitlab.com>2019-02-26 19:13:09 +0000
committerStan Hu <stanhu@gmail.com>2019-02-26 19:13:09 +0000
commit25c10abb80799e24e616e2bb8c0081096b201c29 (patch)
treec602b75234cd3abdb50cb62a46d539bdb6cfa5b8 /app/models/environment.rb
parent9812006568061f0afd8dfb146920e526877d4d9b (diff)
downloadgitlab-ce-25c10abb80799e24e616e2bb8c0081096b201c29.tar.gz
Add name_without_type to environments.json
It's needed to show shorter names in environments "folders"
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r--app/models/environment.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 1fc088b12ae..87bdb52b58b 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -243,6 +243,10 @@ class Environment < ActiveRecord::Base
self.environment_type || self.name
end
+ def name_without_type
+ @name_without_type ||= name.delete_prefix("#{environment_type}/")
+ end
+
def deployment_platform
strong_memoize(:deployment_platform) do
project.deployment_platform(environment: self.name)