Remove unused subscription downgrade logic
This commit is contained in:
-38
@@ -1,38 +0,0 @@
|
||||
sinon = require('sinon')
|
||||
require('chai').should()
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
modulePath = require('path').join __dirname, '../../../../app/js/Features/Subscription/SubscriptionBackgroundTasks'
|
||||
|
||||
describe "SubscriptionBackgroundTasks", ->
|
||||
beforeEach ->
|
||||
@SubscriptionLocator = {}
|
||||
@Settings = defaultPlanCode:
|
||||
collaborators: 13
|
||||
versioning: true
|
||||
@SubscriptionUpdater = {}
|
||||
|
||||
@SubscriptionBackgroundTasks = SandboxedModule.require modulePath, requires:
|
||||
"./SubscriptionLocator" : @SubscriptionLocator
|
||||
"./SubscriptionUpdater" : @SubscriptionUpdater
|
||||
"settings-sharelatex" : @Settings
|
||||
"logger-sharelatex" : log:->
|
||||
|
||||
describe 'downgradeExpiredFreeTrials', ->
|
||||
beforeEach ->
|
||||
@subscriptions = [
|
||||
{ admin_id : 1 },
|
||||
{ admin_id : 2 }
|
||||
]
|
||||
@SubscriptionUpdater.downgradeFreeTrial = sinon.stub().callsArg(1)
|
||||
@SubscriptionLocator.expiredFreeTrials = sinon.stub().callsArgWith(0, null, @subscriptions)
|
||||
@callback = sinon.stub()
|
||||
@SubscriptionBackgroundTasks.downgradeExpiredFreeTrials(@callback)
|
||||
|
||||
it "should downgrade each expired subscription", ->
|
||||
@SubscriptionUpdater.downgradeFreeTrial.callCount.should.equal @subscriptions.length
|
||||
for subscription in @subscriptions
|
||||
@SubscriptionUpdater.downgradeFreeTrial.calledWith(subscription).should.equal true
|
||||
|
||||
it "should return the subscriptions in the callback", ->
|
||||
@callback.called.should.equal true
|
||||
@callback.args[0][1].should.deep.equal @subscriptions
|
||||
@@ -40,21 +40,3 @@ describe "Subscription Locator Tests", ->
|
||||
subscription.should.equal @subscription
|
||||
done()
|
||||
|
||||
describe "expiredFreeTrials", ->
|
||||
beforeEach ->
|
||||
@subscriptions = [ _id : 1, freeTrial:{} ]
|
||||
@Subscription.find = sinon.stub().callsArgWith(1, null, @subscriptions)
|
||||
|
||||
it "should look for subscriptions with an expired free trial that haven't been downgraded", (done)->
|
||||
@SubscriptionLocator.expiredFreeTrials =>
|
||||
@Subscription.find.called.should.equal true
|
||||
query = @Subscription.find.args[0][0]
|
||||
assert.isDefined(query["freeTrial.expiresAt"].$lt)
|
||||
assert.deepEqual(query["freeTrial.downgraded"],"$ne": true)
|
||||
done()
|
||||
|
||||
it "should return the subscriptions in a callback", (done)->
|
||||
@SubscriptionLocator.expiredFreeTrials (err, subscriptions)=>
|
||||
subscriptions.should.deep.equal @subscriptions
|
||||
done()
|
||||
|
||||
|
||||
@@ -119,20 +119,6 @@ describe "Subscription Updater", ->
|
||||
@subscription.save.called.should.equal true
|
||||
done()
|
||||
|
||||
|
||||
describe 'downgradeFreeTrial', ->
|
||||
it "should tell the feature updater to update the user", (done)->
|
||||
@SubscriptionUpdater.downgradeFreeTrial @subscription, =>
|
||||
@UserFeaturesUpdater.updateFeatures.calledWith(@subscription.admin_id, @Settings.defaultPlanCode).should.equal true
|
||||
done()
|
||||
|
||||
it "should update the subscription", (done)->
|
||||
@SubscriptionUpdater.downgradeFreeTrial @subscription, =>
|
||||
@subscription.freeTrial.downgraded.should.equal true
|
||||
@subscription.save.called.should.equal true
|
||||
done()
|
||||
|
||||
|
||||
describe "addUserToGroup", ->
|
||||
it "should add the users id to the group as a set", (done)->
|
||||
@SubscriptionUpdater.addUserToGroup @adminUser._id, @otherUserId, =>
|
||||
|
||||
Reference in New Issue
Block a user