|
@@ -42,6 +42,7 @@ describe "Subscription Handler sanboxed", ->
|
|
|
updateSubscription: sinon.stub().callsArgWith(2, null, @activeRecurlySubscription)
|
|
updateSubscription: sinon.stub().callsArgWith(2, null, @activeRecurlySubscription)
|
|
|
cancelSubscription: sinon.stub().callsArgWith(1)
|
|
cancelSubscription: sinon.stub().callsArgWith(1)
|
|
|
reactivateSubscription: sinon.stub().callsArgWith(1)
|
|
reactivateSubscription: sinon.stub().callsArgWith(1)
|
|
|
|
|
+ redeemCoupon:sinon.stub().callsArgWith(2)
|
|
|
|
|
|
|
|
@SubscriptionUpdater =
|
|
@SubscriptionUpdater =
|
|
|
syncSubscription: sinon.stub().callsArgWith(2)
|
|
syncSubscription: sinon.stub().callsArgWith(2)
|
|
@@ -86,7 +87,7 @@ describe "Subscription Handler sanboxed", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@plan_code = "collaborator"
|
|
@plan_code = "collaborator"
|
|
|
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription)
|
|
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription)
|
|
|
- @SubscriptionHandler.updateSubscription(@user, @plan_code, done)
|
|
|
|
|
|
|
+ @SubscriptionHandler.updateSubscription(@user, @plan_code, null, done)
|
|
|
|
|
|
|
|
it "should update the subscription", ->
|
|
it "should update the subscription", ->
|
|
|
@RecurlyWrapper.updateSubscription.calledWith(@subscription.recurlySubscription_id).should.equal true
|
|
@RecurlyWrapper.updateSubscription.calledWith(@subscription.recurlySubscription_id).should.equal true
|
|
@@ -102,26 +103,36 @@ describe "Subscription Handler sanboxed", ->
|
|
|
@SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal @activeRecurlySubscription
|
|
@SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal @activeRecurlySubscription
|
|
|
@SubscriptionUpdater.syncSubscription.args[0][1].should.deep.equal @user._id
|
|
@SubscriptionUpdater.syncSubscription.args[0][1].should.deep.equal @user._id
|
|
|
|
|
|
|
|
- # describe "without a valid plan code", ->
|
|
|
|
|
- # beforeEach (done) ->
|
|
|
|
|
- # @plan_code = "not-a-plan"
|
|
|
|
|
- # @LimitationsManager.userHasSubscription.callsArgWith(1, null, true)
|
|
|
|
|
-
|
|
|
|
|
- # @SubscriptionHandler.updateSubscription(@user, @plan_code, done)
|
|
|
|
|
-
|
|
|
|
|
- # it "should not update the subscription", ->
|
|
|
|
|
- # @RecurlyWrapper.updateSubscription.called.should.equal false
|
|
|
|
|
- # @SubscriptionHandler.syncSubscriptionToUser.called.should.equal false
|
|
|
|
|
-
|
|
|
|
|
describe "with a user without a subscription", ->
|
|
describe "with a user without a subscription", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false)
|
|
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false)
|
|
|
- @SubscriptionHandler.updateSubscription(@user, @plan_code, done)
|
|
|
|
|
|
|
+ @SubscriptionHandler.updateSubscription(@user, @plan_code, null, done)
|
|
|
|
|
|
|
|
it "should redirect to the subscription dashboard", ->
|
|
it "should redirect to the subscription dashboard", ->
|
|
|
@RecurlyWrapper.updateSubscription.called.should.equal false
|
|
@RecurlyWrapper.updateSubscription.called.should.equal false
|
|
|
@SubscriptionHandler.syncSubscriptionToUser.called.should.equal false
|
|
@SubscriptionHandler.syncSubscriptionToUser.called.should.equal false
|
|
|
|
|
|
|
|
|
|
+ describe "with a coupon code", ->
|
|
|
|
|
+ beforeEach (done) ->
|
|
|
|
|
+ @plan_code = "collaborator"
|
|
|
|
|
+ @coupon_code = "1231312"
|
|
|
|
|
+ @LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription)
|
|
|
|
|
+ @SubscriptionHandler.updateSubscription(@user, @plan_code, @coupon_code, done)
|
|
|
|
|
+
|
|
|
|
|
+ it "should get the users account", ->
|
|
|
|
|
+ @RecurlyWrapper.getSubscription.calledWith(@activeRecurlySubscription.uuid).should.equal true
|
|
|
|
|
+
|
|
|
|
|
+ it "should redeme the coupon", (done)->
|
|
|
|
|
+ @RecurlyWrapper.redeemCoupon.calledWith(@activeRecurlySubscription.account.account_code, @coupon_code).should.equal true
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
|
|
+ it "should update the subscription", ->
|
|
|
|
|
+ @RecurlyWrapper.updateSubscription.calledWith(@subscription.recurlySubscription_id).should.equal true
|
|
|
|
|
+ updateOptions = @RecurlyWrapper.updateSubscription.args[0][1]
|
|
|
|
|
+ updateOptions.plan_code.should.equal @plan_code
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
describe "cancelSubscription", ->
|
|
describe "cancelSubscription", ->
|
|
|
describe "with a user without a subscription", ->
|
|
describe "with a user without a subscription", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|