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
a91a95b2
Commit
a91a95b2
authored
Dec 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for build cancelable/retryable statuses
parent
65c3bfe6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
172 additions
and
0 deletions
+172
-0
spec/lib/gitlab/ci/status/build/cancelable_spec.rb
spec/lib/gitlab/ci/status/build/cancelable_spec.rb
+86
-0
spec/lib/gitlab/ci/status/build/retryable_spec.rb
spec/lib/gitlab/ci/status/build/retryable_spec.rb
+86
-0
No files found.
spec/lib/gitlab/ci/status/build/cancelable_spec.rb
0 → 100644
View file @
a91a95b2
require
'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Build
::
Cancelable
do
let
(
:status
)
{
double
(
'core status'
)
}
let
(
:user
)
{
double
(
'user'
)
}
subject
do
described_class
.
new
(
status
)
end
describe
'#text'
do
it
'does not override status text'
do
expect
(
status
).
to
receive
(
:text
)
subject
.
text
end
end
describe
'#icon'
do
it
'does not override status icon'
do
expect
(
status
).
to
receive
(
:icon
)
subject
.
icon
end
end
describe
'#label'
do
it
'does not override status label'
do
expect
(
status
).
to
receive
(
:label
)
subject
.
label
end
end
describe
'action details'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:status
)
{
Gitlab
::
Ci
::
Status
::
Core
.
new
(
build
,
user
)
}
describe
'#has_action?'
do
context
'when user is allowed to update build'
do
before
{
build
.
project
.
team
<<
[
user
,
:developer
]
}
it
{
is_expected
.
to
have_action
}
end
context
'when user is not allowed to update build'
do
it
{
is_expected
.
not_to
have_action
}
end
end
describe
'#action_path'
do
it
{
expect
(
subject
.
action_path
).
to
include
"
#{
build
.
id
}
/cancel"
}
end
describe
'#action_icon'
do
it
{
expect
(
subject
.
action_icon
).
to
eq
'ban'
}
end
describe
'#action_title'
do
it
{
expect
(
subject
.
action_title
).
to
eq
'Cancel'
}
end
end
describe
'.matches?'
do
subject
{
described_class
.
matches?
(
build
,
user
)
}
context
'build is cancelable'
do
let
(
:build
)
do
create
(
:ci_build
,
:running
)
end
it
'is a correct match'
do
expect
(
subject
).
to
be
true
end
end
context
'when build is not cancelable'
do
let
(
:build
)
{
create
(
:ci_build
,
:success
)
}
it
'does not match'
do
expect
(
subject
).
to
be
false
end
end
end
end
spec/lib/gitlab/ci/status/build/retryable_spec.rb
0 → 100644
View file @
a91a95b2
require
'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
Build
::
Retryable
do
let
(
:status
)
{
double
(
'core status'
)
}
let
(
:user
)
{
double
(
'user'
)
}
subject
do
described_class
.
new
(
status
)
end
describe
'#text'
do
it
'does not override status text'
do
expect
(
status
).
to
receive
(
:text
)
subject
.
text
end
end
describe
'#icon'
do
it
'does not override status icon'
do
expect
(
status
).
to
receive
(
:icon
)
subject
.
icon
end
end
describe
'#label'
do
it
'does not override status label'
do
expect
(
status
).
to
receive
(
:label
)
subject
.
label
end
end
describe
'action details'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:status
)
{
Gitlab
::
Ci
::
Status
::
Core
.
new
(
build
,
user
)
}
describe
'#has_action?'
do
context
'when user is allowed to update build'
do
before
{
build
.
project
.
team
<<
[
user
,
:developer
]
}
it
{
is_expected
.
to
have_action
}
end
context
'when user is not allowed to update build'
do
it
{
is_expected
.
not_to
have_action
}
end
end
describe
'#action_path'
do
it
{
expect
(
subject
.
action_path
).
to
include
"
#{
build
.
id
}
/retry"
}
end
describe
'#action_icon'
do
it
{
expect
(
subject
.
action_icon
).
to
eq
'refresh'
}
end
describe
'#action_title'
do
it
{
expect
(
subject
.
action_title
).
to
eq
'Retry'
}
end
end
describe
'.matches?'
do
subject
{
described_class
.
matches?
(
build
,
user
)
}
context
'build is retryable'
do
let
(
:build
)
do
create
(
:ci_build
,
:success
)
end
it
'is a correct match'
do
expect
(
subject
).
to
be
true
end
end
context
'when build is not retryable'
do
let
(
:build
)
{
create
(
:ci_build
,
:running
)
}
it
'does not match'
do
expect
(
subject
).
to
be
false
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