diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-10-24 12:22:21 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-10-24 15:40:14 +0300 |
commit | 3bf0686663b049fe87f083797a0e0ba2bf00a859 (patch) | |
tree | f989b35997fd95a4cc121c3185c73818ca6a23c2 | |
parent | 73e40d759425c6140b8162f38e323c449ec4808c (diff) |
Merge branch 'sh-fix-environment-write-ref' into 'master'
Fix the writing of invalid environment refs
Closes #39182
See merge request gitlab-org/gitlab-ce!14993
(cherry picked from commit 3dcdd4a1e8533cac55805d2242446cb2e12b21e9)
3bff85a4 Fix the writing of invalid environment refs
-rw-r--r-- | app/models/environment.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/sh-fix-environment-write-ref.yml | 5 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 10 |
3 files changed, 16 insertions, 1 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index b6868ccbe8f..e613d21add6 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base end def ref_path - "refs/#{Repository::REF_ENVIRONMENTS}/#{Shellwords.shellescape(name)}" + "refs/#{Repository::REF_ENVIRONMENTS}/#{generate_slug}" end def formatted_external_url diff --git a/changelogs/unreleased/sh-fix-environment-write-ref.yml b/changelogs/unreleased/sh-fix-environment-write-ref.yml new file mode 100644 index 00000000000..8f291843ebe --- /dev/null +++ b/changelogs/unreleased/sh-fix-environment-write-ref.yml @@ -0,0 +1,5 @@ +--- +title: Fix the writing of invalid environment refs +merge_request: +author: +type: fixed diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 25e5d155894..e1be23541e8 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -575,6 +575,16 @@ describe Environment do end end + describe '#ref_path' do + subject(:environment) do + create(:environment, name: 'staging / review-1') + end + + it 'returns a path that uses the slug and does not have spaces' do + expect(environment.ref_path).to start_with('refs/environments/staging-review-1-') + end + end + describe '#external_url_for' do let(:source_path) { 'source/file.html' } let(:sha) { RepoHelpers.sample_commit.id } |