BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
391d1915
Commit
391d1915
authored
Jul 20, 2017
by
Mark Fletcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide pipeline schedule 'take ownership' for current owner
parent
5b73e0eb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
1 deletion
+76
-1
pipeline_schedule_policy.rb
app/policies/ci/pipeline_schedule_policy.rb
+8
-0
_pipeline_schedule.html.haml
.../projects/pipeline_schedules/_pipeline_schedule.html.haml
+2
-1
35285-user-interface-bugs-for-schedule-pipelines.yml
...ased/35285-user-interface-bugs-for-schedule-pipelines.yml
+5
-0
pipeline_schedule_policy_spec.rb
spec/policies/ci/pipeline_schedule_policy_spec.rb
+14
-0
_pipeline_schedule.html.haml_spec.rb
...s/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb
+47
-0
No files found.
app/policies/ci/pipeline_schedule_policy.rb
View file @
391d1915
...
...
@@ -10,6 +10,10 @@ module Ci
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 @@ module Ci
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 @
391d1915
...
...
@@ -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 @
391d1915
---
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 @
391d1915
...
...
@@ -88,5 +88,19 @@ describe Ci::PipelineSchedulePolicy, :models do
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 @
391d1915
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