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
9214d689
Commit
9214d689
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
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
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/lib/mattermost/client_spec.rb
0 → 100644
View file @
9214d689
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 @
9214d689
...
...
@@ -95,5 +95,29 @@ describe Mattermost::Session, type: :request do
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
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