Commit 3dcdd4a1 authored by Grzegorz Bizon's avatar Grzegorz Bizon

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
parents 3548dc4b 3bff85a4
......@@ -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
......
---
title: Fix the writing of invalid environment refs
merge_request:
author:
type: fixed
......@@ -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 }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment