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
e4bcdddf
Commit
e4bcdddf
authored
Jan 31, 2017
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zj-display-error-team-fetch' into 'master'
Fix inconsistent return type Closes #27150 See merge request !8290
parents
223f1f3d
bd5245db
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
9 deletions
+19
-9
mattermosts_controller.rb
app/controllers/projects/mattermosts_controller.rb
+1
-1
mattermost_slash_commands_service.rb
...els/project_services/mattermost_slash_commands_service.rb
+2
-2
_no_teams.html.haml
app/views/projects/mattermosts/_no_teams.html.haml
+4
-0
mattermosts_controller_spec.rb
spec/controllers/projects/mattermosts_controller_spec.rb
+2
-2
mattermost_slash_command_spec.rb
...atures/projects/services/mattermost_slash_command_spec.rb
+9
-0
mattermost_slash_commands_service_spec.rb
...roject_services/mattermost_slash_commands_service_spec.rb
+1
-4
No files found.
app/controllers/projects/mattermosts_controller.rb
View file @
e4bcdddf
...
...
@@ -34,7 +34,7 @@ class Projects::MattermostsController < Projects::ApplicationController
end
def
teams
@teams
||
=
@service
.
list_teams
(
current_user
)
@teams
,
@teams_error_message
=
@service
.
list_teams
(
current_user
)
end
def
service
...
...
app/models/project_services/mattermost_slash_commands_service.rb
View file @
e4bcdddf
...
...
@@ -28,8 +28,8 @@ class MattermostSlashCommandsService < ChatSlashCommandsService
[
false
,
e
.
message
]
end
def
list_teams
(
user
)
Mattermost
::
Team
.
new
(
user
).
all
def
list_teams
(
current_
user
)
[
Mattermost
::
Team
.
new
(
current_user
).
all
,
nil
]
rescue
Mattermost
::
Error
=>
e
[[],
e
.
message
]
end
...
...
app/views/projects/mattermosts/_no_teams.html.haml
View file @
e4bcdddf
-
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
%strong
=
Gitlab
.
config
.
mattermost
.
host
...
...
spec/controllers/projects/mattermosts_controller_spec.rb
View file @
e4bcdddf
...
...
@@ -13,13 +13,13 @@ describe Projects::MattermostsController do
before
do
allow_any_instance_of
(
MattermostSlashCommandsService
).
to
receive
(
:list_teams
).
and_return
([])
end
it
'accepts the request'
do
get
(
:new
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
)
end
it
'accepts the request'
do
expect
(
response
).
to
have_http_status
(
200
)
end
end
...
...
spec/features/projects/services/mattermost_slash_command_spec.rb
View file @
e4bcdddf
...
...
@@ -99,6 +99,15 @@ feature 'Setup Mattermost slash commands', feature: true do
expect
(
select_element
.
all
(
'option'
).
count
).
to
eq
(
3
)
end
it
'shows an error alert with the error message if there is an error requesting teams'
do
allow_any_instance_of
(
MattermostSlashCommandsService
).
to
receive
(
:list_teams
)
{
[[],
'test mattermost error message'
]
}
click_link
'Add to Mattermost'
expect
(
page
).
to
have_selector
(
'.alert'
)
expect
(
page
).
to
have_content
(
'test mattermost error message'
)
end
def
stub_teams
(
count:
0
)
teams
=
create_teams
(
count
)
...
...
spec/models/project_services/mattermost_slash_commands_service_spec.rb
View file @
e4bcdddf
...
...
@@ -113,10 +113,7 @@ describe MattermostSlashCommandsService, :models do
end
it
'shows error messages'
do
teams
,
message
=
subject
expect
(
teams
).
to
be_empty
expect
(
message
).
to
eq
(
'Failed to get team list.'
)
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