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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b7894a74
Commit
b7894a74
authored
Dec 23, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errorcode 500 on slash commands
Coverage was failing, so this could slip through the cracks
parent
358a2d8b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
9 deletions
+34
-9
lib/gitlab/chat_commands/deploy.rb
lib/gitlab/chat_commands/deploy.rb
+3
-2
lib/gitlab/chat_commands/presenter.rb
lib/gitlab/chat_commands/presenter.rb
+6
-6
spec/lib/gitlab/chat_commands/command_spec.rb
spec/lib/gitlab/chat_commands/command_spec.rb
+24
-0
spec/models/project_services/mattermost_slash_commands_service_spec.rb
...roject_services/mattermost_slash_commands_service_spec.rb
+1
-1
No files found.
lib/gitlab/chat_commands/deploy.rb
View file @
b7894a74
...
@@ -49,8 +49,9 @@ module Gitlab
...
@@ -49,8 +49,9 @@ module Gitlab
end
end
def
url
(
subject
)
def
url
(
subject
)
polymorphic_url
(
project
=
subject
.
project
[
subject
.
project
.
namespace
.
becomes
(
Namespace
),
subject
.
project
,
subject
])
namespace_project_build_url
(
project
.
namespace
.
becomes
(
Namespace
),
project
,
subject
)
end
end
end
end
end
end
...
...
lib/gitlab/chat_commands/presenter.rb
View file @
b7894a74
...
@@ -30,12 +30,12 @@ module Gitlab
...
@@ -30,12 +30,12 @@ module Gitlab
if
subject
.
is_a?
(
Gitlab
::
ChatCommands
::
Result
)
if
subject
.
is_a?
(
Gitlab
::
ChatCommands
::
Result
)
show_result
(
subject
)
show_result
(
subject
)
elsif
subject
.
respond_to?
(
:count
)
elsif
subject
.
respond_to?
(
:count
)
if
subject
.
many?
if
subject
.
none?
multiple_resources
(
subject
)
elsif
subject
.
none?
not_found
not_found
elsif
subject
.
one?
single_resource
(
subject
.
first
)
else
else
single_resource
(
subject
)
multiple_resources
(
subject
)
end
end
else
else
single_resource
(
subject
)
single_resource
(
subject
)
...
@@ -71,9 +71,9 @@ module Gitlab
...
@@ -71,9 +71,9 @@ module Gitlab
end
end
def
multiple_resources
(
resources
)
def
multiple_resources
(
resources
)
resources
.
map!
{
|
resource
|
title
(
resource
)
}
titles
=
resources
.
map
{
|
resource
|
title
(
resource
)
}
message
=
header_with_list
(
"Multiple results were found:"
,
resourc
es
)
message
=
header_with_list
(
"Multiple results were found:"
,
titl
es
)
ephemeral_response
(
message
)
ephemeral_response
(
message
)
end
end
...
...
spec/lib/gitlab/chat_commands/command_spec.rb
View file @
b7894a74
...
@@ -54,6 +54,30 @@ describe Gitlab::ChatCommands::Command, service: true do
...
@@ -54,6 +54,30 @@ describe Gitlab::ChatCommands::Command, service: true do
end
end
end
end
context
'searching for an issue'
do
let
(
:params
)
{
{
text:
'issue search find me'
}
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
title:
'find me'
)
}
before
do
project
.
team
<<
[
user
,
:master
]
end
context
'a single issue is found'
do
it
'presents the issue'
do
expect
(
subject
[
:text
]).
to
match
(
issue
.
title
)
end
end
context
'multiple issues found'
do
let!
(
:issue2
)
{
create
(
:issue
,
project:
project
,
title:
"someone find me"
)
}
it
'shows a link to the new issue'
do
expect
(
subject
[
:text
]).
to
match
(
issue
.
title
)
expect
(
subject
[
:text
]).
to
match
(
issue2
.
title
)
end
end
end
context
'when trying to do deployment'
do
context
'when trying to do deployment'
do
let
(
:params
)
{
{
text:
'deploy staging to production'
}
}
let
(
:params
)
{
{
text:
'deploy staging to production'
}
}
let!
(
:build
)
{
create
(
:ci_build
,
project:
project
)
}
let!
(
:build
)
{
create
(
:ci_build
,
project:
project
)
}
...
...
spec/models/project_services/mattermost_slash_commands_service_spec.rb
View file @
b7894a74
...
@@ -6,7 +6,7 @@ describe MattermostSlashCommandsService, :models do
...
@@ -6,7 +6,7 @@ describe MattermostSlashCommandsService, :models do
context
'Mattermost API'
do
context
'Mattermost API'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:service
)
{
project
.
build_mattermost_slash_commands_service
}
let
(
:service
)
{
project
.
build_mattermost_slash_commands_service
}
let
(
:user
)
{
create
(
:user
)}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
Mattermost
::
Session
.
base_uri
(
"http://mattermost.example.com"
)
Mattermost
::
Session
.
base_uri
(
"http://mattermost.example.com"
)
...
...
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