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
752a4cce
Commit
752a4cce
authored
Oct 03, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for CommitStatus.exclude_ignored
parent
9c230600
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
16 deletions
+40
-16
app/models/commit_status.rb
app/models/commit_status.rb
+0
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+40
-15
No files found.
app/models/commit_status.rb
View file @
752a4cce
...
...
@@ -38,7 +38,6 @@ class CommitStatus < ActiveRecord::Base
where
(
"
#{
quoted_when
}
<> ? OR status <> ?"
,
'manual'
,
'skipped'
)
.
# We want to ignore skipped on_failure
where
(
"
#{
quoted_when
}
<> ? OR status <> ?"
,
'on_failure'
,
'skipped'
)
end
scope
:latest_ci_stages
,
->
{
latest
.
ordered
.
includes
(
project: :namespace
)
}
...
...
spec/models/commit_status_spec.rb
View file @
752a4cce
...
...
@@ -7,7 +7,11 @@ describe CommitStatus, models: true do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
)
end
let
(
:commit_status
)
{
create
(
:commit_status
,
pipeline:
pipeline
)
}
let
(
:commit_status
)
{
create_status
}
def
create_status
(
args
=
{})
create
(
:commit_status
,
args
.
merge
(
pipeline:
pipeline
))
end
it
{
is_expected
.
to
belong_to
(
:pipeline
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
...
...
@@ -125,32 +129,53 @@ describe CommitStatus, models: true do
describe
'.latest'
do
subject
{
CommitStatus
.
latest
.
order
(
:id
)
}
before
do
@commit1
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'bb'
,
status:
'running'
@commit2
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
@commit3
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'cc'
,
status:
'success'
@commit4
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'cc'
,
ref:
'bb'
,
status:
'success'
@commit5
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'bb'
,
status:
'success'
let
(
:statuses
)
do
[
create_status
(
name:
'aa'
,
ref:
'bb'
,
status:
'running'
),
create_status
(
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
),
create_status
(
name:
'aa'
,
ref:
'cc'
,
status:
'success'
),
create_status
(
name:
'cc'
,
ref:
'bb'
,
status:
'success'
),
create_status
(
name:
'aa'
,
ref:
'bb'
,
status:
'success'
)]
end
it
'returns unique statuses'
do
is_expected
.
to
eq
(
[
@commit4
,
@commit5
]
)
is_expected
.
to
eq
(
statuses
.
values_at
(
3
,
4
)
)
end
end
describe
'.running_or_pending'
do
subject
{
CommitStatus
.
running_or_pending
.
order
(
:id
)
}
before
do
@commit1
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'bb'
,
status:
'running'
@commit2
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
@commit3
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
nil
,
status:
'success'
@commit4
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'dd'
,
ref:
nil
,
status:
'failed'
@commit5
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'ee'
,
ref:
nil
,
status:
'canceled'
let
(
:statuses
)
do
[
create_status
(
name:
'aa'
,
ref:
'bb'
,
status:
'running'
),
create_status
(
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
),
create_status
(
name:
'aa'
,
ref:
nil
,
status:
'success'
),
create_status
(
name:
'dd'
,
ref:
nil
,
status:
'failed'
),
create_status
(
name:
'ee'
,
ref:
nil
,
status:
'canceled'
)]
end
it
'returns statuses that are running or pending'
do
is_expected
.
to
eq
([
@commit1
,
@commit2
])
is_expected
.
to
eq
(
statuses
.
values_at
(
0
,
1
))
end
end
describe
'.exclude_ignored'
do
subject
{
CommitStatus
.
exclude_ignored
.
order
(
:id
)
}
let
(
:statuses
)
do
[
create_status
(
when:
'manual'
,
status:
'skipped'
),
create_status
(
when:
'manual'
,
status:
'success'
),
create_status
(
when:
'manual'
,
status:
'failed'
),
create_status
(
when:
'on_failure'
,
status:
'skipped'
),
create_status
(
when:
'on_failure'
,
status:
'success'
),
create_status
(
when:
'on_failure'
,
status:
'failed'
),
create_status
(
allow_failure:
true
,
status:
'success'
),
create_status
(
allow_failure:
true
,
status:
'failed'
),
create_status
(
allow_failure:
false
,
status:
'success'
),
create_status
(
allow_failure:
false
,
status:
'failed'
)]
end
it
'returns statuses without what we want to ignore'
do
is_expected
.
to
eq
(
statuses
.
values_at
(
1
,
2
,
4
,
5
,
6
,
8
,
9
))
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