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
57eb3954
Commit
57eb3954
authored
Feb 24, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not pass unsanitized params to issue move service
parent
4cbe87d5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
issues_controller.rb
app/controllers/projects/issues_controller.rb
+2
-1
move_service.rb
app/services/issues/move_service.rb
+2
-5
move_service_spec.rb
spec/services/issues/move_service_spec.rb
+7
-3
No files found.
app/controllers/projects/issues_controller.rb
View file @
57eb3954
...
...
@@ -88,7 +88,8 @@ class Projects::IssuesController < Projects::ApplicationController
def
update
@issue
=
Issues
::
UpdateService
.
new
(
project
,
current_user
,
issue_params
).
execute
(
issue
)
move_service
=
Issues
::
MoveService
.
new
(
project
,
current_user
,
params
.
require
(
:issue
).
permit!
,
@issue
)
move_service
=
Issues
::
MoveService
.
new
(
project
,
current_user
,
issue_params
,
@issue
,
params
[
'move_to_project_id'
])
if
move_service
.
move?
@issue
=
move_service
.
execute
...
...
app/services/issues/move_service.rb
View file @
57eb3954
module
Issues
class
MoveService
<
Issues
::
BaseService
def
initialize
(
project
,
current_user
,
params
,
issue
)
def
initialize
(
project
,
current_user
,
params
,
issue
,
new_project_id
)
super
(
project
,
current_user
,
params
)
@issue_old
=
issue
@issue_new
=
@issue_old
.
dup
@project_old
=
@project
if
params
[
'move_to_project_id'
]
@project_new
=
Project
.
find
(
params
[
'move_to_project_id'
])
end
@project_new
=
Project
.
find
(
new_project_id
)
if
new_project_id
end
def
execute
...
...
spec/services/issues/move_service_spec.rb
View file @
57eb3954
...
...
@@ -7,10 +7,14 @@ describe Issues::MoveService, services: true do
let
(
:old_project
)
{
create
(
:project
)
}
let
(
:old_issue
)
{
create
(
:issue
,
title:
title
,
description:
description
,
project:
old_project
)
}
let
(
:new_project
)
{
create
(
:project
)
}
let
(
:move_service
)
{
described_class
.
new
(
old_project
,
user
,
move_params
,
old_issue
)
}
let
(
:issue_params
)
{
old_issue
.
serializable_hash
}
let
(
:move_service
)
do
described_class
.
new
(
old_project
,
user
,
issue_params
,
old_issue
,
new_project_id
)
end
shared_context
'issue move requested'
do
let
(
:
move_params
)
{
{
'move_to_project_id'
=>
new_project
.
id
}
}
let
(
:
new_project_id
)
{
new_project
.
id
}
end
shared_context
'user can move issue'
do
...
...
@@ -108,7 +112,7 @@ describe Issues::MoveService, services: true do
end
context
'issue move not requested'
do
let
(
:
move_params
)
{
{}
}
let
(
:
new_project_id
)
{
nil
}
describe
'#move?'
do
subject
{
move_service
.
move?
}
...
...
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