diff options
author | Kamil TrzciĆski <kamil@gitlab.com> | 2017-08-21 15:46:45 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-09-07 20:22:16 -0400 |
commit | 4efd18d7e140bf2b6b95637af630e7294fcf28cc (patch) | |
tree | 107d92596480763bb1bd43ee85c6493ca18842a9 /app/models/environment.rb | |
parent | 4acab552be05e2ee1ccb6ba1997b770dd89c42bd (diff) | |
download | gitlab-ce-4efd18d7e140bf2b6b95637af630e7294fcf28cc.tar.gz |
Merge branch '29943-environment-folder' into 'security-9-5'
Do not use `location.pathname` when accessing environments folders
See merge request !2147
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 435eeaf0e2e..9b05f8b1cd5 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -82,12 +82,7 @@ class Environment < ActiveRecord::Base def set_environment_type names = name.split('/') - self.environment_type = - if names.many? - names.first - else - nil - end + self.environment_type = names.many? ? names.first : nil end def includes_commit?(commit) @@ -101,7 +96,7 @@ class Environment < ActiveRecord::Base end def update_merge_request_metrics? - (environment_type || name) == "production" + folder_name == "production" end def first_deployment_for(commit) @@ -223,6 +218,10 @@ class Environment < ActiveRecord::Base format: :json) end + def folder_name + self.environment_type || self.name + end + private # Slugifying a name may remove the uniqueness guarantee afforded by it being |