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
ef061371
Commit
ef061371
authored
Aug 01, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for PipelineDataBuilder
parent
3b943fbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
lib/gitlab/data_builder/pipeline_data_builder.rb
lib/gitlab/data_builder/pipeline_data_builder.rb
+1
-1
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
+32
-0
No files found.
lib/gitlab/data_builder/pipeline_data_builder.rb
View file @
ef061371
...
...
@@ -6,10 +6,10 @@ module Gitlab
def
build
(
pipeline
)
{
object_kind:
'pipeline'
,
object_attributes:
hook_attrs
(
pipeline
),
user:
pipeline
.
user
.
try
(
:hook_attrs
),
project:
pipeline
.
project
.
hook_attrs
(
backward:
false
),
commit:
pipeline
.
commit
.
try
(
:hook_attrs
),
object_attributes:
hook_attrs
(
pipeline
),
builds:
pipeline
.
builds
.
map
(
&
method
(
:build_hook_attrs
))
}
end
...
...
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
0 → 100644
View file @
ef061371
require
'spec_helper'
describe
Gitlab
::
DataBuilder
::
PipelineDataBuilder
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
status:
'success'
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
end
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
describe
'.build'
do
let
(
:data
)
{
Gitlab
::
DataBuilder
::
PipelineDataBuilder
.
build
(
pipeline
)
}
let
(
:attributes
)
{
data
[
:object_attributes
]
}
let
(
:build_data
)
{
data
[
:builds
].
first
}
let
(
:project_data
)
{
data
[
:project
]
}
it
{
expect
(
attributes
).
to
be_a
(
Hash
)
}
it
{
expect
(
attributes
[
:ref
]).
to
eq
(
pipeline
.
ref
)
}
it
{
expect
(
attributes
[
:sha
]).
to
eq
(
pipeline
.
sha
)
}
it
{
expect
(
attributes
[
:tag
]).
to
eq
(
pipeline
.
tag
)
}
it
{
expect
(
attributes
[
:id
]).
to
eq
(
pipeline
.
id
)
}
it
{
expect
(
attributes
[
:status
]).
to
eq
(
pipeline
.
status
)
}
it
{
expect
(
build_data
).
to
be_a
(
Hash
)
}
it
{
expect
(
build_data
[
:id
]).
to
eq
(
build
.
id
)
}
it
{
expect
(
build_data
[
:status
]).
to
eq
(
build
.
status
)
}
it
{
expect
(
project_data
).
to
eq
(
project
.
hook_attrs
(
backward:
false
))
}
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