mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-23 01:12:27 +00:00
if subscription is downgraded don't use plan code on subscription, use default instead
This commit is contained in:
parent
81cd2adfd3
commit
3d719af71e
2 changed files with 11 additions and 3 deletions
|
@ -88,7 +88,7 @@ module.exports = SubscriptionUpdater =
|
|||
logger.err err:err, user_id:user, "error getting subscription or group for _setUsersMinimumFeatures"
|
||||
return callback(err)
|
||||
{subscription, groupSubscription} = results
|
||||
if subscription? and subscription.planCode?
|
||||
if subscription? and subscription.planCode? and subscription.planCode != Settings.defaultPlanCode
|
||||
logger.log user_id:user_id, "using users subscription plan code for features"
|
||||
UserFeaturesUpdater.updateFeatures user_id, subscription.planCode, callback
|
||||
else if groupSubscription? and groupSubscription.planCode?
|
||||
|
|
|
@ -183,8 +183,6 @@ describe "SubscriptionUpdater", ->
|
|||
|
||||
describe "_setUsersMinimumFeatures", ->
|
||||
|
||||
|
||||
|
||||
it "should call updateFeatures with the subscription if set", (done)->
|
||||
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, @subscription)
|
||||
@SubscriptionLocator.getGroupSubscriptionMemberOf.callsArgWith(1, null)
|
||||
|
@ -205,6 +203,16 @@ describe "SubscriptionUpdater", ->
|
|||
assert.equal args[1], @groupSubscription.planCode
|
||||
done()
|
||||
|
||||
it "should call not call updateFeatures with users subscription if the subscription plan code is the default one (downgraded)", (done)->
|
||||
@subscription.planCode = @Settings.defaultPlanCode
|
||||
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, @subscription)
|
||||
@SubscriptionLocator.getGroupSubscriptionMemberOf.callsArgWith(1, null, @groupSubscription)
|
||||
@SubscriptionUpdater._setUsersMinimumFeatures @adminuser_id, (err)=>
|
||||
args = @UserFeaturesUpdater.updateFeatures.args[0]
|
||||
assert.equal args[0], @adminUser._id
|
||||
assert.equal args[1], @groupSubscription.planCode
|
||||
done()
|
||||
|
||||
|
||||
it "should call updateFeatures with default if there are no subscriptions for user", (done)->
|
||||
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null)
|
||||
|
|
Loading…
Reference in a new issue