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
1edb1746
Commit
1edb1746
authored
Nov 21, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer a description for it and split the case:
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7508#note_18730091
parent
ca639c9b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
29 deletions
+48
-29
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+15
-7
has_status_spec.rb
spec/models/concerns/has_status_spec.rb
+33
-22
No files found.
spec/models/ci/pipeline_spec.rb
View file @
1edb1746
...
...
@@ -403,15 +403,15 @@ describe Ci::Pipeline, models: true do
end
describe
'#cancelable?'
do
subject
{
pipeline
.
cancelable?
}
%i[created running pending]
.
each
do
|
status
|
context
"when there is a build
#{
status
}
"
do
before
do
create
(
:ci_build
,
status
,
pipeline:
pipeline
)
end
it
{
is_expected
.
to
be_truthy
}
it
'is cancelable'
do
expect
(
pipeline
.
cancelable?
).
to
be_truthy
end
end
context
"when there is an external job
#{
status
}
"
do
...
...
@@ -419,7 +419,9 @@ describe Ci::Pipeline, models: true do
create
(
:generic_commit_status
,
status
,
pipeline:
pipeline
)
end
it
{
is_expected
.
to
be_truthy
}
it
'is cancelable'
do
expect
(
pipeline
.
cancelable?
).
to
be_truthy
end
end
%i[success failed canceled]
.
each
do
|
status2
|
...
...
@@ -430,7 +432,9 @@ describe Ci::Pipeline, models: true do
create
(
build
.
sample
,
status2
,
pipeline:
pipeline
)
end
it
{
is_expected
.
to
be_truthy
}
it
'is cancelable'
do
expect
(
pipeline
.
cancelable?
).
to
be_truthy
end
end
end
end
...
...
@@ -441,7 +445,9 @@ describe Ci::Pipeline, models: true do
create
(
:ci_build
,
status
,
pipeline:
pipeline
)
end
it
{
is_expected
.
to
be_falsey
}
it
'is not cancelable'
do
expect
(
pipeline
.
cancelable?
).
to
be_falsey
end
end
context
"when there is an external job
#{
status
}
"
do
...
...
@@ -449,7 +455,9 @@ describe Ci::Pipeline, models: true do
create
(
:generic_commit_status
,
status
,
pipeline:
pipeline
)
end
it
{
is_expected
.
to
be_falsey
}
it
'is not cancelable'
do
expect
(
pipeline
.
cancelable?
).
to
be_falsey
end
end
end
end
...
...
spec/models/concerns/has_status_spec.rb
View file @
1edb1746
...
...
@@ -134,20 +134,20 @@ describe HasStatus do
let!
(
:job
)
{
create
(
type
,
status
)
}
describe
".
#{
status
}
"
do
subject
{
CommitStatus
.
public_send
(
status
).
all
}
it
{
is_expected
.
to
contain_exactly
(
job
)
}
it
'contains the job'
do
expect
(
CommitStatus
.
public_send
(
status
).
all
).
to
contain_exactly
(
job
)
end
end
describe
'.relevant'
do
subject
{
CommitStatus
.
relevant
.
all
}
it
do
case
status
when
:created
is_expected
.
to
be_empty
if
status
==
:created
it
'contains nothing'
do
expect
(
CommitStatus
.
relevant
.
all
).
to
be_empty
end
else
is_expected
.
to
contain_exactly
(
job
)
it
'contains the job'
do
expect
(
CommitStatus
.
relevant
.
all
).
to
contain_exactly
(
job
)
end
end
end
...
...
@@ -161,43 +161,54 @@ describe HasStatus do
end
context
'for scope with more statuses'
do
shared_examples
'
having a job'
do
|
type
,
status
,
excluded_
status
|
shared_examples
'
containing the job'
do
|
type
,
status
|
context
"when it's
#{
status
}
#{
type
}
job"
do
let!
(
:job
)
{
create
(
type
,
status
)
}
it
do
case
status
when
excluded_status
is_expected
.
to
be_empty
else
it
'contains the job'
do
is_expected
.
to
contain_exactly
(
job
)
end
end
end
shared_examples
'not containing the job'
do
|
type
,
status
|
context
"when it's
#{
status
}
#{
type
}
job"
do
let!
(
:job
)
{
create
(
type
,
status
)
}
it
'contains nothing'
do
is_expected
.
to
be_empty
end
end
end
describe
'.running_or_pending'
do
subject
{
CommitStatus
.
running_or_pending
}
%i[running pending
created
]
.
each
do
|
status
|
it_behaves_like
'
having a job'
,
random_type
,
status
,
:created
%i[running pending]
.
each
do
|
status
|
it_behaves_like
'
containing the job'
,
random_type
,
status
end
it_behaves_like
'not containing the job'
,
random_type
,
:created
end
describe
'.finished'
do
subject
{
CommitStatus
.
finished
}
%i[success failed canceled
created
]
.
each
do
|
status
|
it_behaves_like
'
having a job'
,
random_type
,
status
,
:created
%i[success failed canceled]
.
each
do
|
status
|
it_behaves_like
'
containing the job'
,
random_type
,
status
end
it_behaves_like
'not containing the job'
,
random_type
,
:created
end
describe
'.cancelable'
do
subject
{
CommitStatus
.
cancelable
}
%i[running pending created
failed
]
.
each
do
|
status
|
it_behaves_like
'
having a job'
,
random_type
,
status
,
:failed
%i[running pending created]
.
each
do
|
status
|
it_behaves_like
'
containing the job'
,
random_type
,
status
end
it_behaves_like
'not containing the job'
,
random_type
,
:failed
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