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
afc0ae5c
Commit
afc0ae5c
authored
Oct 03, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests. Check 'success' first (default status)
parent
752a4cce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
24 deletions
+21
-24
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+1
-1
spec/models/concerns/has_status_spec.rb
spec/models/concerns/has_status_spec.rb
+20
-23
No files found.
app/models/concerns/has_status.rb
View file @
afc0ae5c
...
@@ -22,8 +22,8 @@ module HasStatus
...
@@ -22,8 +22,8 @@ module HasStatus
canceled
=
scope
.
canceled
.
select
(
'count(*)'
).
to_sql
canceled
=
scope
.
canceled
.
select
(
'count(*)'
).
to_sql
"(CASE
"(CASE
WHEN (
#{
builds
}
)=(
#{
created
}
) THEN 'created'
WHEN (
#{
builds
}
)=(
#{
success
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
success
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
created
}
) THEN 'created'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
) THEN 'skipped'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
) THEN 'skipped'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
)+(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
)+(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
created
}
)+(
#{
skipped
}
)+(
#{
pending
}
) THEN 'pending'
WHEN (
#{
builds
}
)=(
#{
created
}
)+(
#{
skipped
}
)+(
#{
pending
}
) THEN 'pending'
...
...
spec/models/concerns/has_status_spec.rb
View file @
afc0ae5c
require
'spec_helper'
require
'spec_helper'
describe
HasStatus
do
describe
HasStatus
do
before
do
@object
=
Object
.
new
@object
.
extend
(
HasStatus
::
ClassMethods
)
end
describe
'.status'
do
describe
'.status'
do
before
do
subject
{
CommitStatus
.
status
}
allow
(
@object
).
to
receive
(
:all
).
and_return
(
CommitStatus
.
where
(
id:
statuses
))
end
subject
{
@object
.
status
}
shared_examples
'build status summary'
do
shared_examples
'build status summary'
do
context
'all successful'
do
context
'all successful'
do
let
(
:statuses
)
{
Array
.
new
(
2
)
{
create
(
type
,
status: :success
)
}
}
let
!
(
:statuses
)
{
Array
.
new
(
2
)
{
create
(
type
,
status: :success
)
}
}
it
{
is_expected
.
to
eq
'success'
}
it
{
is_expected
.
to
eq
'success'
}
end
end
context
'at least one failed'
do
context
'at least one failed'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :failed
)]
[
create
(
type
,
status: :success
),
create
(
type
,
status: :failed
)]
end
end
...
@@ -28,7 +19,7 @@ describe HasStatus do
...
@@ -28,7 +19,7 @@ describe HasStatus do
end
end
context
'at least one running'
do
context
'at least one running'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :running
)]
[
create
(
type
,
status: :success
),
create
(
type
,
status: :running
)]
end
end
...
@@ -36,7 +27,7 @@ describe HasStatus do
...
@@ -36,7 +27,7 @@ describe HasStatus do
end
end
context
'at least one pending'
do
context
'at least one pending'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :pending
)]
[
create
(
type
,
status: :success
),
create
(
type
,
status: :pending
)]
end
end
...
@@ -44,7 +35,7 @@ describe HasStatus do
...
@@ -44,7 +35,7 @@ describe HasStatus do
end
end
context
'success and failed but allowed to fail'
do
context
'success and failed but allowed to fail'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
[
create
(
type
,
status: :success
),
create
(
type
,
status: :failed
,
allow_failure:
true
)]
create
(
type
,
status: :failed
,
allow_failure:
true
)]
end
end
...
@@ -53,12 +44,15 @@ describe HasStatus do
...
@@ -53,12 +44,15 @@ describe HasStatus do
end
end
context
'one failed but allowed to fail'
do
context
'one failed but allowed to fail'
do
let
(
:statuses
)
{
[
create
(
type
,
status: :failed
,
allow_failure:
true
)]
}
let!
(
:statuses
)
do
[
create
(
type
,
status: :failed
,
allow_failure:
true
)]
end
it
{
is_expected
.
to
eq
'success'
}
it
{
is_expected
.
to
eq
'success'
}
end
end
context
'success and canceled'
do
context
'success and canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :canceled
)]
[
create
(
type
,
status: :success
),
create
(
type
,
status: :canceled
)]
end
end
...
@@ -66,7 +60,7 @@ describe HasStatus do
...
@@ -66,7 +60,7 @@ describe HasStatus do
end
end
context
'one failed and one canceled'
do
context
'one failed and one canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :failed
),
create
(
type
,
status: :canceled
)]
[
create
(
type
,
status: :failed
),
create
(
type
,
status: :canceled
)]
end
end
...
@@ -74,7 +68,7 @@ describe HasStatus do
...
@@ -74,7 +68,7 @@ describe HasStatus do
end
end
context
'one failed but allowed to fail and one canceled'
do
context
'one failed but allowed to fail and one canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :failed
,
allow_failure:
true
),
[
create
(
type
,
status: :failed
,
allow_failure:
true
),
create
(
type
,
status: :canceled
)]
create
(
type
,
status: :canceled
)]
end
end
...
@@ -83,7 +77,7 @@ describe HasStatus do
...
@@ -83,7 +77,7 @@ describe HasStatus do
end
end
context
'one running one canceled'
do
context
'one running one canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :running
),
create
(
type
,
status: :canceled
)]
[
create
(
type
,
status: :running
),
create
(
type
,
status: :canceled
)]
end
end
...
@@ -91,14 +85,15 @@ describe HasStatus do
...
@@ -91,14 +85,15 @@ describe HasStatus do
end
end
context
'all canceled'
do
context
'all canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :canceled
),
create
(
type
,
status: :canceled
)]
[
create
(
type
,
status: :canceled
),
create
(
type
,
status: :canceled
)]
end
end
it
{
is_expected
.
to
eq
'canceled'
}
it
{
is_expected
.
to
eq
'canceled'
}
end
end
context
'success and canceled but allowed to fail'
do
context
'success and canceled but allowed to fail'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
[
create
(
type
,
status: :success
),
create
(
type
,
status: :canceled
,
allow_failure:
true
)]
create
(
type
,
status: :canceled
,
allow_failure:
true
)]
end
end
...
@@ -107,7 +102,7 @@ describe HasStatus do
...
@@ -107,7 +102,7 @@ describe HasStatus do
end
end
context
'one finished and second running but allowed to fail'
do
context
'one finished and second running but allowed to fail'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
[
create
(
type
,
status: :success
),
create
(
type
,
status: :running
,
allow_failure:
true
)]
create
(
type
,
status: :running
,
allow_failure:
true
)]
end
end
...
@@ -118,11 +113,13 @@ describe HasStatus do
...
@@ -118,11 +113,13 @@ describe HasStatus do
context
'ci build statuses'
do
context
'ci build statuses'
do
let
(
:type
)
{
:ci_build
}
let
(
:type
)
{
:ci_build
}
it_behaves_like
'build status summary'
it_behaves_like
'build status summary'
end
end
context
'generic commit statuses'
do
context
'generic commit statuses'
do
let
(
:type
)
{
:generic_commit_status
}
let
(
:type
)
{
:generic_commit_status
}
it_behaves_like
'build status summary'
it_behaves_like
'build status summary'
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