2014-02-12 10:23:40 +00:00
|
|
|
SandboxedModule = require('sandboxed-module')
|
|
|
|
should = require('chai').should()
|
|
|
|
sinon = require 'sinon'
|
|
|
|
modulePath = "../../../../app/js/Features/Subscription/UserFeaturesUpdater"
|
|
|
|
assert = require("chai").assert
|
|
|
|
|
2016-03-09 12:51:19 +00:00
|
|
|
describe "UserFeaturesUpdater", ->
|
2014-02-12 10:23:40 +00:00
|
|
|
beforeEach ->
|
|
|
|
@User =
|
|
|
|
update: sinon.stub().callsArgWith(2)
|
|
|
|
@UserFeaturesUpdater = SandboxedModule.require modulePath, requires:
|
|
|
|
'../../models/User': User:@User
|
|
|
|
"logger-sharelatex": log:->
|
|
|
|
|
|
|
|
describe "updateFeatures", ->
|
|
|
|
it "should send the users features", (done)->
|
|
|
|
user_id = "5208dd34438842e2db000005"
|
2018-05-17 15:58:58 +00:00
|
|
|
@features = {versioning:true, collaborators:10}
|
|
|
|
@UserFeaturesUpdater.updateFeatures user_id, @features, (err, features)=>
|
2014-02-12 10:23:40 +00:00
|
|
|
update = {"features.versioning":true, "features.collaborators":10}
|
|
|
|
@User.update.calledWith({"_id":user_id}, update).should.equal true
|
2018-05-17 15:58:58 +00:00
|
|
|
features.should.deep.equal @features
|
2014-02-12 10:23:40 +00:00
|
|
|
done()
|