 			@SubscriptionLocator.getSubscription = sinon.stub().yields(null, @subscription)
 			@FeaturesUpdater.refreshFeatures = sinon.stub().yields()
 			@SubscriptionUpdater.deleteSubscription @subscription_id, done
-			
+
 		it "should look up the subscription", ->
 			@SubscriptionLocator.getSubscription
 				.calledWith(@subscription_id)
 				.should.equal true
-		
+
 		it "should remove the subscription", ->
 			@SubscriptionModel.remove
 				.calledWith({_id: ObjectId(@subscription_id)})
 				.should.equal true
-		
+
 		it "should downgrade the admin_id", ->
 			@FeaturesUpdater.refreshFeatures
 				.calledWith(@subscription.admin_id)
 				.should.equal true
-		
+
 		it "should downgrade all of the members", ->
 			for user_id in @subscription.member_ids
 				@FeaturesUpdater.refreshFeatures

	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

sinon = require 'sinon'
modulePath = "../../../../app/js/Features/Subscription/SubscriptionUpdater"
assert = require("chai").assert
ObjectId = require('mongoose').Types.ObjectId

describe "SubscriptionUpdater", ->

	beforeEach ->
		@recurlySubscription =
			uuid: "1238uoijdasjhd"
			plan:
				plan_code: "kjhsakjds"
		@adminUser =
			_id: @adminuser_id = "5208dd34438843e2db000007"
		@otherUserId = "5208dd34438842e2db000005"
		@allUserIds = ["13213", "dsadas", "djsaiud89"]
