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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
56876070
Commit
56876070
authored
Aug 06, 2019
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix nil take regression
parent
2fd73269
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
19 deletions
+25
-19
app/models/project.rb
app/models/project.rb
+4
-5
spec/models/project_spec.rb
spec/models/project_spec.rb
+21
-14
No files found.
app/models/project.rb
View file @
56876070
...
@@ -1487,6 +1487,9 @@ class Project < ApplicationRecord
...
@@ -1487,6 +1487,9 @@ class Project < ApplicationRecord
end
end
def
pipeline_for
(
ref
,
sha
=
nil
,
id
=
nil
)
def
pipeline_for
(
ref
,
sha
=
nil
,
id
=
nil
)
sha
||=
commit
(
ref
).
try
(
:sha
)
return
unless
sha
if
id
.
present?
if
id
.
present?
pipelines_for
(
ref
,
sha
).
find_by
(
id:
id
)
pipelines_for
(
ref
,
sha
).
find_by
(
id:
id
)
else
else
...
@@ -1494,11 +1497,7 @@ class Project < ApplicationRecord
...
@@ -1494,11 +1497,7 @@ class Project < ApplicationRecord
end
end
end
end
def
pipelines_for
(
ref
,
sha
=
nil
)
def
pipelines_for
(
ref
,
sha
)
sha
||=
commit
(
ref
).
try
(
:sha
)
return
unless
sha
ci_pipelines
.
order
(
id: :desc
).
where
(
sha:
sha
,
ref:
ref
)
ci_pipelines
.
order
(
id: :desc
).
where
(
sha:
sha
,
ref:
ref
)
end
end
...
...
spec/models/project_spec.rb
View file @
56876070
...
@@ -1156,7 +1156,6 @@ describe Project do
...
@@ -1156,7 +1156,6 @@ describe Project do
describe
'#pipeline_for'
do
describe
'#pipeline_for'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:pipeline
)
{
create_pipeline
(
project
)
}
shared_examples
'giving the correct pipeline'
do
shared_examples
'giving the correct pipeline'
do
it
{
is_expected
.
to
eq
(
pipeline
)
}
it
{
is_expected
.
to
eq
(
pipeline
)
}
...
@@ -1168,6 +1167,9 @@ describe Project do
...
@@ -1168,6 +1167,9 @@ describe Project do
end
end
end
end
context
'with a matching pipeline'
do
let!
(
:pipeline
)
{
create_pipeline
(
project
)
}
context
'with explicit sha'
do
context
'with explicit sha'
do
subject
{
project
.
pipeline_for
(
'master'
,
pipeline
.
sha
)
}
subject
{
project
.
pipeline_for
(
'master'
,
pipeline
.
sha
)
}
...
@@ -1189,17 +1191,22 @@ describe Project do
...
@@ -1189,17 +1191,22 @@ describe Project do
end
end
end
end
context
'when there is no matching pipeline'
do
subject
{
project
.
pipeline_for
(
'master'
)
}
it
{
is_expected
.
to
be_nil
}
end
end
describe
'#pipelines_for'
do
describe
'#pipelines_for'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:pipeline
)
{
create_pipeline
(
project
)
}
let!
(
:pipeline
)
{
create_pipeline
(
project
)
}
let!
(
:other_pipeline
)
{
create_pipeline
(
project
)
}
let!
(
:other_pipeline
)
{
create_pipeline
(
project
)
}
context
'with implicit sha'
do
subject
{
project
.
pipelines_for
(
project
.
default_branch
,
project
.
commit
.
sha
)
}
subject
{
project
.
pipelines_for
(
'master'
)
}
it
{
is_expected
.
to
contain_exactly
(
pipeline
,
other_pipeline
)
}
it
{
is_expected
.
to
contain_exactly
(
pipeline
,
other_pipeline
)
}
end
end
end
describe
'#builds_enabled'
do
describe
'#builds_enabled'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
...
...
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