BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
4323d24a
Commit
4323d24a
authored
Aug 24, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old stuffs
parent
a79cd2a2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
101 deletions
+2
-101
pipeline_data_builder.rb
lib/gitlab/data_builder/pipeline_data_builder.rb
+0
-66
pipeline_data_builder_spec.rb
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
+0
-33
slack_service_spec.rb
spec/models/project_services/slack_service_spec.rb
+2
-2
No files found.
lib/gitlab/data_builder/pipeline_data_builder.rb
deleted
100644 → 0
View file @
a79cd2a2
module
Gitlab
module
DataBuilder
module
PipelineDataBuilder
module_function
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
),
builds:
pipeline
.
builds
.
map
(
&
method
(
:build_hook_attrs
))
}
end
def
hook_attrs
(
pipeline
)
first_pending_build
=
pipeline
.
builds
.
first_pending
config_processor
=
pipeline
.
config_processor
{
id:
pipeline
.
id
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
sha:
pipeline
.
sha
,
before_sha:
pipeline
.
before_sha
,
status:
pipeline
.
status
,
stage:
first_pending_build
.
try
(
:stage
),
stages:
config_processor
.
try
(
:stages
),
created_at:
pipeline
.
created_at
,
finished_at:
pipeline
.
finished_at
,
duration:
pipeline
.
duration
}
end
def
build_hook_attrs
(
build
)
{
id:
build
.
id
,
stage:
build
.
stage
,
name:
build
.
name
,
status:
build
.
status
,
created_at:
build
.
created_at
,
started_at:
build
.
started_at
,
finished_at:
build
.
finished_at
,
when:
build
.
when
,
manual:
build
.
manual?
,
user:
build
.
user
.
try
(
:hook_attrs
),
runner:
build
.
runner
&&
runner_hook_attrs
(
build
.
runner
),
artifacts_file:
{
filename:
build
.
artifacts_file
.
filename
,
size:
build
.
artifacts_size
}
}
end
def
runner_hook_attrs
(
runner
)
{
id:
runner
.
id
,
description:
runner
.
description
,
active:
runner
.
active?
,
is_shared:
runner
.
is_shared?
}
end
end
end
end
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
deleted
100644 → 0
View file @
a79cd2a2
require
'spec_helper'
describe
Gitlab
::
DataBuilder
::
PipelineDataBuilder
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
status:
'success'
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
end
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
spec/models/project_services/slack_service_spec.rb
View file @
4323d24a
...
...
@@ -310,7 +310,7 @@ describe SlackService, models: true do
end
it
'calls Slack API for pipeline events'
do
data
=
Gitlab
::
DataBuilder
::
Pipeline
DataBuilder
.
build
(
pipeline
)
data
=
Gitlab
::
DataBuilder
::
Pipeline
.
build
(
pipeline
)
slack
.
execute
(
data
)
expect
(
WebMock
).
to
have_requested
(
:post
,
webhook_url
).
once
...
...
@@ -328,7 +328,7 @@ describe SlackService, models: true do
context
'with default to notify_only_broken_pipelines'
do
it
'does not call Slack API for pipeline events'
do
data
=
Gitlab
::
DataBuilder
::
Pipeline
DataBuilder
.
build
(
pipeline
)
data
=
Gitlab
::
DataBuilder
::
Pipeline
.
build
(
pipeline
)
result
=
slack
.
execute
(
data
)
expect
(
result
).
to
be_falsy
...
...
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