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
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
canceled
=
scope
.
canceled
.
select
(
'count(*)'
).
to_sql
"(CASE
WHEN (
#{
builds
}
)=(
#{
created
}
) THEN 'created'
WHEN (
#{
builds
}
)=(
#{
success
}
) THEN 'success'
WHEN (
#{
builds
}
)=(
#{
created
}
) THEN 'created'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
) THEN 'skipped'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
)+(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
created
}
)+(
#{
skipped
}
)+(
#{
pending
}
) THEN 'pending'
...
...
spec/models/concerns/has_status_spec.rb
View file @
afc0ae5c
require
'spec_helper'
describe
HasStatus
do
before
do
@object
=
Object
.
new
@object
.
extend
(
HasStatus
::
ClassMethods
)
end
describe
'.status'
do
before
do
allow
(
@object
).
to
receive
(
:all
).
and_return
(
CommitStatus
.
where
(
id:
statuses
))
end
subject
{
@object
.
status
}
subject
{
CommitStatus
.
status
}
shared_examples
'build status summary'
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'
}
end
context
'at least one failed'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :failed
)]
end
...
...
@@ -28,7 +19,7 @@ describe HasStatus do
end
context
'at least one running'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :running
)]
end
...
...
@@ -36,7 +27,7 @@ describe HasStatus do
end
context
'at least one pending'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :pending
)]
end
...
...
@@ -44,7 +35,7 @@ describe HasStatus do
end
context
'success and failed but allowed to fail'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :failed
,
allow_failure:
true
)]
end
...
...
@@ -53,12 +44,15 @@ describe HasStatus do
end
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'
}
end
context
'success and canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :canceled
)]
end
...
...
@@ -66,7 +60,7 @@ describe HasStatus do
end
context
'one failed and one canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :failed
),
create
(
type
,
status: :canceled
)]
end
...
...
@@ -74,7 +68,7 @@ describe HasStatus do
end
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: :canceled
)]
end
...
...
@@ -83,7 +77,7 @@ describe HasStatus do
end
context
'one running one canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :running
),
create
(
type
,
status: :canceled
)]
end
...
...
@@ -91,14 +85,15 @@ describe HasStatus do
end
context
'all canceled'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :canceled
),
create
(
type
,
status: :canceled
)]
end
it
{
is_expected
.
to
eq
'canceled'
}
end
context
'success and canceled but allowed to fail'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :canceled
,
allow_failure:
true
)]
end
...
...
@@ -107,7 +102,7 @@ describe HasStatus do
end
context
'one finished and second running but allowed to fail'
do
let
(
:statuses
)
do
let
!
(
:statuses
)
do
[
create
(
type
,
status: :success
),
create
(
type
,
status: :running
,
allow_failure:
true
)]
end
...
...
@@ -118,11 +113,13 @@ describe HasStatus do
context
'ci build statuses'
do
let
(
:type
)
{
:ci_build
}
it_behaves_like
'build status summary'
end
context
'generic commit statuses'
do
let
(
:type
)
{
:generic_commit_status
}
it_behaves_like
'build status summary'
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