test of Account.inGroup

This commit is contained in:
jysperm
2014-10-24 03:23:58 +08:00
parent 173f4628a7
commit 2231465cef
2 changed files with 11 additions and 3 deletions

View File

@@ -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

View File

@@ -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