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
b3de65bc
Commit
b3de65bc
authored
Jan 26, 2017
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update #list_teams to propagate errors
parent
8bcc911b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
14 deletions
+12
-14
app/controllers/projects/mattermosts_controller.rb
app/controllers/projects/mattermosts_controller.rb
+1
-4
app/models/project_services/mattermost_slash_commands_service.rb
...els/project_services/mattermost_slash_commands_service.rb
+4
-4
app/views/projects/mattermosts/_no_teams.html.haml
app/views/projects/mattermosts/_no_teams.html.haml
+3
-2
app/views/projects/mattermosts/new.html.haml
app/views/projects/mattermosts/new.html.haml
+1
-1
lib/mattermost/client.rb
lib/mattermost/client.rb
+2
-2
spec/models/project_services/mattermost_slash_commands_service_spec.rb
...roject_services/mattermost_slash_commands_service_spec.rb
+1
-1
No files found.
app/controllers/projects/mattermosts_controller.rb
View file @
b3de65bc
...
...
@@ -34,10 +34,7 @@ class Projects::MattermostsController < Projects::ApplicationController
end
def
teams
@teams
||=
begin
teams
,
error_message
=
@service
.
list_teams
(
current_user
)
error_message
?
error_message
:
teams
end
@teams
,
@teams_error_message
=
@service
.
list_teams
(
current_user
)
end
def
service
...
...
app/models/project_services/mattermost_slash_commands_service.rb
View file @
b3de65bc
...
...
@@ -28,10 +28,10 @@ class MattermostSlashCommandsService < ChatSlashCommandsService
[
false
,
e
.
message
]
end
def
list_teams
(
user
)
Mattermost
::
Team
.
new
(
user
).
all
rescue
Mattermost
::
Error
[]
def
list_teams
(
current_
user
)
[
Mattermost
::
Team
.
new
(
current_user
).
all
,
nil
]
rescue
Mattermost
::
Error
=>
e
[
[],
e
.
message
]
end
private
...
...
app/views/projects/mattermosts/_no_teams.html.haml
View file @
b3de65bc
=
content_for
:flash_message
do
.alert.alert-danger
=
@teams
if
@teams
.
is_a?
(
String
)
-
if
@teams_error_message
=
content_for
:flash_message
do
.alert.alert-danger
=
@teams_error_message
%p
You aren’t a member of any team on the Mattermost instance at
...
...
app/views/projects/mattermosts/new.html.haml
View file @
b3de65bc
...
...
@@ -2,7 +2,7 @@
.inline.pull-right
=
custom_icon
(
'mattermost_logo'
,
size:
48
)
%h3
Install Mattermost Command
-
if
@teams
.
is_a?
(
String
)
||
@teams
.
empty?
-
if
@teams
.
empty?
=
render
'no_teams'
-
else
=
render
'team_selection'
lib/mattermost/client.rb
View file @
b3de65bc
...
...
@@ -27,12 +27,12 @@ module Mattermost
end
def
json_response
(
response
)
json_response
=
JSON
.
parse
(
response
.
body
)
unless
response
.
success?
raise
Mattermost
::
ClientError
.
new
(
json_response
[
'message'
]
||
'Undefined error'
)
end
json_response
=
JSON
.
parse
(
response
.
body
)
json_response
rescue
JSON
::
JSONError
raise
Mattermost
::
ClientError
.
new
(
'Cannot parse response'
)
...
...
spec/models/project_services/mattermost_slash_commands_service_spec.rb
View file @
b3de65bc
...
...
@@ -113,7 +113,7 @@ describe MattermostSlashCommandsService, :models do
end
it
'shows error messages'
do
expect
(
subject
).
to
eq
([])
expect
(
subject
).
to
eq
([
[],
"Failed to get team list."
])
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