 sinon = require 'sinon'
 modulePath = "../../../../app/js/Features/Subscription/SubscriptionUpdater"
 assert = require("chai").assert
-ObjectId = require('mongoose').Types.ObjectId	
+ObjectId = require('mongoose').Types.ObjectId
 
 describe "SubscriptionUpdater", ->
 
 	beforeEach ->
-		@recurlySubscription = 
+		@recurlySubscription =
 			uuid: "1238uoijdasjhd"
 			plan:
 				plan_code: "kjhsakjds"
-		@adminUser = 
+		@adminUser =
 			_id: @adminuser_id = "5208dd34438843e2db000007"
 		@otherUserId = "5208dd34438842e2db000005"
 		@allUserIds = ["13213", "dsadas", "djsaiud89"]


		it "should add the users id to the group as a set", (done)->
			@SubscriptionUpdater.addUserToGroup @adminUser._id, @otherUserId, =>
				searchOps = 
					admin_id: @adminUser._id
				insertOperation = 
					"$addToSet": {member_ids:@otherUserId}
				@findAndModifyStub.calledWith(searchOps, insertOperation).should.equal true
				done()

		@updateStub = sinon.stub().callsArgWith(2, null)
		@findAndModifyStub = sinon.stub().callsArgWith(2, null, @subscription)
		@SubscriptionModel = class
			constructor: (opts)->
				subscription.admin_id = opts.admin_id
				return subscription
			@remove: sinon.stub().yields()
		@SubscriptionModel.update = @updateStub
		@SubscriptionModel.findAndModify = @findAndModifyStub

		@SubscriptionLocator =
			getUsersSubscription: sinon.stub()
			getGroupSubscriptionMemberOf:sinon.stub()

		@Settings =
			freeTrialPlanCode: "collaborator"
			defaultPlanCode: "personal"
			defaultFeatures: { "default": "features" }
