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)->
if 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"
callback err, hasValidSubscription, subscription

View file

@ -127,7 +127,23 @@ describe "LimitationsManager", ->
@LimitationsManager.userHasSubscription @user, (err, hasSubOrIsGroupMember, subscription)->
subscription.should.deep.equal stubbedSubscription
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", ->
beforeEach ->
@SubscriptionLocator.getMemberSubscriptions = sinon.stub()