Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
837ab8c5
Commit
837ab8c5
authored
Nov 15, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make HasRef#git_ref public
parent
2edc0214
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
+28
-4
app/models/concerns/has_ref.rb
app/models/concerns/has_ref.rb
+0
-4
spec/models/concerns/has_ref_spec.rb
spec/models/concerns/has_ref_spec.rb
+28
-0
No files found.
app/models/concerns/has_ref.rb
View file @
837ab8c5
...
...
@@ -7,15 +7,11 @@ module HasRef
!
tag?
end
private
def
git_ref
if
branch?
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
ref
.
to_s
elsif
tag?
Gitlab
::
Git
::
TAG_REF_PREFIX
+
ref
.
to_s
else
raise
ArgumentError
,
'Invalid pipeline type!'
end
end
end
spec/models/concerns/has_ref_spec.rb
View file @
837ab8c5
...
...
@@ -28,4 +28,32 @@ describe HasRef do
end
end
end
describe
'#git_ref'
do
subject
{
pipeline
.
git_ref
}
context
'when tag is true'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
tag:
true
)
}
it
'returns a tag ref'
do
is_expected
.
to
start_with
(
Gitlab
::
Git
::
TAG_REF_PREFIX
)
end
end
context
'when tag is false'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
tag:
false
)
}
it
'returns a branch ref'
do
is_expected
.
to
start_with
(
Gitlab
::
Git
::
BRANCH_REF_PREFIX
)
end
end
context
'when tag is nil'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
tag:
nil
)
}
it
'returns a branch ref'
do
is_expected
.
to
start_with
(
Gitlab
::
Git
::
BRANCH_REF_PREFIX
)
end
end
end
end
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