From d2bccbec25e0331e2ac27f330c604416816d7327 Mon Sep 17 00:00:00 2001 From: Douglas Lovell Date: Thu, 24 Jan 2019 08:52:26 -0300 Subject: [PATCH] Merge remote-tracking branch 'origin/sk-admin-panel-projects' GitOrigin-RevId: 56f17fe3bec6252bd3d933899e540813550a36ff --- .../Features/Project/ProjectOptionsHandler.coffee | 10 ++++++++++ .../coffee/Project/ProjectOptionsHandlerTests.coffee | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/services/web/app/coffee/Features/Project/ProjectOptionsHandler.coffee b/services/web/app/coffee/Features/Project/ProjectOptionsHandler.coffee index b9469e566e..7bdad93b03 100644 --- a/services/web/app/coffee/Features/Project/ProjectOptionsHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectOptionsHandler.coffee @@ -57,3 +57,13 @@ module.exports = if err? logger.err err:err, "error setting brandVariationId" 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() diff --git a/services/web/test/unit/coffee/Project/ProjectOptionsHandlerTests.coffee b/services/web/test/unit/coffee/Project/ProjectOptionsHandlerTests.coffee index 16121e0399..498fac355f 100644 --- a/services/web/test/unit/coffee/Project/ProjectOptionsHandlerTests.coffee +++ b/services/web/test/unit/coffee/Project/ProjectOptionsHandlerTests.coffee @@ -1,5 +1,6 @@ sinon = require('sinon') chai = require('chai') +expect = chai.expect should = chai.should() modulePath = "../../../../app/js/Features/Project/ProjectOptionsHandler.js" SandboxedModule = require('sandboxed-module') @@ -97,3 +98,12 @@ describe 'ProjectOptionsHandler', -> @handler.setBrandVariationId project_id, "", (err)=> @projectModel.update.called.should.equal false 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]()