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
Léo-Paul Géneau
gitlab-ce
Commits
10854ad8
Commit
10854ad8
authored
Sep 01, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'move-action' into 'master'
Merge request to address /move functionality. See merge request !13436
parents
aeb005fc
7e71f958
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
175 additions
and
1 deletion
+175
-1
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+1
-0
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+12
-1
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+18
-0
changelogs/unreleased/move-action.yml
changelogs/unreleased/move-action.yml
+4
-0
doc/user/project/quick_actions.md
doc/user/project/quick_actions.md
+1
-0
spec/features/issues/user_uses_slash_commands_spec.rb
spec/features/issues/user_uses_slash_commands_spec.rb
+109
-0
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+20
-0
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+10
-0
No files found.
app/services/issuable_base_service.rb
View file @
10854ad8
...
...
@@ -56,6 +56,7 @@ class IssuableBaseService < BaseService
params
.
delete
(
:assignee_id
)
params
.
delete
(
:due_date
)
params
.
delete
(
:canonical_issue_id
)
params
.
delete
(
:project
)
end
filter_assignee
(
issuable
)
...
...
app/services/issues/update_service.rb
View file @
10854ad8
...
...
@@ -6,7 +6,7 @@ module Issues
handle_move_between_iids
(
issue
)
filter_spam_check_params
change_issue_duplicate
(
issue
)
update
(
issue
)
move_issue_to_new_project
(
issue
)
||
update
(
issue
)
end
def
before_update
(
issue
)
...
...
@@ -74,6 +74,17 @@ module Issues
end
end
def
move_issue_to_new_project
(
issue
)
target_project
=
params
.
delete
(
:target_project
)
return
unless
target_project
&&
issue
.
can_move?
(
current_user
,
target_project
)
&&
target_project
!=
issue
.
project
update
(
issue
)
Issues
::
MoveService
.
new
(
project
,
current_user
).
execute
(
issue
,
target_project
)
end
private
def
get_issue_if_allowed
(
project
,
iid
)
...
...
app/services/quick_actions/interpret_service.rb
View file @
10854ad8
...
...
@@ -505,6 +505,24 @@ module QuickActions
end
end
desc
'Move this issue to another project.'
explanation
do
|
path_to_project
|
"Moves this issue to
#{
path_to_project
}
."
end
params
'path/to/project'
condition
do
issuable
.
is_a?
(
Issue
)
&&
issuable
.
persisted?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
command
:move
do
|
target_project_path
|
target_project
=
Project
.
find_by_full_path
(
target_project_path
)
if
target_project
.
present?
@updates
[
:target_project
]
=
target_project
end
end
def
extract_users
(
params
)
return
[]
if
params
.
nil?
...
...
changelogs/unreleased/move-action.yml
0 → 100644
View file @
10854ad8
---
title
:
Allow users to move issues to other projects using a / command
merge_request
:
13436
author
:
Manolis Mavrofidis
doc/user/project/quick_actions.md
View file @
10854ad8
...
...
@@ -38,3 +38,4 @@ do.
|
`/award :emoji:`
| Toggle award for :emoji: |
|
`/board_move ~column`
| Move issue to column on the board |
|
`/duplicate #issue`
| Closes this issue and marks it as a duplicate of another issue |
|
`/move path/to/project`
| Moves issue to another project |
spec/features/issues/user_uses_slash_commands_spec.rb
View file @
10854ad8
...
...
@@ -155,5 +155,114 @@ feature 'Issues > User uses quick actions', js: true do
end
end
end
describe
'move the issue to another project'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
context
'when the project is valid'
,
js:
true
do
let
(
:target_project
)
{
create
(
:project
,
:public
)
}
before
do
target_project
.
team
<<
[
user
,
:master
]
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
end
it
'moves the issue'
do
write_note
(
"/move
#{
target_project
.
full_path
}
"
)
expect
(
page
).
to
have_content
'Commands applied'
expect
(
issue
.
reload
).
to
be_closed
visit
project_issue_path
(
target_project
,
issue
)
expect
(
page
).
to
have_content
'Issues 1'
end
end
context
'when the project is valid but the user not authorized'
,
js:
true
do
let
(
:project_unauthorized
)
{
create
(
:project
,
:public
)}
before
do
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
end
it
'does not move the issue'
do
write_note
(
"/move
#{
project_unauthorized
.
full_path
}
"
)
expect
(
page
).
not_to
have_content
'Commands applied'
expect
(
issue
.
reload
).
to
be_open
end
end
context
'when the project is invalid'
,
js:
true
do
before
do
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
end
it
'does not move the issue'
do
write_note
(
"/move not/valid"
)
expect
(
page
).
not_to
have_content
'Commands applied'
expect
(
issue
.
reload
).
to
be_open
end
end
context
'when the user issues multiple commands'
,
js:
true
do
let
(
:target_project
)
{
create
(
:project
,
:public
)
}
let
(
:milestone
)
{
create
(
:milestone
,
title:
'1.0'
,
project:
project
)
}
let
(
:target_milestone
)
{
create
(
:milestone
,
title:
'1.0'
,
project:
target_project
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
title:
'bug'
)
}
let
(
:wontfix
)
{
create
(
:label
,
project:
project
,
title:
'wontfix'
)
}
let
(
:bug_target
)
{
create
(
:label
,
project:
target_project
,
title:
'bug'
)
}
let
(
:wontfix_target
)
{
create
(
:label
,
project:
target_project
,
title:
'wontfix'
)
}
before
do
target_project
.
team
<<
[
user
,
:master
]
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
end
it
'applies the commands to both issues and moves the issue'
do
write_note
(
"/label ~
#{
bug
.
title
}
~
#{
wontfix
.
title
}
\n
/milestone %
\"
#{
milestone
.
title
}
\"\n
/move
#{
target_project
.
full_path
}
"
)
expect
(
page
).
to
have_content
'Commands applied'
expect
(
issue
.
reload
).
to
be_closed
visit
project_issue_path
(
target_project
,
issue
)
expect
(
page
).
to
have_content
'bug'
expect
(
page
).
to
have_content
'wontfix'
expect
(
page
).
to
have_content
'1.0'
visit
project_issue_path
(
project
,
issue
)
expect
(
page
).
to
have_content
'Closed'
expect
(
page
).
to
have_content
'bug'
expect
(
page
).
to
have_content
'wontfix'
expect
(
page
).
to
have_content
'1.0'
end
it
'moves the issue and applies the commands to both issues'
do
write_note
(
"/move
#{
target_project
.
full_path
}
\n
/label ~
#{
bug
.
title
}
~
#{
wontfix
.
title
}
\n
/milestone %
\"
#{
milestone
.
title
}
\"
"
)
expect
(
page
).
to
have_content
'Commands applied'
expect
(
issue
.
reload
).
to
be_closed
visit
project_issue_path
(
target_project
,
issue
)
expect
(
page
).
to
have_content
'bug'
expect
(
page
).
to
have_content
'wontfix'
expect
(
page
).
to
have_content
'1.0'
visit
project_issue_path
(
project
,
issue
)
expect
(
page
).
to
have_content
'Closed'
expect
(
page
).
to
have_content
'bug'
expect
(
page
).
to
have_content
'wontfix'
expect
(
page
).
to
have_content
'1.0'
end
end
end
end
end
spec/services/issues/update_service_spec.rb
View file @
10854ad8
...
...
@@ -510,6 +510,26 @@ describe Issues::UpdateService, :mailer do
end
end
context
'move issue to another project'
do
let
(
:target_project
)
{
create
(
:project
)
}
context
'valid project'
do
before
do
target_project
.
team
<<
[
user
,
:master
]
end
it
'calls the move service with the proper issue and project'
do
move_stub
=
class_double
(
"Issues::MoveService"
).
as_stubbed_const
allow
(
Issues
::
MoveService
).
to
receive
(
:new
).
and_return
(
move_stub
)
allow
(
move_stub
).
to
receive
(
:execute
).
with
(
issue
,
target_project
).
and_return
(
issue
)
expect
(
move_stub
).
to
receive
(
:execute
).
with
(
issue
,
target_project
)
update_issue
(
target_project:
target_project
)
end
end
end
include_examples
'issuable update service'
do
let
(
:open_issuable
)
{
issue
}
let
(
:closed_issuable
)
{
create
(
:closed_issue
,
project:
project
)
}
...
...
spec/services/quick_actions/interpret_service_spec.rb
View file @
10854ad8
...
...
@@ -1147,5 +1147,15 @@ describe QuickActions::InterpretService do
expect
(
explanations
).
to
eq
([
"Moves issue to ~
#{
bug
.
id
}
column in the board."
])
end
end
describe
'move issue to another project command'
do
let
(
:content
)
{
'/move test/project'
}
it
'includes the project name'
do
_
,
explanations
=
service
.
explain
(
content
,
issue
)
expect
(
explanations
).
to
eq
([
"Moves this issue to test/project."
])
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