unlink dropbox when a user cancels

This commit is contained in:
Henry Oswald 2014-10-09 17:05:41 +01:00
parent 9924882b59
commit e7984a90d7
2 changed files with 12 additions and 1 deletions

View file

@ -6,6 +6,7 @@ logger = require('logger-sharelatex')
SubscriptionUpdater = require("./SubscriptionUpdater") SubscriptionUpdater = require("./SubscriptionUpdater")
LimitationsManager = require('./LimitationsManager') LimitationsManager = require('./LimitationsManager')
EmailHandler = require("../Email/EmailHandler") EmailHandler = require("../Email/EmailHandler")
DropboxHandler = require("../Dropbox/DropboxHandler")
module.exports = module.exports =
@ -49,6 +50,7 @@ module.exports =
ONE_HOUR_IN_MS = 1000 * 60 * 60 ONE_HOUR_IN_MS = 1000 * 60 * 60
setTimeout (-> EmailHandler.sendEmail "canceledSubscription", emailOpts setTimeout (-> EmailHandler.sendEmail "canceledSubscription", emailOpts
), ONE_HOUR_IN_MS ), ONE_HOUR_IN_MS
DropboxHandler.unlinkAccount user._id, ->
callback() callback()
else else
callback() callback()

View file

@ -44,6 +44,9 @@ describe "Subscription Handler sanboxed", ->
reactivateSubscription: sinon.stub().callsArgWith(1) reactivateSubscription: sinon.stub().callsArgWith(1)
redeemCoupon:sinon.stub().callsArgWith(2) redeemCoupon:sinon.stub().callsArgWith(2)
@DropboxHandler =
unlinkAccount:sinon.stub().callsArgWith(1)
@SubscriptionUpdater = @SubscriptionUpdater =
syncSubscription: sinon.stub().callsArgWith(2) syncSubscription: sinon.stub().callsArgWith(2)
startFreeTrial: sinon.stub().callsArgWith(1) startFreeTrial: sinon.stub().callsArgWith(1)
@ -62,6 +65,7 @@ describe "Subscription Handler sanboxed", ->
"logger-sharelatex":{log:->} "logger-sharelatex":{log:->}
'./LimitationsManager':@LimitationsManager './LimitationsManager':@LimitationsManager
"../Email/EmailHandler":@EmailHandler "../Email/EmailHandler":@EmailHandler
"../Dropbox/DropboxHandler":@DropboxHandler
@SubscriptionHandler.syncSubscriptionToUser = sinon.stub().callsArgWith(2) @SubscriptionHandler.syncSubscriptionToUser = sinon.stub().callsArgWith(2)
@ -152,6 +156,11 @@ describe "Subscription Handler sanboxed", ->
@RecurlyWrapper.cancelSubscription.called.should.equal true @RecurlyWrapper.cancelSubscription.called.should.equal true
@RecurlyWrapper.cancelSubscription.calledWith(@subscription.recurlySubscription_id).should.equal true @RecurlyWrapper.cancelSubscription.calledWith(@subscription.recurlySubscription_id).should.equal true
it "should unlink dropbox", ->
@DropboxHandler.unlinkAccount.called.should.equal true
@DropboxHandler.unlinkAccount.calledWith(@user._id).should.equal true
describe "reactiveRecurlySubscription", -> describe "reactiveRecurlySubscription", ->
describe "with a user without a subscription", -> describe "with a user without a subscription", ->
beforeEach (done) -> beforeEach (done) ->