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
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
17 deletions
+65
-17
ability.rb
app/models/ability.rb
+2
-1
move_service.rb
app/services/issues/move_service.rb
+3
-6
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
:admin_wiki
,
:admin_project
,
:admin_commit_status
,
:admin_build
:admin_build
,
:move_issue
]
end
...
...
app/services/issues/move_service.rb
View file @
8d1b7f95
...
...
@@ -34,17 +34,14 @@ module Issues
end
def
move?
return
false
unless
@project_new
return
false
unless
@issue_new
return
false
unless
can_move?
true
@project_new
&&
can_move?
end
private
def
can_move?
true
can?
(
@current_user
,
:move_issue
,
@project_old
)
&&
can?
(
@current_user
,
:move_issue
,
@project_new
)
end
def
open_new_issue
...
...
spec/services/issues/move_service_spec.rb
View file @
8d1b7f95
...
...
@@ -5,14 +5,25 @@ describe Issues::MoveService, services: true do
let
(
:title
)
{
'Some issue'
}
let
(
:description
)
{
'Some issue 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
(
:move_params
)
{
{
'move_to_project_id'
=>
new_project
.
id
}
}
let
(
:move_service
)
{
described_class
.
new
(
current_project
,
user
,
move_params
,
old_issue
)
}
let
(
:move_service
)
{
described_class
.
new
(
old_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
include_context
'issue move requested'
include_context
'user can move issue'
describe
'#move?'
do
subject
{
move_service
.
move?
}
it
{
is_expected
.
to
be_truthy
}
...
...
@@ -53,7 +64,7 @@ describe Issues::MoveService, services: true do
end
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
(
:note
,
note_params
.
merge
(
note:
note_contents
.
second
))
create
(
:system_note
,
note_params
.
merge
(
note:
note_contents
.
third
))
...
...
@@ -74,12 +85,51 @@ describe Issues::MoveService, services: true do
end
end
context
'issue not movable'
do
context
'move not requested'
do
let
(
:move_params
)
{
{}
}
context
'issue move not requested'
do
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
}
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