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
Boxiang Sun
gitlab-ce
Commits
9aa3edc6
Commit
9aa3edc6
authored
Aug 17, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unneeded aliases
parent
3e7eeefc
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
117 deletions
+109
-117
app/services/slash_commands/interpret_service.rb
app/services/slash_commands/interpret_service.rb
+21
-14
doc/workflow/slash_commands.md
doc/workflow/slash_commands.md
+20
-20
spec/features/issues/user_uses_slash_commands_spec.rb
spec/features/issues/user_uses_slash_commands_spec.rb
+4
-4
spec/features/merge_requests/user_uses_slash_commands_spec.rb
.../features/merge_requests/user_uses_slash_commands_spec.rb
+2
-2
spec/lib/gitlab/slash_commands/extractor_spec.rb
spec/lib/gitlab/slash_commands/extractor_spec.rb
+8
-8
spec/services/notes/slash_commands_service_spec.rb
spec/services/notes/slash_commands_service_spec.rb
+4
-4
spec/services/slash_commands/interpret_service_spec.rb
spec/services/slash_commands/interpret_service_spec.rb
+48
-63
spec/support/issuable_create_service_slash_commands_shared_examples.rb
...issuable_create_service_slash_commands_shared_examples.rb
+2
-2
No files found.
app/services/slash_commands/interpret_service.rb
View file @
9aa3edc6
...
@@ -54,7 +54,7 @@ module SlashCommands
...
@@ -54,7 +54,7 @@ module SlashCommands
issuable
.
closed?
&&
issuable
.
closed?
&&
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
end
end
command
:reopen
,
:open
do
command
:reopen
do
@updates
[
:state_event
]
=
'reopen'
@updates
[
:state_event
]
=
'reopen'
end
end
...
@@ -86,7 +86,7 @@ module SlashCommands
...
@@ -86,7 +86,7 @@ module SlashCommands
issuable
.
assignee_id?
&&
issuable
.
assignee_id?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
end
command
:unassign
,
:remove_assignee
do
command
:unassign
do
@updates
[
:assignee_id
]
=
nil
@updates
[
:assignee_id
]
=
nil
end
end
...
@@ -109,7 +109,7 @@ module SlashCommands
...
@@ -109,7 +109,7 @@ module SlashCommands
issuable
.
milestone_id?
&&
issuable
.
milestone_id?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
end
command
:
clear_milestone
,
:
remove_milestone
do
command
:remove_milestone
do
@updates
[
:milestone_id
]
=
nil
@updates
[
:milestone_id
]
=
nil
end
end
...
@@ -119,33 +119,40 @@ module SlashCommands
...
@@ -119,33 +119,40 @@ module SlashCommands
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
&&
project
.
labels
.
any?
project
.
labels
.
any?
end
end
command
:label
,
:labels
do
|
labels_param
|
command
:label
do
|
labels_param
|
label_ids
=
find_label_ids
(
labels_param
)
label_ids
=
find_label_ids
(
labels_param
)
@updates
[
:add_label_ids
]
=
label_ids
unless
label_ids
.
empty?
@updates
[
:add_label_ids
]
=
label_ids
unless
label_ids
.
empty?
end
end
desc
'Remove label(s)'
desc
'Remove
all or specific
label(s)'
params
'~label1 ~"label 2"'
params
'~label1 ~"label 2"'
condition
do
condition
do
issuable
.
persisted?
&&
issuable
.
persisted?
&&
issuable
.
labels
.
any?
&&
issuable
.
labels
.
any?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
end
command
:unlabel
,
:remove_label
,
:remove_labels
do
|
labels_param
|
command
:unlabel
do
|
labels_param
=
nil
|
label_ids
=
find_label_ids
(
labels_param
)
if
labels_param
.
present?
label_ids
=
find_label_ids
(
labels_param
)
@updates
[
:remove_label_ids
]
=
label_ids
unless
label_ids
.
empty?
@updates
[
:remove_label_ids
]
=
label_ids
unless
label_ids
.
empty?
else
@updates
[
:label_ids
]
=
[]
end
end
end
desc
'Remove all labels'
desc
'Replace all label(s)'
params
'~label1 ~"label 2"'
condition
do
condition
do
issuable
.
persisted?
&&
issuable
.
persisted?
&&
issuable
.
labels
.
any?
&&
issuable
.
labels
.
any?
&&
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
current_user
.
can?
(
:"admin_
#{
issuable
.
to_ability_name
}
"
,
project
)
end
end
command
:clear_labels
,
:clear_label
do
command
:relabel
do
|
labels_param
|
@updates
[
:label_ids
]
=
[]
label_ids
=
find_label_ids
(
labels_param
)
@updates
[
:label_ids
]
=
label_ids
unless
label_ids
.
empty?
end
end
desc
'Add a todo'
desc
'Add a todo'
...
@@ -185,12 +192,12 @@ module SlashCommands
...
@@ -185,12 +192,12 @@ module SlashCommands
end
end
desc
'Set due date'
desc
'Set due date'
params
'<in 2 days
; this Friday;
December 31st>'
params
'<in 2 days
| this Friday |
December 31st>'
condition
do
condition
do
issuable
.
respond_to?
(
:due_date
)
&&
issuable
.
respond_to?
(
:due_date
)
&&
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
end
end
command
:due
,
:due_date
do
|
due_date_param
|
command
:due
do
|
due_date_param
|
due_date
=
Chronic
.
parse
(
due_date_param
).
try
(
:to_date
)
due_date
=
Chronic
.
parse
(
due_date_param
).
try
(
:to_date
)
@updates
[
:due_date
]
=
due_date
if
due_date
@updates
[
:due_date
]
=
due_date
if
due_date
...
@@ -203,7 +210,7 @@ module SlashCommands
...
@@ -203,7 +210,7 @@ module SlashCommands
issuable
.
due_date?
&&
issuable
.
due_date?
&&
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
current_user
.
can?
(
:"update_
#{
issuable
.
to_ability_name
}
"
,
issuable
)
end
end
command
:
clear
_due_date
do
command
:
remove
_due_date
do
@updates
[
:due_date
]
=
nil
@updates
[
:due_date
]
=
nil
end
end
...
...
doc/workflow/slash_commands.md
View file @
9aa3edc6
...
@@ -5,26 +5,26 @@ requests that are usually done by clicking buttons or dropdowns in GitLab's UI.
...
@@ -5,26 +5,26 @@ requests that are usually done by clicking buttons or dropdowns in GitLab's UI.
You can enter these commands while creating a new issue or merge request, and
You can enter these commands while creating a new issue or merge request, and
in comments. Each command should be on a separate line in order to be properly
in comments. Each command should be on a separate line in order to be properly
detected and executed. The commands are removed from the issue, merge request or
detected and executed. The commands are removed from the issue, merge request or
comment body before it is saved and will not be visible
as such
to anyone else.
comment body before it is saved and will not be visible to anyone else.
Here
is a list of all of the available commands and descriptions about what they
Below
is a list of all of the available commands and descriptions about what they
do.
do.
| Command | A
liases | A
ction |
| Command | Action |
|:---------------------------|:-------------
-------|:-------------
|
|:---------------------------|:-------------|
|
`/close`
|
None |
Close the issue or merge request |
|
`/close`
| Close the issue or merge request |
|
`/reopen`
|
`/open`
|
Reopen the issue or merge request |
|
`/reopen`
| Reopen the issue or merge request |
|
`/title <New title>`
|
None |
Change title |
|
`/title <New title>`
| Change title |
|
`/assign @username`
|
None |
Assign |
|
`/assign @username`
| Assign |
|
`/unassign`
|
`/remove_assignee`
|
Remove assignee |
|
`/unassign`
| Remove assignee |
|
`/milestone %milestone`
|
None |
Set milestone |
|
`/milestone %milestone`
| Set milestone |
|
`/
clear_milestone`
|
`/remove_milestone`
| Remove milestone |
|
`/
remove_milestone`
| Remove milestone |
|
`/label ~foo ~"bar baz"`
|
`/labels`
|
Add label(s) |
|
`/label ~foo ~"bar baz"`
| Add label(s) |
|
`/unlabel ~foo ~"bar baz"`
|
`/remove_label`
,
`remove_labels`
| Remove
label(s) |
|
`/unlabel ~foo ~"bar baz"`
|
Remove all or specific
label(s) |
|
`/
clear_labels`
|
`/clear_label`
| Clear all labels
|
|
`/
relabel ~foo ~"bar baz"`
| Replace all label(s)
|
|
`/todo`
|
None |
Add a todo |
|
`/todo`
| Add a todo |
|
`/done`
|
None |
Mark todo as done |
|
`/done`
| Mark todo as done |
|
`/subscribe`
|
None |
Subscribe |
|
`/subscribe`
| Subscribe |
|
`/unsubscribe`
|
None |
Unsubscribe |
|
`/unsubscribe`
| Unsubscribe |
|
`/due <in 2 days
; this Friday; December 31st>`
|
`/due_date
`
| Set due date |
|
`/due <in 2 days
| this Friday | December 31st>
`
| Set due date |
|
`/
clear_due_date`
| None
| Remove due date |
|
`/
remove_due_date`
| Remove due date |
spec/features/issues/user_uses_slash_commands_spec.rb
View file @
9aa3edc6
...
@@ -22,11 +22,11 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
...
@@ -22,11 +22,11 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
it
'does not create a note, and sets the due date accordingly'
do
it
'does not create a note, and sets the due date accordingly'
do
page
.
within
(
'.js-main-target-form'
)
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
'note[note]'
,
with:
"/due
_date
2016-08-28"
fill_in
'note[note]'
,
with:
"/due 2016-08-28"
click_button
'Comment'
click_button
'Comment'
end
end
expect
(
page
).
not_to
have_content
'/due
_date
2016-08-28'
expect
(
page
).
not_to
have_content
'/due 2016-08-28'
expect
(
page
).
to
have_content
'Your commands have been executed!'
expect
(
page
).
to
have_content
'Your commands have been executed!'
issue
.
reload
issue
.
reload
...
@@ -42,11 +42,11 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
...
@@ -42,11 +42,11 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
expect
(
issue
.
due_date
).
to
eq
Date
.
new
(
2016
,
8
,
28
)
expect
(
issue
.
due_date
).
to
eq
Date
.
new
(
2016
,
8
,
28
)
page
.
within
(
'.js-main-target-form'
)
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
'note[note]'
,
with:
"/
clear
_due_date"
fill_in
'note[note]'
,
with:
"/
remove
_due_date"
click_button
'Comment'
click_button
'Comment'
end
end
expect
(
page
).
not_to
have_content
'/
clear
_due_date'
expect
(
page
).
not_to
have_content
'/
remove
_due_date'
expect
(
page
).
to
have_content
'Your commands have been executed!'
expect
(
page
).
to
have_content
'Your commands have been executed!'
issue
.
reload
issue
.
reload
...
...
spec/features/merge_requests/user_uses_slash_commands_spec.rb
View file @
9aa3edc6
...
@@ -22,11 +22,11 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do
...
@@ -22,11 +22,11 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do
it
'does not recognize the command nor create a note'
do
it
'does not recognize the command nor create a note'
do
page
.
within
(
'.js-main-target-form'
)
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
'note[note]'
,
with:
"/due
_date
2016-08-28"
fill_in
'note[note]'
,
with:
"/due 2016-08-28"
click_button
'Comment'
click_button
'Comment'
end
end
expect
(
page
).
not_to
have_content
'/due
_date
2016-08-28'
expect
(
page
).
not_to
have_content
'/due 2016-08-28'
end
end
end
end
end
end
spec/lib/gitlab/slash_commands/extractor_spec.rb
View file @
9aa3edc6
...
@@ -18,7 +18,7 @@ describe Gitlab::SlashCommands::Extractor do
...
@@ -18,7 +18,7 @@ describe Gitlab::SlashCommands::Extractor do
it
'extracts command'
do
it
'extracts command'
do
msg
,
commands
=
extractor
.
extract_commands
(
original_msg
)
msg
,
commands
=
extractor
.
extract_commands
(
original_msg
)
expect
(
commands
).
to
eq
[[
'open'
]]
expect
(
commands
).
to
eq
[[
'
re
open'
]]
expect
(
msg
).
to
eq
final_msg
expect
(
msg
).
to
eq
final_msg
end
end
end
end
...
@@ -45,31 +45,31 @@ describe Gitlab::SlashCommands::Extractor do
...
@@ -45,31 +45,31 @@ describe Gitlab::SlashCommands::Extractor do
describe
'command with no argument'
do
describe
'command with no argument'
do
context
'at the start of content'
do
context
'at the start of content'
do
it_behaves_like
'command with no argument'
do
it_behaves_like
'command with no argument'
do
let
(
:original_msg
)
{
"/open
\n
world"
}
let
(
:original_msg
)
{
"/
re
open
\n
world"
}
let
(
:final_msg
)
{
"world"
}
let
(
:final_msg
)
{
"world"
}
end
end
end
end
context
'in the middle of content'
do
context
'in the middle of content'
do
it_behaves_like
'command with no argument'
do
it_behaves_like
'command with no argument'
do
let
(
:original_msg
)
{
"hello
\n
/open
\n
world"
}
let
(
:original_msg
)
{
"hello
\n
/
re
open
\n
world"
}
let
(
:final_msg
)
{
"hello
\n
world"
}
let
(
:final_msg
)
{
"hello
\n
world"
}
end
end
end
end
context
'in the middle of a line'
do
context
'in the middle of a line'
do
it
'does not extract command'
do
it
'does not extract command'
do
msg
=
"hello
\n
world /open"
msg
=
"hello
\n
world /
re
open"
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
expect
(
commands
).
to
be_empty
expect
(
commands
).
to
be_empty
expect
(
msg
).
to
eq
"hello
\n
world /open"
expect
(
msg
).
to
eq
"hello
\n
world /
re
open"
end
end
end
end
context
'at the end of content'
do
context
'at the end of content'
do
it_behaves_like
'command with no argument'
do
it_behaves_like
'command with no argument'
do
let
(
:original_msg
)
{
"hello
\n
/open"
}
let
(
:original_msg
)
{
"hello
\n
/
re
open"
}
let
(
:final_msg
)
{
"hello"
}
let
(
:final_msg
)
{
"hello"
}
end
end
end
end
...
@@ -170,10 +170,10 @@ describe Gitlab::SlashCommands::Extractor do
...
@@ -170,10 +170,10 @@ describe Gitlab::SlashCommands::Extractor do
end
end
it
'extracts multiple commands'
do
it
'extracts multiple commands'
do
msg
=
%(hello\n/power @user.name %9.10 ~"bar baz.2" label\nworld\n/open)
msg
=
%(hello\n/power @user.name %9.10 ~"bar baz.2" label\nworld\n/
re
open)
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
msg
,
commands
=
extractor
.
extract_commands
(
msg
)
expect
(
commands
).
to
eq
[[
'power'
,
'@user.name %9.10 ~"bar baz.2" label'
],
[
'open'
]]
expect
(
commands
).
to
eq
[[
'power'
,
'@user.name %9.10 ~"bar baz.2" label'
],
[
'
re
open'
]]
expect
(
msg
).
to
eq
"hello
\n
world"
expect
(
msg
).
to
eq
"hello
\n
world"
end
end
...
...
spec/services/notes/slash_commands_service_spec.rb
View file @
9aa3edc6
...
@@ -69,12 +69,12 @@ describe Notes::SlashCommandsService, services: true do
...
@@ -69,12 +69,12 @@ describe Notes::SlashCommandsService, services: true do
end
end
end
end
describe
'/open'
do
describe
'/
re
open'
do
before
do
before
do
note
.
noteable
.
close!
note
.
noteable
.
close!
expect
(
note
.
noteable
).
to
be_closed
expect
(
note
.
noteable
).
to
be_closed
end
end
let
(
:note_text
)
{
'/open'
}
let
(
:note_text
)
{
'/
re
open'
}
it
'opens the noteable, and leave no note'
do
it
'opens the noteable, and leave no note'
do
content
,
command_params
=
service
.
extract_commands
(
note
)
content
,
command_params
=
service
.
extract_commands
(
note
)
...
@@ -104,12 +104,12 @@ describe Notes::SlashCommandsService, services: true do
...
@@ -104,12 +104,12 @@ describe Notes::SlashCommandsService, services: true do
end
end
end
end
describe
'/open'
do
describe
'/
re
open'
do
before
do
before
do
note
.
noteable
.
close
note
.
noteable
.
close
expect
(
note
.
noteable
).
to
be_closed
expect
(
note
.
noteable
).
to
be_closed
end
end
let
(
:note_text
)
{
"HELLO
\n
/open
\n
WORLD"
}
let
(
:note_text
)
{
"HELLO
\n
/
re
open
\n
WORLD"
}
it
'opens the noteable'
do
it
'opens the noteable'
do
content
,
command_params
=
service
.
extract_commands
(
note
)
content
,
command_params
=
service
.
extract_commands
(
note
)
...
...
spec/services/slash_commands/interpret_service_spec.rb
View file @
9aa3edc6
...
@@ -16,8 +16,8 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -16,8 +16,8 @@ describe SlashCommands::InterpretService, services: true do
let
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
shared_examples
'open command'
do
shared_examples
'
re
open command'
do
it
'returns state_event: "
open" if content contains /
open'
do
it
'returns state_event: "
reopen" if content contains /re
open'
do
issuable
.
close!
issuable
.
close!
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
...
@@ -26,7 +26,7 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -26,7 +26,7 @@ describe SlashCommands::InterpretService, services: true do
end
end
shared_examples
'close command'
do
shared_examples
'close command'
do
it
'returns state_event: "close" if content contains /
open
'
do
it
'returns state_event: "close" if content contains /
close
'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
state_event:
'close'
)
expect
(
updates
).
to
eq
(
state_event:
'close'
)
...
@@ -67,8 +67,8 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -67,8 +67,8 @@ describe SlashCommands::InterpretService, services: true do
end
end
end
end
shared_examples
'
clear
_milestone command'
do
shared_examples
'
remove
_milestone command'
do
it
'populates milestone_id: nil if content contains /
clear
_milestone'
do
it
'populates milestone_id: nil if content contains /
remove
_milestone'
do
issuable
.
update
(
milestone_id:
milestone
.
id
)
issuable
.
update
(
milestone_id:
milestone
.
id
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
...
@@ -95,8 +95,8 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -95,8 +95,8 @@ describe SlashCommands::InterpretService, services: true do
end
end
end
end
shared_examples
'
clear_labels command
'
do
shared_examples
'
unlabel command with no argument
'
do
it
'populates label_ids: [] if content contains /
clear_label
s'
do
it
'populates label_ids: [] if content contains /
unlabel with no argument
s'
do
issuable
.
update
(
label_ids:
[
inprogress
.
id
])
# populate the label
issuable
.
update
(
label_ids:
[
inprogress
.
id
])
# populate the label
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
...
@@ -104,6 +104,16 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -104,6 +104,16 @@ describe SlashCommands::InterpretService, services: true do
end
end
end
end
shared_examples
'relabel command'
do
it
'populates label_ids: [] if content contains /relabel'
do
issuable
.
update
(
label_ids:
[
bug
.
id
])
# populate the label
inprogress
# populate the label
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
label_ids:
[
inprogress
.
id
])
end
end
shared_examples
'todo command'
do
shared_examples
'todo command'
do
it
'populates todo_event: "add" if content contains /todo'
do
it
'populates todo_event: "add" if content contains /todo'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
...
@@ -138,16 +148,16 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -138,16 +148,16 @@ describe SlashCommands::InterpretService, services: true do
end
end
end
end
shared_examples
'due
_date
command'
do
shared_examples
'due command'
do
it
'populates due_date: Date.new(2016, 8, 28) if content contains /due
_date
2016-08-28'
do
it
'populates due_date: Date.new(2016, 8, 28) if content contains /due 2016-08-28'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
due_date:
defined?
(
expected_date
)
?
expected_date
:
Date
.
new
(
2016
,
8
,
28
))
expect
(
updates
).
to
eq
(
due_date:
defined?
(
expected_date
)
?
expected_date
:
Date
.
new
(
2016
,
8
,
28
))
end
end
end
end
shared_examples
'
clear
_due_date command'
do
shared_examples
'
remove
_due_date command'
do
it
'populates due_date: nil if content contains /
clear
_due_date'
do
it
'populates due_date: nil if content contains /
remove
_due_date'
do
issuable
.
update
(
due_date:
Date
.
today
)
issuable
.
update
(
due_date:
Date
.
today
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
_
,
updates
=
service
.
execute
(
content
,
issuable
)
...
@@ -163,19 +173,14 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -163,19 +173,14 @@ describe SlashCommands::InterpretService, services: true do
end
end
end
end
it_behaves_like
'open command'
do
it_behaves_like
'
re
open command'
do
let
(
:content
)
{
'/open'
}
let
(
:content
)
{
'/
re
open'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'open command'
do
it_behaves_like
'reopen command'
do
let
(
:content
)
{
'/open'
}
let
(
:issuable
)
{
merge_request
}
end
it_behaves_like
'open command'
do
let
(
:content
)
{
'/reopen'
}
let
(
:content
)
{
'/reopen'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'close command'
do
it_behaves_like
'close command'
do
...
@@ -233,11 +238,6 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -233,11 +238,6 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'unassign command'
do
let
(
:content
)
{
'/remove_assignee'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'milestone command'
do
it_behaves_like
'milestone command'
do
let
(
:content
)
{
"/milestone %
#{
milestone
.
title
}
"
}
let
(
:content
)
{
"/milestone %
#{
milestone
.
title
}
"
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
...
@@ -248,19 +248,14 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -248,19 +248,14 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'
clear
_milestone command'
do
it_behaves_like
'
remove
_milestone command'
do
let
(
:content
)
{
'/
clear
_milestone'
}
let
(
:content
)
{
'/
remove
_milestone'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'clear_milestone command'
do
it_behaves_like
'remove_milestone command'
do
let
(
:content
)
{
'/clear_milestone'
}
let
(
:issuable
)
{
merge_request
}
end
it_behaves_like
'clear_milestone command'
do
let
(
:content
)
{
'/remove_milestone'
}
let
(
:content
)
{
'/remove_milestone'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'label command'
do
it_behaves_like
'label command'
do
...
@@ -273,11 +268,6 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -273,11 +268,6 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'label command'
do
let
(
:content
)
{
%(/labels ~"#{inprogress.title}" ~#{bug.title} ~unknown)
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'unlabel command'
do
it_behaves_like
'unlabel command'
do
let
(
:content
)
{
%(/unlabel ~"#{inprogress.title}")
}
let
(
:content
)
{
%(/unlabel ~"#{inprogress.title}")
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
...
@@ -288,31 +278,26 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -288,31 +278,26 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'unlabel command'
do
it_behaves_like
'unlabel command
with no argument
'
do
let
(
:content
)
{
%(/
remove_labels ~"#{inprogress.title}"
)
}
let
(
:content
)
{
%(/
unlabel
)
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'unlabel command'
do
it_behaves_like
'unlabel command
with no argument
'
do
let
(
:content
)
{
%(/
remove_label ~"#{inprogress.title}"
)
}
let
(
:content
)
{
%(/
unlabel
)
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'
clear_labels
command'
do
it_behaves_like
'
relabel
command'
do
let
(
:content
)
{
'/clear_labels'
}
let
(
:content
)
{
%(/relabel ~"#{inprogress.title}")
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'
clear_labels
command'
do
it_behaves_like
'
relabel
command'
do
let
(
:content
)
{
'/clear_labels'
}
let
(
:content
)
{
%(/relabel ~"#{inprogress.title}")
}
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'clear_labels command'
do
let
(
:content
)
{
'/clear_label'
}
let
(
:issuable
)
{
issue
}
end
it_behaves_like
'todo command'
do
it_behaves_like
'todo command'
do
let
(
:content
)
{
'/todo'
}
let
(
:content
)
{
'/todo'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
...
@@ -353,46 +338,46 @@ describe SlashCommands::InterpretService, services: true do
...
@@ -353,46 +338,46 @@ describe SlashCommands::InterpretService, services: true do
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'due
_date
command'
do
it_behaves_like
'due command'
do
let
(
:content
)
{
'/due
_date
2016-08-28'
}
let
(
:content
)
{
'/due 2016-08-28'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'due
_date
command'
do
it_behaves_like
'due command'
do
let
(
:content
)
{
'/due tomorrow'
}
let
(
:content
)
{
'/due tomorrow'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
let
(
:expected_date
)
{
Date
.
tomorrow
}
let
(
:expected_date
)
{
Date
.
tomorrow
}
end
end
it_behaves_like
'due
_date
command'
do
it_behaves_like
'due command'
do
let
(
:content
)
{
'/due 5 days from now'
}
let
(
:content
)
{
'/due 5 days from now'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
let
(
:expected_date
)
{
5
.
days
.
from_now
.
to_date
}
let
(
:expected_date
)
{
5
.
days
.
from_now
.
to_date
}
end
end
it_behaves_like
'due
_date
command'
do
it_behaves_like
'due command'
do
let
(
:content
)
{
'/due in 2 days'
}
let
(
:content
)
{
'/due in 2 days'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
let
(
:expected_date
)
{
2
.
days
.
from_now
.
to_date
}
let
(
:expected_date
)
{
2
.
days
.
from_now
.
to_date
}
end
end
it_behaves_like
'empty command'
do
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/due
_date
foo bar'
}
let
(
:content
)
{
'/due foo bar'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'empty command'
do
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/due
_date
2016-08-28'
}
let
(
:content
)
{
'/due 2016-08-28'
}
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
it_behaves_like
'
clear
_due_date command'
do
it_behaves_like
'
remove
_due_date command'
do
let
(
:content
)
{
'/
clear
_due_date'
}
let
(
:content
)
{
'/
remove
_due_date'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
end
end
it_behaves_like
'empty command'
do
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/
clear
_due_date'
}
let
(
:content
)
{
'/
remove
_due_date'
}
let
(
:issuable
)
{
merge_request
}
let
(
:issuable
)
{
merge_request
}
end
end
end
end
...
...
spec/support/issuable_create_service_slash_commands_shared_examples.rb
View file @
9aa3edc6
...
@@ -14,7 +14,7 @@ shared_examples 'new issuable record that supports slash commands' do
...
@@ -14,7 +14,7 @@ shared_examples 'new issuable record that supports slash commands' do
context
'with labels in command only'
do
context
'with labels in command only'
do
let
(
:example_params
)
do
let
(
:example_params
)
do
{
{
description:
"/label ~
#{
labels
.
first
.
name
}
~
#{
labels
.
second
.
name
}
\n
/
remove_
label ~
#{
labels
.
third
.
name
}
"
description:
"/label ~
#{
labels
.
first
.
name
}
~
#{
labels
.
second
.
name
}
\n
/
un
label ~
#{
labels
.
third
.
name
}
"
}
}
end
end
...
@@ -28,7 +28,7 @@ shared_examples 'new issuable record that supports slash commands' do
...
@@ -28,7 +28,7 @@ shared_examples 'new issuable record that supports slash commands' do
let
(
:example_params
)
do
let
(
:example_params
)
do
{
{
label_ids:
[
labels
.
second
.
id
],
label_ids:
[
labels
.
second
.
id
],
description:
"/label ~
#{
labels
.
first
.
name
}
\n
/
remove_
label ~
#{
labels
.
third
.
name
}
"
description:
"/label ~
#{
labels
.
first
.
name
}
\n
/
un
label ~
#{
labels
.
third
.
name
}
"
}
}
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