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
Boxiang Sun
gitlab-ce
Commits
d0451a05
Commit
d0451a05
authored
Jul 12, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for Project#builds_for and return empty array for nothing
parent
2c646bb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
app/models/project.rb
app/models/project.rb
+3
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+15
-1
No files found.
app/models/project.rb
View file @
d0451a05
...
...
@@ -430,6 +430,9 @@ class Project < ActiveRecord::Base
end
def
builds_for
(
build_name
,
ref
=
'HEAD'
)
ct
=
commit
(
ref
)
return
[]
unless
ct
sha
=
commit
(
ref
).
sha
builds
.
joins
(
:pipeline
).
...
...
spec/models/project_spec.rb
View file @
d0451a05
...
...
@@ -359,11 +359,25 @@ describe Project, models: true do
describe
:repository
do
let
(
:project
)
{
create
(
:project
)
}
it
'
should return
valid repo'
do
it
'
returns
valid repo'
do
expect
(
project
.
repository
).
to
be_kind_of
(
Repository
)
end
end
describe
'#builds_for'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
)
end
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'returns builds for a particular ref'
do
build_ids
=
project
.
builds_for
(
build
.
name
,
build
.
sha
).
map
(
&
:id
)
expect
(
build_ids
).
to
eq
([
build
.
id
])
end
end
describe
:default_issues_tracker?
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:ext_project
)
{
create
(
:redmine_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