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
Jérome Perrin
gitlab-ce
Commits
0a9d9f7d
Commit
0a9d9f7d
authored
Aug 11, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fetch the current SHA if SHA was not passed
parent
4b559c9a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
13 deletions
+28
-13
app/models/project.rb
app/models/project.rb
+2
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+26
-12
No files found.
app/models/project.rb
View file @
0a9d9f7d
...
@@ -1086,7 +1086,8 @@ class Project < ActiveRecord::Base
...
@@ -1086,7 +1086,8 @@ class Project < ActiveRecord::Base
!
namespace
.
share_with_group_lock
!
namespace
.
share_with_group_lock
end
end
def
pipeline_for
(
ref
,
sha
)
def
pipeline_for
(
ref
,
sha
=
commit
(
ref
).
try
(
:sha
))
return
unless
sha
pipelines
.
order
(
id: :desc
).
find_by
(
sha:
sha
,
ref:
ref
)
pipelines
.
order
(
id: :desc
).
find_by
(
sha:
sha
,
ref:
ref
)
end
end
...
...
spec/models/project_spec.rb
View file @
0a9d9f7d
...
@@ -684,23 +684,37 @@ describe Project, models: true do
...
@@ -684,23 +684,37 @@ describe Project, models: true do
end
end
end
end
describe
'#pipeline'
do
describe
'#pipeline_for'
do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
:ci_pipeline
,
project:
project
,
ref:
'master'
}
let!
(
:pipeline
)
{
create_pipeline
}
subject
{
project
.
pipeline_for
(
'master'
,
pipeline
.
sha
)
}
shared_examples
'giving the correct pipeline'
do
it
{
is_expected
.
to
eq
(
pipeline
)
}
it
{
is_expected
.
to
eq
(
pipeline
)
}
context
'return latest'
do
context
'return latest'
do
let
(
:pipeline2
)
{
create
:ci_pipeline
,
project:
project
,
ref:
'master'
}
let!
(
:pipeline2
)
{
create_pipeline
}
before
do
it
{
is_expected
.
to
eq
(
pipeline2
)
}
pipeline
end
pipeline2
end
end
it
{
is_expected
.
to
eq
(
pipeline2
)
}
context
'with explicit sha'
do
subject
{
project
.
pipeline_for
(
'master'
,
pipeline
.
sha
)
}
it_behaves_like
'giving the correct pipeline'
end
context
'with implicit sha'
do
subject
{
project
.
pipeline_for
(
'master'
)
}
it_behaves_like
'giving the correct pipeline'
end
def
create_pipeline
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
,
sha:
project
.
commit
(
'master'
).
sha
)
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