diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee index 105a9a4a0d..c3423482ae 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionHandler.coffee @@ -6,6 +6,7 @@ logger = require('logger-sharelatex') SubscriptionUpdater = require("./SubscriptionUpdater") LimitationsManager = require('./LimitationsManager') EmailHandler = require("../Email/EmailHandler") +DropboxHandler = require("../Dropbox/DropboxHandler") module.exports = @@ -49,7 +50,8 @@ module.exports = ONE_HOUR_IN_MS = 1000 * 60 * 60 setTimeout (-> EmailHandler.sendEmail "canceledSubscription", emailOpts ), ONE_HOUR_IN_MS - callback() + DropboxHandler.unlinkAccount user._id, -> + callback() else callback() diff --git a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee index 8452000f02..ce824f4c9e 100644 --- a/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Subscription/SubscriptionHandlerTests.coffee @@ -44,6 +44,9 @@ describe "Subscription Handler sanboxed", -> reactivateSubscription: sinon.stub().callsArgWith(1) redeemCoupon:sinon.stub().callsArgWith(2) + @DropboxHandler = + unlinkAccount:sinon.stub().callsArgWith(1) + @SubscriptionUpdater = syncSubscription: sinon.stub().callsArgWith(2) startFreeTrial: sinon.stub().callsArgWith(1) @@ -62,6 +65,7 @@ describe "Subscription Handler sanboxed", -> "logger-sharelatex":{log:->} './LimitationsManager':@LimitationsManager "../Email/EmailHandler":@EmailHandler + "../Dropbox/DropboxHandler":@DropboxHandler @SubscriptionHandler.syncSubscriptionToUser = sinon.stub().callsArgWith(2) @@ -152,6 +156,11 @@ describe "Subscription Handler sanboxed", -> @RecurlyWrapper.cancelSubscription.called.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 "with a user without a subscription", -> beforeEach (done) ->