Merge remote-tracking branch 'origin/sk-admin-panel-projects'

GitOrigin-RevId: 56f17fe3bec6252bd3d933899e540813550a36ff
This commit is contained in:
Douglas Lovell 2019-01-24 08:52:26 -03:00 committed by sharelatex
parent bd9adbae52
commit d2bccbec25
2 changed files with 20 additions and 0 deletions

View file

@ -57,3 +57,13 @@ module.exports =
if err? if err?
logger.err err:err, "error setting brandVariationId" logger.err err:err, "error setting brandVariationId"
callback() callback()
unsetBrandVariationId: (project_id, callback = ()->)->
logger.log project_id:project_id, "unsetting the brand variation id"
conditions = {_id:project_id}
update = {$unset: {brandVariationId: 1}}
Project.update conditions, update, {}, (err)->
if err?
logger.err err:err, "error unsetting brandVariationId"
return callback(err)
callback()

View file

@ -1,5 +1,6 @@
sinon = require('sinon') sinon = require('sinon')
chai = require('chai') chai = require('chai')
expect = chai.expect
should = chai.should() should = chai.should()
modulePath = "../../../../app/js/Features/Project/ProjectOptionsHandler.js" modulePath = "../../../../app/js/Features/Project/ProjectOptionsHandler.js"
SandboxedModule = require('sandboxed-module') SandboxedModule = require('sandboxed-module')
@ -97,3 +98,12 @@ describe 'ProjectOptionsHandler', ->
@handler.setBrandVariationId project_id, "", (err)=> @handler.setBrandVariationId project_id, "", (err)=>
@projectModel.update.called.should.equal false @projectModel.update.called.should.equal false
done() done()
describe "unsetting the brandVariationId", ->
it 'should perform and update on mongo', (done)->
@handler.unsetBrandVariationId project_id, (err)=>
args = @projectModel.update.args[0]
args[0]._id.should.equal project_id
expect(args[1]).to.deep.equal {$unset: {brandVariationId: 1}}
done()
@projectModel.update.args[0][3]()