BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0b18023c
Commit
0b18023c
authored
Nov 02, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid regenerating the ref path for the environment
Closes #39752
parent
713052c7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
environment.rb
app/models/environment.rb
+5
-1
sh-fix-environment-slug-generation.yml
changelogs/unreleased/sh-fix-environment-slug-generation.yml
+5
-0
environment_spec.rb
spec/models/environment_spec.rb
+15
-0
No files found.
app/models/environment.rb
View file @
0b18023c
...
...
@@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base
end
def
ref_path
"refs/
#{
Repository
::
REF_ENVIRONMENTS
}
/
#{
generate_
slug
}
"
"refs/
#{
Repository
::
REF_ENVIRONMENTS
}
/
#{
slug
}
"
end
def
formatted_external_url
...
...
@@ -164,6 +164,10 @@ class Environment < ActiveRecord::Base
end
end
def
slug
super
.
presence
||
generate_slug
end
# An environment name is not necessarily suitable for use in URLs, DNS
# or other third-party contexts, so provide a slugified version. A slug has
# the following properties:
...
...
changelogs/unreleased/sh-fix-environment-slug-generation.yml
0 → 100644
View file @
0b18023c
---
title
:
Avoid regenerating the ref path for the environment
merge_request
:
author
:
type
:
fixed
spec/models/environment_spec.rb
View file @
0b18023c
...
...
@@ -547,6 +547,15 @@ describe Environment do
expect
(
environment
.
slug
).
to
eq
(
original_slug
)
end
it
"regenerates the slug if nil"
do
environment
=
build
(
:environment
,
slug:
nil
)
new_slug
=
environment
.
slug
expect
(
new_slug
).
not_to
be_nil
expect
(
environment
.
slug
).
to
eq
(
new_slug
)
end
end
describe
'#generate_slug'
do
...
...
@@ -583,6 +592,12 @@ describe Environment do
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
it
"doesn't change when the slug is nil initially"
do
environment
.
slug
=
nil
expect
(
environment
.
ref_path
).
to
eq
(
environment
.
ref_path
)
end
end
describe
'#external_url_for'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment