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
Boxiang Sun
gitlab-ce
Commits
7fcf3560
Commit
7fcf3560
authored
Mar 08, 2018
by
julien MILLAU
Committed by
Sean McGivern
Mar 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing delete method in mattermost session
parent
7734e85b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
3 deletions
+117
-3
changelogs/unreleased/fix-mattermost-delete-team.yml
changelogs/unreleased/fix-mattermost-delete-team.yml
+5
-0
lib/mattermost/session.rb
lib/mattermost/session.rb
+6
-0
lib/mattermost/team.rb
lib/mattermost/team.rb
+2
-3
spec/lib/mattermost/team_spec.rb
spec/lib/mattermost/team_spec.rb
+104
-0
No files found.
changelogs/unreleased/fix-mattermost-delete-team.yml
0 → 100644
View file @
7fcf3560
---
title
:
Fixed group deletion linked to Mattermost
merge_request
:
16209
author
:
Julien Millau
type
:
fixed
lib/mattermost/session.rb
View file @
7fcf3560
...
...
@@ -83,6 +83,12 @@ module Mattermost
end
end
def
delete
(
path
,
options
=
{})
handle_exceptions
do
self
.
class
.
delete
(
path
,
options
.
merge
(
headers:
@headers
))
end
end
private
def
create
...
...
lib/mattermost/team.rb
View file @
7fcf3560
...
...
@@ -16,10 +16,9 @@ module Mattermost
end
# The deletion is done async, so the response is fast.
# On the mattermost side, this triggers an soft deletion first, after which
# the actuall data is removed
# On the mattermost side, this triggers an soft deletion
def
destroy
(
team_id
:)
session_delete
(
"/api/v4/teams/
#{
team_id
}
?permanent=true
"
)
session_delete
(
"/api/v4/teams/
#{
team_id
}
"
)
end
end
end
spec/lib/mattermost/team_spec.rb
View file @
7fcf3560
...
...
@@ -64,4 +64,108 @@ describe Mattermost::Team do
end
end
end
describe
'#create'
do
subject
{
described_class
.
new
(
nil
).
create
(
name:
"devteam"
,
display_name:
"Dev Team"
,
type:
"O"
)
}
context
'for a new team'
do
let
(
:response
)
do
{
"id"
=>
"cuojfcetjty7tb4pxe47pwpndo"
,
"create_at"
=>
1517688728701
,
"update_at"
=>
1517688728701
,
"delete_at"
=>
0
,
"display_name"
=>
"Dev Team"
,
"name"
=>
"devteam"
,
"description"
=>
""
,
"email"
=>
"admin@example.com"
,
"type"
=>
"O"
,
"company_name"
=>
""
,
"allowed_domains"
=>
""
,
"invite_id"
=>
"7mp9d3ayaj833ymmkfnid8js6w"
,
"allow_open_invite"
=>
false
}
end
before
do
stub_request
(
:post
,
"http://mattermost.example.com/api/v3/teams/create"
)
.
to_return
(
status:
200
,
body:
response
.
to_json
,
headers:
{
'Content-Type'
=>
'application/json'
}
)
end
it
'returns the new team'
do
is_expected
.
to
eq
(
response
)
end
end
context
'for existing team'
do
before
do
stub_request
(
:post
,
'http://mattermost.example.com/api/v3/teams/create'
)
.
to_return
(
status:
400
,
headers:
{
'Content-Type'
=>
'application/json'
},
body:
{
id:
"store.sql_team.save.domain_exists.app_error"
,
message:
"A team with that name already exists"
,
detailed_error:
""
,
request_id:
"1hsb5bxs97r8bdggayy7n9gxaw"
,
status_code:
400
}.
to_json
)
end
it
'raises an error with message'
do
expect
{
subject
}.
to
raise_error
(
Mattermost
::
Error
,
'A team with that name already exists'
)
end
end
end
describe
'#delete'
do
subject
{
described_class
.
new
(
nil
).
destroy
(
team_id:
"cuojfcetjty7tb4pxe47pwpndo"
)
}
context
'for an existing team'
do
let
(
:response
)
do
{
"status"
=>
"OK"
}
end
before
do
stub_request
(
:delete
,
"http://mattermost.example.com/api/v4/teams/cuojfcetjty7tb4pxe47pwpndo"
)
.
to_return
(
status:
200
,
body:
response
.
to_json
,
headers:
{
'Content-Type'
=>
'application/json'
}
)
end
it
'returns team status'
do
is_expected
.
to
eq
(
response
)
end
end
context
'for an unknown team'
do
before
do
stub_request
(
:delete
,
"http://mattermost.example.com/api/v4/teams/cuojfcetjty7tb4pxe47pwpndo"
)
.
to_return
(
status:
404
,
body:
{
id:
"store.sql_team.get.find.app_error"
,
message:
"We couldn't find the existing team"
,
detailed_error:
""
,
request_id:
"my114ab5nbnui8c9pes4kz8mza"
,
status_code:
404
}.
to_json
,
headers:
{
'Content-Type'
=>
'application/json'
}
)
end
it
'raises an error with message'
do
expect
{
subject
}.
to
raise_error
(
Mattermost
::
Error
,
"We couldn't find the existing team"
)
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