summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-01-26 09:16:07 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-01-30 11:01:36 +0100
commitb3de65bcc5627915511182a9ac9857b1fef14853 (patch)
tree537c79d5c1f03b1306556b3abf20a5bb3fe565dc /app
parent8bcc911b9bc9fcb2179860c5a98d8a1ad3ec34b0 (diff)
downloadgitlab-ce-b3de65bcc5627915511182a9ac9857b1fef14853.tar.gz
Update #list_teams to propagate errors
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/mattermosts_controller.rb5
-rw-r--r--app/models/project_services/mattermost_slash_commands_service.rb8
-rw-r--r--app/views/projects/mattermosts/_no_teams.html.haml5
-rw-r--r--app/views/projects/mattermosts/new.html.haml2
4 files changed, 9 insertions, 11 deletions
diff --git a/app/controllers/projects/mattermosts_controller.rb b/app/controllers/projects/mattermosts_controller.rb
index 20161e1cfd8..38f7e6eb5e9 100644
--- a/app/controllers/projects/mattermosts_controller.rb
+++ b/app/controllers/projects/mattermosts_controller.rb
@@ -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
diff --git a/app/models/project_services/mattermost_slash_commands_service.rb b/app/models/project_services/mattermost_slash_commands_service.rb
index 548163f38fa..b0f7a42f9a3 100644
--- a/app/models/project_services/mattermost_slash_commands_service.rb
+++ b/app/models/project_services/mattermost_slash_commands_service.rb
@@ -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
diff --git a/app/views/projects/mattermosts/_no_teams.html.haml b/app/views/projects/mattermosts/_no_teams.html.haml
index 1bb3642431e..aac74a25b75 100644
--- a/app/views/projects/mattermosts/_no_teams.html.haml
+++ b/app/views/projects/mattermosts/_no_teams.html.haml
@@ -1,5 +1,6 @@
-= 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
diff --git a/app/views/projects/mattermosts/new.html.haml b/app/views/projects/mattermosts/new.html.haml
index 82f596da0fe..96b1d2aee61 100644
--- a/app/views/projects/mattermosts/new.html.haml
+++ b/app/views/projects/mattermosts/new.html.haml
@@ -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'