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
Boxiang Sun
gitlab-ce
Commits
2cc8f43e
Commit
2cc8f43e
authored
May 05, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce generic manual action extended status class
parent
53219857
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
43 deletions
+57
-43
lib/gitlab/ci/status/build/action.rb
lib/gitlab/ci/status/build/action.rb
+23
-0
lib/gitlab/ci/status/build/factory.rb
lib/gitlab/ci/status/build/factory.rb
+2
-1
lib/gitlab/ci/status/build/play.rb
lib/gitlab/ci/status/build/play.rb
+1
-5
spec/lib/gitlab/ci/status/build/factory_spec.rb
spec/lib/gitlab/ci/status/build/factory_spec.rb
+18
-14
spec/lib/gitlab/ci/status/build/play_spec.rb
spec/lib/gitlab/ci/status/build/play_spec.rb
+13
-23
No files found.
lib/gitlab/ci/status/build/action.rb
0 → 100644
View file @
2cc8f43e
module
Gitlab
module
Ci
module
Status
module
Build
class
Action
<
SimpleDelegator
include
Status
::
Extended
def
label
if
has_action?
__getobj__
.
label
else
"
#{
__getobj__
.
label
}
(not allowed)"
end
end
def
self
.
matches?
(
build
,
user
)
build
.
action?
end
end
end
end
end
end
lib/gitlab/ci/status/build/factory.rb
View file @
2cc8f43e
...
...
@@ -8,7 +8,8 @@ module Gitlab
Status
::
Build
::
Retryable
],
[
Status
::
Build
::
FailedAllowed
,
Status
::
Build
::
Play
,
Status
::
Build
::
Stop
]]
Status
::
Build
::
Stop
],
[
Status
::
Build
::
Action
]]
end
def
self
.
common_helpers
...
...
lib/gitlab/ci/status/build/play.rb
View file @
2cc8f43e
...
...
@@ -6,11 +6,7 @@ module Gitlab
include
Status
::
Extended
def
label
if
has_action?
'manual play action'
else
'manual play action (not allowed)'
end
end
def
has_action?
...
...
spec/lib/gitlab/ci/status/build/factory_spec.rb
View file @
2cc8f43e
...
...
@@ -204,11 +204,12 @@ describe Gitlab::Ci::Status::Build::Factory do
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Play
]
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Play
,
Gitlab
::
Ci
::
Status
::
Build
::
Action
]
end
it
'fabricates a
play
detailed status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Play
it
'fabricates a
ction
detailed status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Action
end
it
'fabricates status with correct details'
do
...
...
@@ -247,21 +248,24 @@ describe Gitlab::Ci::Status::Build::Factory do
it
'matches correct extended statuses'
do
expect
(
factory
.
extended_statuses
)
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Stop
]
.
to
eq
[
Gitlab
::
Ci
::
Status
::
Build
::
Stop
,
Gitlab
::
Ci
::
Status
::
Build
::
Action
]
end
it
'fabricates a
stop
detailed status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Stop
it
'fabricates a
ction
detailed status'
do
expect
(
status
).
to
be_a
Gitlab
::
Ci
::
Status
::
Build
::
Action
end
context
'when user is not allowed to execute manual action'
do
it
'fabricates status with correct details'
do
expect
(
status
.
text
).
to
eq
'manual'
expect
(
status
.
group
).
to
eq
'manual'
expect
(
status
.
icon
).
to
eq
'icon_status_manual'
expect
(
status
.
favicon
).
to
eq
'favicon_status_manual'
expect
(
status
.
label
).
to
eq
'manual stop action
'
expect
(
status
.
label
).
to
eq
'manual stop action (not allowed)
'
expect
(
status
).
to
have_details
expect
(
status
).
to
have_action
expect
(
status
).
not_to
have_action
end
end
end
end
...
...
spec/lib/gitlab/ci/status/build/play_spec.rb
View file @
2cc8f43e
...
...
@@ -7,38 +7,28 @@ describe Gitlab::Ci::Status::Build::Play do
subject
{
described_class
.
new
(
status
)
}
context
'when user is allowed to update build'
do
context
'when user can push to branch'
do
before
{
build
.
project
.
add_master
(
user
)
}
describe
'#has_action?'
do
it
{
is_expected
.
to
have_action
}
end
describe
'#label'
do
it
'has a label that says it is a manual action'
do
expect
(
subject
.
label
).
to
eq
'manual play action'
end
end
describe
'#has_action?'
do
context
'when user is allowed to update build'
do
context
'when user can push to branch'
do
before
{
build
.
project
.
add_master
(
user
)
}
it
{
is_expected
.
to
have_action
}
end
context
'when user can not push to the branch'
do
before
{
build
.
project
.
add_developer
(
user
)
}
describe
'has_action?'
do
it
{
is_expected
.
not_to
have_action
}
end
describe
'#label'
do
it
'has a label that says user is not allowed to play it'
do
expect
(
subject
.
label
).
to
eq
'manual play action (not allowed)'
end
end
end
end
context
'when user is not allowed to update build'
do
describe
'#has_action?'
do
it
{
is_expected
.
not_to
have_action
}
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