Don’t show upgrade prompts for users with custom subscription accounts.

Set `hasValidSubscription` to true if user subscription is custom.
This commit is contained in:
Shane Kilkelly 2016-07-19 10:15:45 +01:00
parent 62a444082d
commit effc3727be
2 changed files with 18 additions and 2 deletions

View file

@ -38,7 +38,7 @@ module.exports =
SubscriptionLocator.getUsersSubscription user._id, (err, subscription)-> SubscriptionLocator.getUsersSubscription user._id, (err, subscription)->
if err? if err?
return callback(err) return callback(err)
hasValidSubscription = subscription? and subscription.recurlySubscription_id? hasValidSubscription = subscription? and (subscription.recurlySubscription_id? or subscription.customAccount?)
logger.log user:user, hasValidSubscription:hasValidSubscription, subscription:subscription, "checking if user has subscription" logger.log user:user, hasValidSubscription:hasValidSubscription, subscription:subscription, "checking if user has subscription"
callback err, hasValidSubscription, subscription callback err, hasValidSubscription, subscription

View file

@ -128,6 +128,22 @@ describe "LimitationsManager", ->
subscription.should.deep.equal stubbedSubscription subscription.should.deep.equal stubbedSubscription
done() done()
describe "when user has a custom account", ->
beforeEach ->
@fakeSubscription = {customAccount: true}
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, @fakeSubscription)
it 'should return true', (done) ->
@LimitationsManager.userHasSubscription @user, (err, hasSubscription, subscription)->
hasSubscription.should.equal true
done()
it 'should return the subscription', (done) ->
@LimitationsManager.userHasSubscription @user, (err, hasSubscription, subscription)=>
subscription.should.deep.equal @fakeSubscription
done()
describe "userIsMemberOfGroupSubscription", -> describe "userIsMemberOfGroupSubscription", ->
beforeEach -> beforeEach ->
@SubscriptionLocator.getMemberSubscriptions = sinon.stub() @SubscriptionLocator.getMemberSubscriptions = sinon.stub()