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
Léo-Paul Géneau
gitlab-ce
Commits
99928aca
Commit
99928aca
authored
Aug 11, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhance a pipeline event tests to analyse number of returned builds
parent
ffa75a49
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
22 deletions
+25
-22
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
+6
-2
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+19
-20
No files found.
spec/lib/gitlab/data_builder/pipeline_data_builder_spec.rb
View file @
99928aca
...
@@ -3,11 +3,15 @@ require 'spec_helper'
...
@@ -3,11 +3,15 @@ require 'spec_helper'
describe
Gitlab
::
DataBuilder
::
PipelineDataBuilder
do
describe
Gitlab
::
DataBuilder
::
PipelineDataBuilder
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
create
(
:ci_pipeline
,
project:
project
,
status:
'success'
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
status:
'success'
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
)
end
end
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
describe
'.build'
do
describe
'.build'
do
...
...
spec/models/ci/pipeline_spec.rb
View file @
99928aca
...
@@ -2,7 +2,7 @@ require 'spec_helper'
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Ci
::
Pipeline
,
models:
true
do
describe
Ci
::
Pipeline
,
models:
true
do
let
(
:project
)
{
FactoryGirl
.
create
:empty_project
}
let
(
:project
)
{
FactoryGirl
.
create
:empty_project
}
let
(
:pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
,
project:
project
}
let
(
:pipeline
)
{
FactoryGirl
.
create
:ci_
empty_
pipeline
,
project:
project
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
...
@@ -18,6 +18,8 @@ describe Ci::Pipeline, models: true do
...
@@ -18,6 +18,8 @@ describe Ci::Pipeline, models: true do
it
{
is_expected
.
to
respond_to
:git_author_email
}
it
{
is_expected
.
to
respond_to
:git_author_email
}
it
{
is_expected
.
to
respond_to
:short_sha
}
it
{
is_expected
.
to
respond_to
:short_sha
}
it
{
is_expected
.
to
delegate_method
(
:stages
).
to
(
:statuses
)
}
describe
'#valid_commit_sha'
do
describe
'#valid_commit_sha'
do
context
'commit.sha can not start with 00000000'
do
context
'commit.sha can not start with 00000000'
do
before
do
before
do
...
@@ -261,43 +263,40 @@ describe Ci::Pipeline, models: true do
...
@@ -261,43 +263,40 @@ describe Ci::Pipeline, models: true do
end
end
before
do
before
do
WebMock
.
stub_request
(
:post
,
hook
.
url
)
pipeline
.
touch
ProjectWebHookWorker
.
drain
ProjectWebHookWorker
.
drain
end
end
context
'with pipeline hooks enabled'
do
context
'with pipeline hooks enabled'
do
let
(
:enabled
)
{
true
}
let
(
:enabled
)
{
true
}
it
'executes pipeline_hook after touched'
do
expect
(
WebMock
).
to
have_requested
(
:post
,
hook
.
url
).
once
end
context
'with multiple builds'
do
context
'with multiple builds'
do
let
(
:build_a
)
{
create_build
(
'a'
)
}
let
!
(
:build_a
)
{
create_build
(
'a'
)
}
let
(
:build_b
)
{
create_build
(
'b'
)
}
let
!
(
:build_b
)
{
create_build
(
'b'
)
}
before
do
it
'fires exactly 3 hooks'
do
stub_request
(
'pending'
)
build_a
.
queue
build_b
.
queue
stub_request
(
'running'
)
build_a
.
run
build_a
.
run
build_b
.
run
build_b
.
run
stub_request
(
'success'
)
build_a
.
success
build_a
.
success
build_b
.
success
build_b
.
success
end
end
it
'fires 3 hooks'
do
%w(pending running success)
.
each
do
|
status
|
expect
(
WebMock
).
to
requested
(
status
)
end
end
def
create_build
(
name
)
def
create_build
(
name
)
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
name:
name
)
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
name:
name
)
end
end
def
requested
(
status
)
def
stub_request
(
status
)
have_requested
(
:post
,
hook
.
url
).
with
do
|
req
|
WebMock
.
stub_request
(
:post
,
hook
.
url
).
with
do
|
req
|
JSON
.
parse
(
req
.
body
)[
'object_attributes'
][
'status'
]
==
status
json_body
=
JSON
.
parse
(
req
.
body
)
end
.
once
json_body
[
'object_attributes'
][
'status'
]
==
status
&&
json_body
[
'builds'
].
length
==
2
end
end
end
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