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
4f10cad9
Commit
4f10cad9
authored
Jan 15, 2018
by
Mateusz Bajorski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Inherit quick action
Closes #38450
parent
405c4cae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
1 deletion
+90
-1
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+18
-0
changelogs/unreleased/add-inherit-command.yml
changelogs/unreleased/add-inherit-command.yml
+5
-0
doc/user/project/quick_actions.md
doc/user/project/quick_actions.md
+2
-1
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+65
-0
No files found.
app/services/quick_actions/interpret_service.rb
View file @
4f10cad9
...
...
@@ -268,6 +268,24 @@ module QuickActions
end
end
desc
'Inherit (copy) labels and milestone from other issue'
explanation
do
|
issue_id
|
"Inherit (copy) labels and milestone from issue
\"
#{
issue_id
}
\"
."
end
params
'#issue'
condition
do
issuable
.
persisted?
&&
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
end
command
:inherit
do
|
issue_id
|
issue
=
extract_references
(
issue_id
,
:issue
).
first
if
issue
.
present?
&&
issue
.
project_id
==
issuable
.
project_id
@updates
[
:add_label_ids
]
=
issue
.
labels
.
map
(
&
:id
)
@updates
[
:milestone_id
]
=
issue
.
milestone
.
id
if
issue
.
milestone
end
end
desc
'Add a todo'
explanation
'Adds a todo.'
condition
do
...
...
changelogs/unreleased/add-inherit-command.yml
0 → 100644
View file @
4f10cad9
---
title
:
Add Inherit quick action
merge_request
:
author
:
Mateusz Bajorski
type
:
added
doc/user/project/quick_actions.md
View file @
4f10cad9
...
...
@@ -40,4 +40,5 @@ do.
|
`/duplicate #issue`
| Closes this issue and marks it as a duplicate of another issue |
|
`/move path/to/project`
| Moves issue to another project |
|
`/tableflip`
| Append the comment with
`(╯°□°)╯︵ ┻━┻`
|
|
`/shrug`
| Append the comment with
`¯\_(ツ)_/¯`
|
\ No newline at end of file
|
`/shrug`
| Append the comment with
`¯\_(ツ)_/¯`
|
|
`/inherit #issue`
| Inherit (copy) labels and milestone from other issue |
spec/services/quick_actions/interpret_service_spec.rb
View file @
4f10cad9
...
...
@@ -306,6 +306,23 @@ describe QuickActions::InterpretService do
end
end
shared_examples
'inherit command'
do
it
'fetches issue and copies labels and milestone if content contains /inherit issue_reference'
do
issue_father
# populate the issue
todo_label
# populate this label
inreview_label
# populate this label
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
[
:add_label_ids
]).
to
match_array
([
inreview_label
.
id
,
todo_label
.
id
])
if
issue_father
.
milestone
expect
(
updates
[
:milestone_id
]).
to
eq
(
issue_father
.
milestone
.
id
)
else
expect
(
updates
).
not_to
have_key
(
:milestone_id
)
end
end
end
shared_examples
'shrug command'
do
it
'appends ¯\_(ツ)_/¯ to the comment'
do
new_content
,
_
=
service
.
execute
(
content
,
issuable
)
...
...
@@ -757,6 +774,54 @@ describe QuickActions::InterpretService do
let
(
:issuable
)
{
issue
}
end
context
'/inherit command'
do
let!
(
:todo_label
)
{
create
(
:label
,
project:
project
,
title:
'To Do'
)
}
let!
(
:inreview_label
)
{
create
(
:label
,
project:
project
,
title:
'In Review'
)
}
it_behaves_like
'inherit command'
do
# Without milestone assignment
let
(
:issue_father
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
inreview_label
,
todo_label
])
}
let
(
:content
)
{
"/inherit
#{
issue_father
.
to_reference
}
"
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'inherit command'
do
# With milestone assignment
let
(
:issue_father
)
{
create
(
:labeled_issue
,
project:
project
,
labels:
[
todo_label
,
inreview_label
],
milestone:
milestone
)
}
let
(
:content
)
{
"/inherit
#{
issue_father
.
to_reference
(
project
)
}
"
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/inherit'
}
let
(
:issuable
)
{
issue
}
end
context
'cross project references'
do
it_behaves_like
'empty command'
do
let
(
:other_project
)
{
create
(
:project
,
:public
)
}
let
(
:issue_father
)
{
create
(
:labeled_issue
,
project:
other_project
,
labels:
[
todo_label
,
inreview_label
])
}
let
(
:content
)
{
"/inherit
#{
issue_father
.
to_reference
(
project
)
}
"
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'empty command'
do
let
(
:content
)
{
"/inherit imaginary#1234"
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'empty command'
do
let
(
:other_project
)
{
create
(
:project
,
:private
)
}
let
(
:issue_father
)
{
create
(
:issue
,
project:
other_project
)
}
let
(
:content
)
{
"/inherit
#{
issue_father
.
to_reference
(
project
)
}
"
}
let
(
:issuable
)
{
issue
}
end
end
end
context
'/duplicate command'
do
it_behaves_like
'duplicate command'
do
let
(
:issue_duplicate
)
{
create
(
:issue
,
project:
project
)
}
...
...
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