Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
ba6c10fa
Commit
ba6c10fa
authored
Dec 15, 2014
by
Gergely Ujvari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix auth related tests
parent
0a6aef27
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
19 deletions
+47
-19
account-controller-test.coffee
tests/js/account/account-controller-test.coffee
+1
-1
controllers-test.coffee
tests/js/controllers-test.coffee
+12
-14
auth-test.coffee
tests/js/services/auth-test.coffee
+34
-4
No files found.
tests/js/account/account-controller-test.coffee
View file @
ba6c10fa
...
@@ -24,7 +24,7 @@ describe 'h.account.AccountController', ->
...
@@ -24,7 +24,7 @@ describe 'h.account.AccountController', ->
fakeFormHelpers
=
fakeFormHelpers
=
applyValidationErrors
:
sandbox
.
spy
()
applyValidationErrors
:
sandbox
.
spy
()
fakeAuth
=
fakeAuth
=
getPersona
:
(
->
'egon@columbia.edu'
)
user
:
'egon@columbia.edu'
$filterProvider
.
register
'persona'
,
->
$filterProvider
.
register
'persona'
,
->
sandbox
.
stub
().
returns
(
'STUBBED_PERSONA_FILTER'
)
sandbox
.
stub
().
returns
(
'STUBBED_PERSONA_FILTER'
)
...
...
tests/js/controllers-test.coffee
View file @
ba6c10fa
...
@@ -4,10 +4,10 @@ sinon.assert.expose assert, prefix: null
...
@@ -4,10 +4,10 @@ sinon.assert.expose assert, prefix: null
describe
'h'
,
->
describe
'h'
,
->
$scope
=
null
$scope
=
null
fakeAuth
=
null
fakeAuth
=
null
fakeIdentity
=
null
fakeLocation
=
null
fakeLocation
=
null
fakeParams
=
null
fakeParams
=
null
fakeStreamer
=
null
fakeStreamer
=
null
fakeIdentity
=
null
sandbox
=
null
sandbox
=
null
beforeEach
module
(
'h'
)
beforeEach
module
(
'h'
)
...
@@ -15,18 +15,6 @@ describe 'h', ->
...
@@ -15,18 +15,6 @@ describe 'h', ->
beforeEach
module
(
$provide
)
->
beforeEach
module
(
$provide
)
->
sandbox
=
sinon
.
sandbox
.
create
()
sandbox
=
sinon
.
sandbox
.
create
()
fakeAuth
=
{
user
:
null
getInitialUser
:
->
then
:
(
resolve
,
reject
)
->
resolve
()
}
fakeIdentity
=
{
watch
:
sandbox
.
spy
()
request
:
sandbox
.
spy
()
}
fakeAnnotator
=
{
fakeAnnotator
=
{
plugins
:
{
plugins
:
{
Auth
:
{
withToken
:
sandbox
.
spy
()}
Auth
:
{
withToken
:
sandbox
.
spy
()}
...
@@ -36,6 +24,15 @@ describe 'h', ->
...
@@ -36,6 +24,15 @@ describe 'h', ->
addPlugin
:
sandbox
.
spy
()
addPlugin
:
sandbox
.
spy
()
}
}
fakeAuth
=
{
user
:
null
}
fakeIdentity
=
{
watch
:
sandbox
.
spy
()
request
:
sandbox
.
spy
()
}
fakeLocation
=
{
fakeLocation
=
{
search
:
sandbox
.
stub
().
returns
({})
search
:
sandbox
.
stub
().
returns
({})
}
}
...
@@ -66,7 +63,8 @@ describe 'h', ->
...
@@ -66,7 +63,8 @@ describe 'h', ->
$controller
(
'AppController'
,
{
$scope
:
$scope
})
$controller
(
'AppController'
,
{
$scope
:
$scope
})
it
'does not show login form for logged in users'
,
->
it
'does not show login form for logged in users'
,
->
app
=
createController
()
createController
()
$scope
.
$digest
()
assert
.
isFalse
(
$scope
.
dialog
.
visible
)
assert
.
isFalse
(
$scope
.
dialog
.
visible
)
describe
'AnnotationViewerController'
,
->
describe
'AnnotationViewerController'
,
->
...
...
tests/js/services/auth-test.coffee
View file @
ba6c10fa
...
@@ -13,16 +13,25 @@ describe 'h', ->
...
@@ -13,16 +13,25 @@ describe 'h', ->
fakeAnnotator
=
{
fakeAnnotator
=
{
plugins
:
{
plugins
:
{
Auth
:
{
withToken
:
sandbox
.
spy
()}
Auth
:
{
withToken
:
sandbox
.
spy
()
destroy
:
sandbox
.
spy
()
element
:
{
removeData
:
sandbox
.
spy
()}
}
Permissions
:
{
destroy
:
sandbox
.
spy
()
setUser
:
sandbox
.
spy
()
}
}
}
options
:
{}
options
:
{}
socialView
:
{
name
:
'none'
}
socialView
:
{
name
:
'none'
}
addPlugin
:
sandbox
.
spy
()
addPlugin
:
sandbox
.
spy
()
}
}
fakeIdentity
=
{
fakeIdentity
=
{
watch
:
sandbox
.
spy
()
watch
:
sandbox
.
spy
()
request
:
sandbox
.
spy
()
request
:
sandbox
.
spy
()
}
}
$provide
.
value
'annotator'
,
fakeAnnotator
$provide
.
value
'annotator'
,
fakeAnnotator
...
@@ -42,8 +51,29 @@ describe 'h', ->
...
@@ -42,8 +51,29 @@ describe 'h', ->
it
'watches the identity service for identity change events'
,
->
it
'watches the identity service for identity change events'
,
->
assert
.
calledOnce
(
fakeIdentity
.
watch
)
assert
.
calledOnce
(
fakeIdentity
.
watch
)
it
'sets the
persona
to null when the identity has been checked'
,
->
it
'sets the
user
to null when the identity has been checked'
,
->
{
on
login
,
onlogout
,
on
ready
}
=
fakeIdentity
.
watch
.
args
[
0
][
0
]
{
onready
}
=
fakeIdentity
.
watch
.
args
[
0
][
0
]
onready
()
onready
()
assert
.
isNull
(
auth
.
user
)
assert
.
isNull
(
auth
.
user
)
it
'sets the Permissions plugin and sets auth.user at login'
,
->
{
onlogin
}
=
fakeIdentity
.
watch
.
args
[
0
][
0
]
onlogin
(
'test-assertion'
)
fakeToken
=
{
userId
:
'acct:hey@joe'
}
userSetter
=
fakeAnnotator
.
plugins
.
Auth
.
withToken
.
args
[
0
][
0
]
userSetter
(
fakeToken
)
assert
.
equal
(
auth
.
user
,
'acct:hey@joe'
)
secondPlugin
=
fakeAnnotator
.
addPlugin
.
args
[
1
]
assert
.
equal
(
secondPlugin
[
0
],
'Permissions'
)
it
'destroys the plugins at logout and sets auth.user to null'
,
->
{
onlogout
}
=
fakeIdentity
.
watch
.
args
[
0
][
0
]
auth
.
user
=
'acct:hey@joe'
authPlugin
=
fakeAnnotator
.
plugins
.
Auth
permissionsPlugin
=
fakeAnnotator
.
plugins
.
Permissions
onlogout
()
assert
.
called
(
authPlugin
.
destroy
)
assert
.
called
(
permissionsPlugin
.
destroy
)
assert
.
equal
(
auth
.
user
,
null
)
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