Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
fb698e122ba1
Commit
849558ef
authored
Jul 20, 2017
by
Mark Fletcher
Browse files
Hide pipeline schedule 'take ownership' for current owner
parent
456b31523866
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/policies/ci/pipeline_schedule_policy.rb
View file @
fb698e12
...
...
@@ -10,6 +10,10 @@ class PipelineSchedulePolicy < PipelinePolicy
can?
(
:developer_access
)
&&
pipeline_schedule
.
owned_by?
(
@user
)
end
condition
(
:non_owner_of_schedule
)
do
!
pipeline_schedule
.
owned_by?
(
@user
)
end
rule
{
can?
(
:developer_access
)
}.
policy
do
enable
:play_pipeline_schedule
end
...
...
@@ -19,6 +23,10 @@ class PipelineSchedulePolicy < PipelinePolicy
enable
:admin_pipeline_schedule
end
rule
{
can?
(
:master_access
)
&
non_owner_of_schedule
}.
policy
do
enable
:take_ownership_pipeline_schedule
end
rule
{
protected_ref
}.
prevent
:play_pipeline_schedule
end
end
app/views/projects/pipeline_schedules/_pipeline_schedule.html.haml
View file @
fb698e12
...
...
@@ -29,9 +29,10 @@
-
if
can?
(
current_user
,
:play_pipeline_schedule
,
pipeline_schedule
)
=
link_to
play_pipeline_schedule_path
(
pipeline_schedule
),
method: :post
,
title:
s_
(
'Play'
),
class:
'btn'
do
=
icon
(
'play'
)
-
if
can?
(
current_user
,
:
update
_pipeline_schedule
,
pipeline_schedule
)
-
if
can?
(
current_user
,
:
take_ownership
_pipeline_schedule
,
pipeline_schedule
)
=
link_to
take_ownership_pipeline_schedule_path
(
pipeline_schedule
),
method: :post
,
title:
s_
(
'PipelineSchedules|Take ownership'
),
class:
'btn'
do
=
s_
(
'PipelineSchedules|Take ownership'
)
-
if
can?
(
current_user
,
:update_pipeline_schedule
,
pipeline_schedule
)
=
link_to
edit_pipeline_schedule_path
(
pipeline_schedule
),
title:
_
(
'Edit'
),
class:
'btn'
do
=
icon
(
'pencil'
)
-
if
can?
(
current_user
,
:admin_pipeline_schedule
,
pipeline_schedule
)
...
...
changelogs/unreleased/35285-user-interface-bugs-for-schedule-pipelines.yml
0 → 100644
View file @
fb698e12
---
title
:
Hide pipeline schedule take ownership for current owner
merge_request
:
12986
author
:
type
:
fixed
spec/policies/ci/pipeline_schedule_policy_spec.rb
View file @
fb698e12
...
...
@@ -88,5 +88,19 @@
expect
(
policy
).
to
be_allowed
:admin_pipeline_schedule
end
end
describe
'rules for non-owner of schedule'
do
let
(
:owner
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
owner
)
project
.
add_master
(
user
)
pipeline_schedule
.
update
(
owner:
owner
)
end
it
'includes abilities to take ownership'
do
expect
(
policy
).
to
be_allowed
:take_ownership_pipeline_schedule
end
end
end
end
spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb
0 → 100644
View file @
fb698e12
require
'spec_helper'
describe
'projects/pipeline_schedules/_pipeline_schedule'
do
let
(
:owner
)
{
create
(
:user
)
}
let
(
:master
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline_schedule
)
{
create
(
:ci_pipeline_schedule
,
:nightly
,
project:
project
)
}
before
do
assign
(
:project
,
project
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
view
).
to
receive
(
:pipeline_schedule
).
and_return
(
pipeline_schedule
)
allow
(
view
).
to
receive
(
:can?
).
and_return
(
true
)
end
context
'taking ownership of schedule'
do
context
'when non-owner is signed in'
do
let
(
:user
)
{
master
}
before
do
allow
(
view
).
to
receive
(
:can?
).
with
(
master
,
:take_ownership_pipeline_schedule
,
pipeline_schedule
).
and_return
(
true
)
end
it
'non-owner can take ownership of pipeline'
do
render
expect
(
rendered
).
to
have_link
(
'Take ownership'
)
end
end
context
'when owner is signed in'
do
let
(
:user
)
{
owner
}
before
do
allow
(
view
).
to
receive
(
:can?
).
with
(
owner
,
:take_ownership_pipeline_schedule
,
pipeline_schedule
).
and_return
(
false
)
end
it
'owner cannot take ownership of pipeline'
do
render
expect
(
rendered
).
not_to
have_link
(
'Take ownership'
)
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