 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"]

	describe "_updateSubscriptionFromRecurly", ->
		beforeEach ->
			@FeaturesUpdater.refreshFeatures = sinon.stub().callsArgWith(1)
			
		it "should update the subscription with token etc when not expired", (done)->
			@SubscriptionUpdater._updateSubscriptionFromRecurly @recurlySubscription, @subscription, (err)=>
				@subscription.recurlySubscription_id.should.equal @recurlySubscription.uuid


		it "should pull the users id from the group", (done)->
			@SubscriptionUpdater.removeUserFromGroup @adminUser._id, @otherUserId, =>
				searchOps =
					admin_id:@adminUser._id
				removeOperation =
					"$pull": {member_ids:@otherUserId}
				@updateStub.calledWith(searchOps, removeOperation).should.equal true
				done()
