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
Jérome Perrin
gitlab-ce
Commits
8d1b7f95
Commit
8d1b7f95
authored
Feb 22, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add issue move ability and use it in move service
parent
14c983fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
17 deletions
+65
-17
app/models/ability.rb
app/models/ability.rb
+2
-1
app/services/issues/move_service.rb
app/services/issues/move_service.rb
+3
-6
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+60
-10
No files found.
app/models/ability.rb
View file @
8d1b7f95
...
@@ -222,7 +222,8 @@ class Ability
...
@@ -222,7 +222,8 @@ class Ability
:admin_wiki
,
:admin_wiki
,
:admin_project
,
:admin_project
,
:admin_commit_status
,
:admin_commit_status
,
:admin_build
:admin_build
,
:move_issue
]
]
end
end
...
...
app/services/issues/move_service.rb
View file @
8d1b7f95
...
@@ -34,17 +34,14 @@ module Issues
...
@@ -34,17 +34,14 @@ module Issues
end
end
def
move?
def
move?
return
false
unless
@project_new
@project_new
&&
can_move?
return
false
unless
@issue_new
return
false
unless
can_move?
true
end
end
private
private
def
can_move?
def
can_move?
true
can?
(
@current_user
,
:move_issue
,
@project_old
)
&&
can?
(
@current_user
,
:move_issue
,
@project_new
)
end
end
def
open_new_issue
def
open_new_issue
...
...
spec/services/issues/move_service_spec.rb
View file @
8d1b7f95
...
@@ -5,14 +5,25 @@ describe Issues::MoveService, services: true do
...
@@ -5,14 +5,25 @@ describe Issues::MoveService, services: true do
let
(
:title
)
{
'Some issue'
}
let
(
:title
)
{
'Some issue'
}
let
(
:description
)
{
'Some issue description'
}
let
(
:description
)
{
'Some issue description'
}
let
(
:old_issue
)
{
create
(
:issue
,
title:
title
,
description:
description
)
}
let
(
:old_issue
)
{
create
(
:issue
,
title:
title
,
description:
description
)
}
let
(
:
current
_project
)
{
old_issue
.
project
}
let
(
:
old
_project
)
{
old_issue
.
project
}
let
(
:new_project
)
{
create
(
:project
)
}
let
(
:new_project
)
{
create
(
:project
)
}
let
(
:move_params
)
{
{
'move_to_project_id'
=>
new_project
.
id
}
}
let
(
:move_service
)
{
described_class
.
new
(
old_project
,
user
,
move_params
,
old_issue
)
}
let
(
:move_service
)
{
described_class
.
new
(
current_project
,
user
,
move_params
,
old_issue
)
}
before
{
current_project
.
team
<<
[
user
,
:master
]
}
shared_context
'issue move requested'
do
let
(
:move_params
)
{
{
'move_to_project_id'
=>
new_project
.
id
}
}
end
shared_context
'user can move issue'
do
before
do
old_project
.
team
<<
[
user
,
:master
]
new_project
.
team
<<
[
user
,
:master
]
end
end
context
'issue movable'
do
context
'issue movable'
do
include_context
'issue move requested'
include_context
'user can move issue'
describe
'#move?'
do
describe
'#move?'
do
subject
{
move_service
.
move?
}
subject
{
move_service
.
move?
}
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
...
@@ -53,7 +64,7 @@ describe Issues::MoveService, services: true do
...
@@ -53,7 +64,7 @@ describe Issues::MoveService, services: true do
end
end
before
do
before
do
note_params
=
{
noteable:
old_issue
,
project:
current
_project
,
author:
user
}
note_params
=
{
noteable:
old_issue
,
project:
old
_project
,
author:
user
}
create
(
:system_note
,
note_params
.
merge
(
note:
note_contents
.
first
))
create
(
:system_note
,
note_params
.
merge
(
note:
note_contents
.
first
))
create
(
:note
,
note_params
.
merge
(
note:
note_contents
.
second
))
create
(
:note
,
note_params
.
merge
(
note:
note_contents
.
second
))
create
(
:system_note
,
note_params
.
merge
(
note:
note_contents
.
third
))
create
(
:system_note
,
note_params
.
merge
(
note:
note_contents
.
third
))
...
@@ -74,12 +85,51 @@ describe Issues::MoveService, services: true do
...
@@ -74,12 +85,51 @@ describe Issues::MoveService, services: true do
end
end
end
end
context
'issue not movable'
do
context
'issue move not requested'
do
context
'move not requested'
do
let
(
:move_params
)
{
{}
}
let
(
:move_params
)
{
{}
}
describe
'#move?'
do
subject
{
move_service
.
move?
}
context
'user do not have permissions to move issue'
do
it
{
is_expected
.
to
be_falsey
}
end
context
'user has permissions to move issue'
do
include_context
'user can move issue'
it
{
is_expected
.
to
be_falsey
}
end
end
end
describe
'move permissions'
do
include_context
'issue move requested'
describe
'#move?'
do
subject
{
move_service
.
move?
}
context
'user is master in both projects'
do
include_context
'user can move issue'
it
{
is_expected
.
to
be_truthy
}
end
context
'user is master only in new project'
do
before
{
new_project
.
team
<<
[
user
,
:master
]
}
it
{
is_expected
.
to
be_falsey
}
end
context
'user is master only in old project'
do
before
{
old_project
.
team
<<
[
user
,
:master
]
}
it
{
is_expected
.
to
be_falsey
}
end
context
'user is master in one project and developer in another'
do
before
do
new_project
.
team
<<
[
user
,
:developer
]
old_project
.
team
<<
[
user
,
:master
]
end
describe
'#move?'
do
subject
{
move_service
.
move?
}
it
{
is_expected
.
to
be_falsey
}
it
{
is_expected
.
to
be_falsey
}
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