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
1b4fdb98
Commit
1b4fdb98
authored
Nov 16, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename from service, and move to lib/gitlab
parent
8c8bc07d
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
233 additions
and
109 deletions
+233
-109
app/services/mattermost/commands/issue_search_service.rb
app/services/mattermost/commands/issue_search_service.rb
+0
-9
app/services/mattermost/commands/issue_show_service.rb
app/services/mattermost/commands/issue_show_service.rb
+0
-9
app/services/mattermost/commands/merge_request_search_service.rb
...vices/mattermost/commands/merge_request_search_service.rb
+0
-9
app/services/mattermost/commands/merge_request_show_service.rb
...ervices/mattermost/commands/merge_request_show_service.rb
+0
-9
app/services/mattermost/slash_command_service.rb
app/services/mattermost/slash_command_service.rb
+0
-39
lib/gitlab/chat_commands/base_command.rb
lib/gitlab/chat_commands/base_command.rb
+55
-0
lib/gitlab/chat_commands/command.rb
lib/gitlab/chat_commands/command.rb
+49
-0
lib/gitlab/chat_commands/issue_command.rb
lib/gitlab/chat_commands/issue_command.rb
+3
-3
lib/gitlab/chat_commands/issue_create.rb
lib/gitlab/chat_commands/issue_create.rb
+16
-0
lib/gitlab/chat_commands/issue_search.rb
lib/gitlab/chat_commands/issue_search.rb
+17
-0
lib/gitlab/chat_commands/issue_show.rb
lib/gitlab/chat_commands/issue_show.rb
+17
-0
lib/gitlab/chat_commands/merge_request_command.rb
lib/gitlab/chat_commands/merge_request_command.rb
+3
-3
lib/gitlab/chat_commands/merge_request_search.rb
lib/gitlab/chat_commands/merge_request_search.rb
+17
-0
lib/gitlab/chat_commands/merge_request_show.rb
lib/gitlab/chat_commands/merge_request_show.rb
+17
-0
lib/mattermost/presenter.rb
lib/mattermost/presenter.rb
+3
-4
spec/lib/gitlab/chat_commands/command_spec.rb
spec/lib/gitlab/chat_commands/command_spec.rb
+3
-3
spec/lib/gitlab/chat_commands/issue_create_spec.rb
spec/lib/gitlab/chat_commands/issue_create_spec.rb
+4
-4
spec/lib/gitlab/chat_commands/issue_search_spec.rb
spec/lib/gitlab/chat_commands/issue_search_spec.rb
+4
-4
spec/lib/gitlab/chat_commands/issue_show_spec.rb
spec/lib/gitlab/chat_commands/issue_show_spec.rb
+4
-5
spec/lib/gitlab/chat_commands/merge_request_search_spec.rb
spec/lib/gitlab/chat_commands/merge_request_search_spec.rb
+10
-4
spec/lib/gitlab/chat_commands/merge_request_show_spec.rb
spec/lib/gitlab/chat_commands/merge_request_show_spec.rb
+11
-4
No files found.
app/services/mattermost/commands/issue_search_service.rb
deleted
100644 → 0
View file @
8c8bc07d
module
Mattermost
module
Commands
class
IssueSearchService
<
IssueService
def
execute
present
search_results
end
end
end
end
app/services/mattermost/commands/issue_show_service.rb
deleted
100644 → 0
View file @
8c8bc07d
module
Mattermost
module
Commands
class
IssueShowService
<
IssueService
def
execute
present
find_by_iid
end
end
end
end
app/services/mattermost/commands/merge_request_search_service.rb
deleted
100644 → 0
View file @
8c8bc07d
module
Mattermost
module
Commands
class
MergeRequestSearchService
<
MergeRequestService
def
execute
present
search_results
end
end
end
end
app/services/mattermost/commands/merge_request_show_service.rb
deleted
100644 → 0
View file @
8c8bc07d
module
Mattermost
module
Commands
class
MergeRequestShowService
<
MergeRequestService
def
execute
present
find_by_iid
end
end
end
end
app/services/mattermost/slash_command_service.rb
deleted
100644 → 0
View file @
8c8bc07d
module
Mattermost
class
SlashCommandService
<
BaseService
def
self
.
registry
@registry
||=
Hash
.
new
({})
end
def
self
.
command
(
command
,
sub_command
,
klass
,
help_message
)
registry
[
command
][
sub_command
]
=
{
klass:
klass
,
help_message:
help_message
}
end
command
'issue'
,
'show'
,
Mattermost
::
Commands
::
IssueShowService
,
'issue show <id>'
command
'issue'
,
'search'
,
Mattermost
::
Commands
::
IssueSearchService
,
'issue search <query>'
command
'issue'
,
'create'
,
Mattermost
::
Commands
::
IssueCreateService
,
'issue create my title'
command
'mergerequest'
,
'show'
,
Mattermost
::
Commands
::
MergeRequestShowService
,
'mergerequest show <id>'
command
'mergerequest'
,
'search'
,
Mattermost
::
Commands
::
MergeRequestSearchService
,
'mergerequest search <query>'
def
execute
command
,
subcommand
=
parse_command
#TODO think how to do this to support ruby 2.1
service
=
registry
.
dig
(
command
,
subcommand
,
:klass
)
return
help_messages
(
registry
)
unless
service
.
try
(
:available?
,
project
)
service
.
new
(
project
,
current_user
,
params
).
execute
end
private
def
parse_command
params
[
:text
].
split
.
first
(
2
)
end
def
registry
self
.
class
.
registry
end
end
end
app/services/mattermost/commands/base_service
.rb
→
lib/gitlab/chat_commands/base_command
.rb
View file @
1b4fdb98
module
Mattermost
module
Gitlab
module
Commands
module
C
hatC
ommands
class
Base
Service
<
::
BaseService
class
Base
Command
QUERY_LIMIT
=
5
QUERY_LIMIT
=
5
def
execute
def
self
.
match
(
_
)
raise
NotImplementedError
raise
NotImplementedError
end
end
def
available?
def
self
.
help_message
raise
NotImplementedError
end
def
self
.
available?
(
_
)
raise
NotImplementedError
end
def
execute
(
_
)
raise
NotImplementedError
raise
NotImplementedError
end
end
...
@@ -15,33 +23,33 @@ module Mattermost
...
@@ -15,33 +23,33 @@ module Mattermost
raise
NotImplementedError
raise
NotImplementedError
end
end
attr_accessor
:project
,
:current_user
,
:params
def
initialize
(
project
,
user
,
params
=
{})
@project
,
@current_user
,
@params
=
project
,
user
,
params
.
dup
end
private
private
def
can?
(
object
,
action
,
subject
)
Ability
.
allowed?
(
object
,
action
,
subject
)
end
def
present
(
resource
)
def
present
(
resource
)
Mattermost
::
Presenter
.
present
(
resource
)
Mattermost
::
Presenter
.
present
(
resource
)
end
end
def
find_by_iid
def
find_by_iid
(
iid
)
resource
=
collection
.
find_by
(
iid:
iid
)
resource
=
collection
.
find_by
(
iid:
iid
)
readable?
(
resource
)
?
resource
:
nil
readable?
(
resource
)
?
resource
:
nil
end
end
def
search_results
def
search_results
(
query
)
collection
.
search
(
query
).
limit
(
QUERY_LIMIT
).
select
do
|
resource
|
collection
.
search
(
query
).
limit
(
QUERY_LIMIT
).
select
do
|
resource
|
readable?
(
resource
)
readable?
(
resource
)
end
end
end
end
# params[:text] = issue search <search query>
def
query
params
[
:text
].
split
[
2
..-
1
].
join
(
' '
)
end
# params[:text] = 'mergerequest show 123'
def
iid
params
[
:text
].
split
[
2
]
end
end
end
end
end
end
end
lib/gitlab/chat_commands/command.rb
0 → 100644
View file @
1b4fdb98
module
Gitlab
module
ChatCommands
class
Command
<
BaseCommand
COMMANDS
=
[
Gitlab
::
ChatCommands
::
IssueShow
,
Gitlab
::
ChatCommands
::
IssueSearch
,
Gitlab
::
ChatCommands
::
IssueCreate
,
Gitlab
::
ChatCommands
::
MergeRequestShow
,
Gitlab
::
ChatCommands
::
MergeRequestSearch
,
].
freeze
def
execute
klass
,
match
=
fetch_klass
return
help
(
help_messages
)
unless
klass
.
try
(
:available?
,
project
)
klass
.
new
(
project
,
current_user
,
params
).
execute
(
match
)
end
private
def
fetch_klass
match
=
nil
service
=
COMMANDS
.
find
do
|
klass
|
if
klass
.
available?
(
project
)
false
else
match
=
klass
.
match
(
command
)
end
end
[
service
,
match
]
end
def
help_messages
COMMANDS
.
map
do
|
klass
|
next
unless
klass
.
available?
(
project
)
klass
.
help_message
end
.
compact
end
def
command
params
[
:text
]
end
end
end
end
app/services/mattermost/commands/issue_service
.rb
→
lib/gitlab/chat_commands/issue_command
.rb
View file @
1b4fdb98
module
Mattermost
module
Gitlab
module
Commands
module
C
hatC
ommands
class
Issue
Service
<
Mattermost
::
Commands
::
BaseService
class
Issue
Command
<
BaseCommand
def
self
.
available?
(
project
)
def
self
.
available?
(
project
)
project
.
issues_enabled?
&&
project
.
default_issues_tracker?
project
.
issues_enabled?
&&
project
.
default_issues_tracker?
end
end
...
...
app/services/mattermost/commands/issue_create_servic
e.rb
→
lib/gitlab/chat_commands/issue_creat
e.rb
View file @
1b4fdb98
module
Mattermost
module
Gitlab
module
Commands
module
ChatCommands
class
IssueCreateService
<
IssueService
class
IssueCreate
<
BaseCommand
def
execute
def
self
.
match
(
text
)
title
,
description
=
parse_command
/\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>.*)\z/
.
match
(
text
)
present
Issues
::
CreateService
.
new
(
project
,
current_user
,
title:
title
,
description:
description
).
execute
end
end
private
def
execute
(
match
)
def
parse_command
match
=
params
[
:text
].
match
(
/\Aissue create (?<title>.*)\n*/
)
title
=
match
[
:title
]
title
=
match
[
:title
]
description
=
match
.
post_match
description
=
match
[
:description
]
[
title
,
description
]
present
Issues
::
CreateService
.
new
(
project
,
current_user
,
title:
title
,
description:
description
).
execute
end
end
end
end
end
end
...
...
lib/gitlab/chat_commands/issue_search.rb
0 → 100644
View file @
1b4fdb98
module
Gitlab
module
ChatCommands
class
IssueSearch
<
IssueCommand
def
self
.
match
(
text
)
/\Aissue\s+search\s+(?<query>.*)/
.
match
(
text
)
end
def
self
.
help_message
"issue search <query>"
end
def
execute
(
match
)
present
search_results
(
match
[
:query
])
end
end
end
end
lib/gitlab/chat_commands/issue_show.rb
0 → 100644
View file @
1b4fdb98
module
Gitlab
module
ChatCommands
class
IssueShow
<
IssueCommand
def
self
.
match
(
text
)
/\Aissue\s+show\s+(?<iid>\d+)/
.
match
(
text
)
end
def
self
.
help_message
"issue show <id>"
end
def
execute
(
match
)
present
find_by_iid
(
match
[
:iid
])
end
end
end
end
app/services/mattermost/commands/merge_request_service
.rb
→
lib/gitlab/chat_commands/merge_request_command
.rb
View file @
1b4fdb98
module
Mattermost
module
Gitlab
module
Commands
module
C
hatC
ommands
class
MergeRequest
Service
<
Mattermost
::
Commands
::
BaseService
class
MergeRequest
Command
<
BaseCommand
def
self
.
available?
(
project
)
def
self
.
available?
(
project
)
project
.
merge_requests_enabled?
project
.
merge_requests_enabled?
end
end
...
...
lib/gitlab/chat_commands/merge_request_search.rb
0 → 100644
View file @
1b4fdb98
module
Gitlab
module
ChatCommands
class
MergeRequestSearch
<
MergeRequestCommand
def
self
.
match
(
text
)
/\Amergerequest\s+search\s+(?<query>.*)/
.
match
(
text
)
end
def
self
.
help_message
"mergerequest search <query>"
end
def
execute
(
match
)
present
search_results
(
match
[
:query
])
end
end
end
end
lib/gitlab/chat_commands/merge_request_show.rb
0 → 100644
View file @
1b4fdb98
module
Gitlab
module
ChatCommands
class
MergeRequestShow
<
MergeRequestCommand
def
self
.
match
(
text
)
/\Amergerequest\s+show\s+(?<iid>\d+)/
.
match
(
text
)
end
def
self
.
help_message
"mergerequest show <id>"
end
def
execute
(
match
)
present
find_by_iid
(
match
[
:iid
])
end
end
end
end
lib/mattermost/presenter.rb
View file @
1b4fdb98
...
@@ -12,12 +12,11 @@ module Mattermost
...
@@ -12,12 +12,11 @@ module Mattermost
}
}
end
end
# TODO figure out how I know which are available or not
def
help
(
messages
)
def
help_message
(
commands
)
messages
=
[
"Available commands:"
]
messages
=
[
"Available commands:"
]
commands
.
each
do
|
sub_command
,
attrs
|
messages
.
each
do
|
messsage
|
messages
<<
"
\t
#{
COMMAND_PREFIX
}
#{
attrs
[
:help_message
]
}
"
messages
<<
"
-
#{
message
}
"
end
end
{
{
...
...
spec/
services/mattermost/slash_command_service
_spec.rb
→
spec/
lib/gitlab/chat_commands/command
_spec.rb
View file @
1b4fdb98
require
'spec_helper'
require
'spec_helper'
describe
Mattermost
::
SlashCommandService
,
service:
true
do
describe
Gitlab
::
ChatCommands
::
Command
,
service:
true
do
let
(
:project
)
{
build
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
build
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:params
)
{
{
text:
'issue show 1'
}
}
let
(
:params
)
{
{
text:
'issue show 1'
}
}
subject
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
subject
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
...
...
spec/
services/mattermost/commands/issue_create_servic
e_spec.rb
→
spec/
lib/gitlab/chat_commands/issue_creat
e_spec.rb
View file @
1b4fdb98
require
'spec_helper'
require
'spec_helper'
describe
Mattermost
::
Commands
::
IssueCreateServic
e
,
service:
true
do
describe
Gitlab
::
ChatCommands
::
IssueCreat
e
,
service:
true
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:
params
)
{
{
text:
"issue create bird is the word"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"issue create bird is the word"
)
}
before
{
project
.
team
<<
[
user
,
:master
]
}
before
{
project
.
team
<<
[
user
,
:master
]
}
subject
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
subject
{
described_class
.
new
(
project
,
user
).
execute
(
regex_match
)
}
context
'without description'
do
context
'without description'
do
it
'creates the issue'
do
it
'creates the issue'
do
...
@@ -23,7 +23,7 @@ describe Mattermost::Commands::IssueCreateService, service: true do
...
@@ -23,7 +23,7 @@ describe Mattermost::Commands::IssueCreateService, service: true do
context
'with description'
do
context
'with description'
do
let
(
:description
)
{
"Surfin bird"
}
let
(
:description
)
{
"Surfin bird"
}
let
(
:
params
)
{
{
text:
"issue create The bird is the word
\n
#{
description
}
"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"issue create bird is the word
\n
#{
description
}
"
)
}
before
{
subject
}
before
{
subject
}
...
...
spec/
services/mattermost/commands/issue_search_service
_spec.rb
→
spec/
lib/gitlab/chat_commands/issue_search
_spec.rb
View file @
1b4fdb98
require
'spec_helper'
require
'spec_helper'
describe
Mattermost
::
Commands
::
IssueSearchService
,
service:
true
do
describe
Gitlab
::
ChatCommands
::
IssueSearch
,
service:
true
do
describe
'#execute'
do
describe
'#execute'
do
let!
(
:issue
)
{
create
(
:issue
,
title:
'The bird is the word'
)
}
let!
(
:issue
)
{
create
(
:issue
,
title:
'The bird is the word'
)
}
let
(
:project
)
{
issue
.
project
}
let
(
:project
)
{
issue
.
project
}
let
(
:user
)
{
issue
.
author
}
let
(
:user
)
{
issue
.
author
}
let
(
:
params
)
{
{
text:
"issue search bird is the"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"issue search bird is the"
)
}
before
{
project
.
team
<<
[
user
,
:master
]
}
before
{
project
.
team
<<
[
user
,
:master
]
}
subject
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
subject
{
described_class
.
new
(
project
,
user
).
execute
(
regex_match
)
}
context
'without results'
do
context
'without results'
do
let
(
:
params
)
{
{
text:
"issue search no results for this one"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"issue search no results for this one"
)
}
it
"returns nil"
do
it
"returns nil"
do
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
...
...
spec/
services/mattermost/commands/issue_show_service
_spec.rb
→
spec/
lib/gitlab/chat_commands/issue_show
_spec.rb
View file @
1b4fdb98
require
'spec_helper'
require
'spec_helper'
describe
Mattermost
::
Commands
::
IssueShowService
,
service:
true
do
describe
Gitlab
::
ChatCommands
::
IssueShow
,
service:
true
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:issue
)
{
create
(
:issue
)
}
let
(
:issue
)
{
create
(
:issue
)
}
let
(
:project
)
{
issue
.
project
}
let
(
:project
)
{
issue
.
project
}
let
(
:user
)
{
issue
.
author
}
let
(
:user
)
{
issue
.
author
}
let
(
:
params
)
{
{
text:
"issue show
#{
issue
.
iid
}
"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"issue show
#{
issue
.
iid
}
"
)
}
before
{
project
.
team
<<
[
user
,
:master
]
}
before
{
project
.
team
<<
[
user
,
:master
]
}
subject
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
subject
{
described_class
.
new
(
project
,
user
).
execute
(
regex_match
)
}
context
'the issue exists'
do
context
'the issue exists'
do
it
'returns the issue'
do
it
'returns the issue'
do
expect
(
subject
[
:response_type
]).
to
be
:in_channel
expect
(
subject
[
:response_type
]).
to
be
:in_channel
expect
(
subject
[
:text
]).
to
match
issue
.
title
expect
(
subject
[
:text
]).
to
match
issue
.
title
end
end
end
end
context
'the issue does not exist'
do
context
'the issue does not exist'
do
let
(
:
params
)
{
{
text:
"issue show 12345"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"issue show 1234"
)
}
it
"returns nil"
do
it
"returns nil"
do
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
...
...
spec/
services/mattermost/commands/merge_request_search_service
_spec.rb
→
spec/
lib/gitlab/chat_commands/merge_request_search
_spec.rb
View file @
1b4fdb98
require
'spec_helper'
require
'spec_helper'
describe
Mattermost
::
Commands
::
MergeRequestSearchService
,
service:
true
do
describe
Gitlab
::
ChatCommands
::
MergeRequestSearch
,
service:
true
do
describe
'#execute'
do
describe
'#execute'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
title:
'The bird is the word'
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
title:
'The bird is the word'
)
}
let
(
:project
)
{
merge_request
.
source_project
}
let
(
:project
)
{
merge_request
.
source_project
}
let
(
:user
)
{
merge_request
.
author
}
let
(
:user
)
{
merge_request
.
author
}
let
(
:
params
)
{
{
text:
"mergerequest search
#{
merge_request
.
title
}
"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"mergerequest search
#{
merge_request
.
title
}
"
)
}
before
{
project
.
team
<<
[
user
,
:master
]
}
before
{
project
.
team
<<
[
user
,
:master
]
}
subject
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
subject
{
described_class
.
new
(
project
,
user
,
{}).
execute
(
regex_match
)
}
context
'the merge request exists'
do
context
'the merge request exists'
do
it
'returns the merge request'
do
it
'returns the merge request'
do
...
@@ -19,7 +19,7 @@ describe Mattermost::Commands::MergeRequestSearchService, service: true do
...
@@ -19,7 +19,7 @@ describe Mattermost::Commands::MergeRequestSearchService, service: true do
end
end
context
'no results can be found'
do
context
'no results can be found'
do
let
(
:
params
)
{
{
text:
"mergerequest search 12345"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"mergerequest search 12334"
)
}
it
"returns a 404 message"
do
it
"returns a 404 message"
do
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
...
@@ -27,4 +27,10 @@ describe Mattermost::Commands::MergeRequestSearchService, service: true do
...
@@ -27,4 +27,10 @@ describe Mattermost::Commands::MergeRequestSearchService, service: true do
end
end
end
end
end
end
describe
'self.match'
do
it
'matches a valid query'
do
expect
(
described_class
.
match
(
"mergerequest search my title here"
)).
to
be_truthy
end
end
end
end
spec/
services/mattermost/commands/merge_request_show_service
_spec.rb
→
spec/
lib/gitlab/chat_commands/merge_request_show
_spec.rb
View file @
1b4fdb98
require
'spec_helper'
require
'spec_helper'
describe
Mattermost
::
Commands
::
MergeRequestShowService
,
service:
true
do
describe
Gitlab
::
ChatCommands
::
MergeRequestShow
,
service:
true
do
describe
'#execute'
do
describe
'#execute'
do
let!
(
:merge_request
)
{
create
(
:merge_request
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:project
)
{
merge_request
.
source_project
}
let
(
:project
)
{
merge_request
.
source_project
}
let
(
:user
)
{
merge_request
.
author
}
let
(
:user
)
{
merge_request
.
author
}
let
(
:
params
)
{
{
text:
"mergerequest show
#{
merge_request
.
iid
}
"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"mergerequest show
#{
merge_request
.
iid
}
"
)
}
before
{
project
.
team
<<
[
user
,
:master
]
}
before
{
project
.
team
<<
[
user
,
:master
]
}
subject
{
described_class
.
new
(
project
,
user
,
params
).
execute
}
subject
{
described_class
.
new
(
project
,
user
).
execute
(
regex_match
)
}
context
'the merge request exists'
do
context
'the merge request exists'
do
it
'returns the merge request'
do
it
'returns the merge request'
do
...
@@ -19,7 +19,7 @@ describe Mattermost::Commands::MergeRequestShowService, service: true do
...
@@ -19,7 +19,7 @@ describe Mattermost::Commands::MergeRequestShowService, service: true do
end
end
context
'the merge request does not exist'
do
context
'the merge request does not exist'
do
let
(
:
params
)
{
{
text:
"mergerequest show 12345"
}
}
let
(
:
regex_match
)
{
described_class
.
match
(
"mergerequest show 12345"
)
}
it
"returns nil"
do
it
"returns nil"
do
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
expect
(
subject
[
:response_type
]).
to
be
:ephemeral
...
@@ -27,4 +27,11 @@ describe Mattermost::Commands::MergeRequestShowService, service: true do
...
@@ -27,4 +27,11 @@ describe Mattermost::Commands::MergeRequestShowService, service: true do
end
end
end
end
end
end
describe
"self.match"
do
it
'matches valid strings'
do
expect
(
described_class
.
match
(
"mergerequest show 123"
)).
to
be_truthy
expect
(
described_class
.
match
(
"mergerequest show sdf23"
)).
to
be_falsy
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