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
1ac06396
Commit
1ac06396
authored
Dec 21, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new tests
parent
55c61d2e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletion
+54
-1
spec/controllers/projects/mattermosts_controller_spec.rb
spec/controllers/projects/mattermosts_controller_spec.rb
+6
-1
spec/lib/mattermost/client_spec.rb
spec/lib/mattermost/client_spec.rb
+24
-0
spec/lib/mattermost/session_spec.rb
spec/lib/mattermost/session_spec.rb
+24
-0
No files found.
spec/controllers/projects/mattermosts_controller_spec.rb
View file @
1ac06396
...
@@ -11,6 +11,9 @@ describe Projects::MattermostsController do
...
@@ -11,6 +11,9 @@ describe Projects::MattermostsController do
describe
'GET #new'
do
describe
'GET #new'
do
before
do
before
do
allow_any_instance_of
(
MattermostSlashCommandsService
).
to
receive
(
:list_teams
).
and_return
([])
get
(
:new
,
get
(
:new
,
namespace_id:
project
.
namespace
.
to_param
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
)
project_id:
project
.
to_param
)
...
@@ -33,7 +36,9 @@ describe Projects::MattermostsController do
...
@@ -33,7 +36,9 @@ describe Projects::MattermostsController do
context
'no request can be made to mattermost'
do
context
'no request can be made to mattermost'
do
it
'shows the error'
do
it
'shows the error'
do
expect
(
controller
).
to
set_flash
[
:alert
].
to
/\AFailed to open TCP connection to/
allow_any_instance_of
(
MattermostSlashCommandsService
).
to
receive
(
:configure
).
and_return
([
false
,
"error message"
])
expect
(
subject
).
to
redirect_to
(
new_namespace_project_mattermost_url
(
project
.
namespace
,
project
))
end
end
end
end
...
...
spec/lib/mattermost/client_spec.rb
0 → 100644
View file @
1ac06396
require
'spec_helper'
describe
Mattermost
::
Client
do
let
(
:user
)
{
build
(
:user
)
}
subject
{
described_class
.
new
(
user
)
}
context
'JSON parse error'
do
before
do
Struct
.
new
(
"Request"
,
:body
,
:success?
)
end
it
'yields an error on malformed JSON'
do
bad_json
=
Struct
::
Request
.
new
(
"I'm not json"
,
true
)
expect
{
subject
.
send
(
:json_response
,
bad_json
)
}.
to
raise_error
(
Mattermost
::
ClientError
)
end
it
'shows a client error if the request was unsuccessful'
do
bad_request
=
Struct
::
Request
.
new
(
"true"
,
false
)
expect
{
subject
.
send
(
:json_response
,
bad_request
)
}.
to
raise_error
(
Mattermost
::
ClientError
)
end
end
end
spec/lib/mattermost/session_spec.rb
View file @
1ac06396
...
@@ -95,5 +95,29 @@ describe Mattermost::Session, type: :request do
...
@@ -95,5 +95,29 @@ describe Mattermost::Session, type: :request do
end
end
end
end
end
end
context
'with lease'
do
before
do
allow
(
subject
).
to
receive
(
:lease_try_obtain
).
and_return
(
'aldkfjsldfk'
)
end
it
'tries to obtain a lease'
do
expect
(
subject
).
to
receive
(
:lease_try_obtain
)
expect
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:cancel
)
# Cannot setup a session, but we should still cancel the lease
expect
{
subject
.
with_session
}.
to
raise_error
(
Mattermost
::
NoSessionError
)
end
end
context
'without lease'
do
before
do
allow
(
subject
).
to
receive
(
:lease_try_obtain
).
and_return
(
nil
)
end
it
'returns a NoSessionError error'
do
expect
{
subject
.
with_session
}.
to
raise_error
(
Mattermost
::
NoSessionError
)
end
end
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