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
242e291e
Commit
242e291e
authored
Nov 12, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add issue create subcommand
parent
657838f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
7 deletions
+27
-7
command_service.rb
app/services/mattermost/command_service.rb
+1
-1
issue_service.rb
app/services/mattermost/commands/issue_service.rb
+13
-6
issue_service_spec.rb
spec/services/mattermost/commands/issue_service_spec.rb
+13
-0
No files found.
app/services/mattermost/command_service.rb
View file @
242e291e
...
...
@@ -24,7 +24,7 @@ module Mattermost
private
def
command
params
[
:text
].
match
(
/\A(?<command>\S+)/
)[
:command
]
params
[
:text
].
split
.
first
end
def
present
(
result
)
...
...
app/services/mattermost/commands/issue_service.rb
View file @
242e291e
...
...
@@ -20,9 +20,20 @@ module Mattermost
private
# TODO implement create
def
create
(
_
)
return
nil
unless
can?
(
current_user
,
:create_issue
,
project
)
# We parse again as the previous split splits on continues whitespace
# per the ruby spec, but we loose information on where the new lines were
match
=
command
.
match
(
/\Aissue create (?<title>.*)\n*/
)
title
=
match
[
:title
]
description
=
match
.
post_match
Issues
::
CreateService
.
new
(
project
,
current_user
,
title:
title
,
description:
description
).
execute
end
def
subcommands
%w[create
s
search show]
%w[create search show]
end
def
collection
...
...
@@ -33,10 +44,6 @@ module Mattermost
can?
(
current_user
,
:read_issue
,
issue
)
end
# 'issue create my new title\nmy new description
# => 'create', ['my', 'new', 'title, ['my new description']]
# 'issue show 123'
# => 'show', ['123']
def
parse_command
split
=
command
.
split
subcommand
=
split
[
1
]
...
...
spec/services/mattermost/commands/issue_service_spec.rb
View file @
242e291e
...
...
@@ -56,6 +56,19 @@ describe Mattermost::Commands::IssueService do
end
end
end
context
'create as subcommand'
do
let
(
:title
)
{
'my new issue'
}
let
(
:params
)
{
{
text:
"issue create
#{
title
}
"
}
}
it
'return the new issue'
do
expect
(
subject
).
to
be_a
Issue
end
it
'creates a new issue'
do
expect
{
subject
}.
to
change
{
Issue
.
count
}.
by
(
1
)
end
end
end
describe
'help_message'
do
...
...
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