mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-28 11:36:21 +08:00
test of Account.inGroup
This commit is contained in:
@@ -158,6 +158,9 @@ Account.methods.updatePassword = (password, callback) ->
|
||||
@password = utils.hashPassword password, @password_salt
|
||||
@save callback
|
||||
|
||||
Account.methods.inGroup = (group) ->
|
||||
return group in @groups
|
||||
|
||||
_.extend app.models,
|
||||
Account: mongoose.model 'Account', Account
|
||||
|
||||
@@ -168,6 +171,3 @@ exports.incBalance = (account, type, amount, payload, callback) ->
|
||||
, ->
|
||||
mBalance.create account, type, amount, payload, (err, balance_log) ->
|
||||
callback balance_log
|
||||
|
||||
exports.inGroup = (account, group) ->
|
||||
return group in account.groups
|
||||
|
||||
@@ -98,3 +98,11 @@ describe 'model/account', ->
|
||||
account.matchPassword(util.password).should.be.ok
|
||||
account.matchPassword(old_password).should.not.ok
|
||||
done()
|
||||
|
||||
describe 'inGroup', ->
|
||||
it 'should in it', ->
|
||||
util.account.groups = ['test']
|
||||
util.account.inGroup('test').should.be.ok
|
||||
|
||||
it 'should not in it', ->
|
||||
util.account.inGroup('group_not_exist').should.not.ok
|
||||
|
||||
Reference in New Issue
Block a user