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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
6e8ea52b
Commit
6e8ea52b
authored
Jun 26, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functionality and security.
parent
e364c118
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
312 additions
and
239 deletions
+312
-239
app/controllers/projects/pipeline_schedules_controller.rb
app/controllers/projects/pipeline_schedules_controller.rb
+2
-0
app/policies/ci/pipeline_schedule_policy.rb
app/policies/ci/pipeline_schedule_policy.rb
+6
-16
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+304
-223
No files found.
app/controllers/projects/pipeline_schedules_controller.rb
View file @
6e8ea52b
...
@@ -33,6 +33,8 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
...
@@ -33,6 +33,8 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
end
end
def
update
def
update
return
access_denied!
unless
can?
(
current_user
,
:update_pipeline_schedule
,
schedule
)
if
Ci
::
CreatePipelineScheduleService
if
Ci
::
CreatePipelineScheduleService
.
new
(
@project
,
current_user
,
schedule_params
).
update
(
schedule
)
.
new
(
@project
,
current_user
,
schedule_params
).
update
(
schedule
)
redirect_to
namespace_project_pipeline_schedules_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
)
redirect_to
namespace_project_pipeline_schedules_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
)
...
...
app/policies/ci/pipeline_schedule_policy.rb
View file @
6e8ea52b
...
@@ -2,24 +2,14 @@ module Ci
...
@@ -2,24 +2,14 @@ module Ci
class
PipelineSchedulePolicy
<
PipelinePolicy
class
PipelineSchedulePolicy
<
PipelinePolicy
alias_method
:pipeline_schedule
,
:subject
alias_method
:pipeline_schedule
,
:subject
condition
(
:protected_action
)
do
def
rules
owned_by_developer?
&&
owned_by_another?
super
end
rule
{
protected_action
}.
prevent
:update_pipeline_schedule
private
def
owned_by_developer?
return
false
unless
@user
pipeline_schedule
.
project
.
team
.
developer?
(
@user
)
end
def
owned_by_another?
access
=
pipeline_schedule
.
project
.
team
.
max_member_access
(
user
.
id
)
return
false
unless
@user
!
pipeline_schedule
.
owned_by?
(
@user
)
if
access
==
Gitlab
::
Access
::
DEVELOPER
&&
pipeline_schedule
.
owner
!=
user
cannot!
:update_pipeline_schedule
end
end
end
end
end
end
end
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
6e8ea52b
This diff is collapsed.
Click to expand it.
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