Merge pull request #895 from sharelatex/ta-add-method-alias

add userHasSubscriptionOrIsGroupMember alias
This commit is contained in:
Shane Kilkelly 2018-09-05 11:43:49 +01:00 committed by GitHub
commit 9b37b0e66f
2 changed files with 10 additions and 0 deletions

View file

@ -43,6 +43,11 @@ module.exports = LimitationsManager =
logger.log {user_id:user._id, isMember, hasSubscription, hasV1Subscription}, "checking if user has subscription or is group member" logger.log {user_id:user._id, isMember, hasSubscription, hasV1Subscription}, "checking if user has subscription or is group member"
callback err, isMember or hasSubscription or hasV1Subscription, subscription callback err, isMember or hasSubscription or hasV1Subscription, subscription
# alias for backward-compatibility with modules. Use `haspaidsubscription` instead
userHasSubscriptionOrIsGroupMember: (user, callback) ->
@hasPaidSubscription(user, callback)
userHasV2Subscription: (user, callback = (err, hasSubscription, subscription)->) -> userHasV2Subscription: (user, callback = (err, hasSubscription, subscription)->) ->
logger.log user_id:user._id, "checking if user has subscription" logger.log user_id:user._id, "checking if user has subscription"
SubscriptionLocator.getUsersSubscription user._id, (err, subscription)-> SubscriptionLocator.getUsersSubscription user._id, (err, subscription)->

View file

@ -277,6 +277,11 @@ describe "LimitationsManager", ->
hasSubOrIsGroupMember.should.equal false hasSubOrIsGroupMember.should.equal false
done() done()
it "should have userHasSubscriptionOrIsGroupMember alias", (done)->
@LimitationsManager.userHasSubscriptionOrIsGroupMember @user, (err, hasSubOrIsGroupMember)->
hasSubOrIsGroupMember.should.equal false
done()
describe "userHasV1OrV2Subscription", -> describe "userHasV1OrV2Subscription", ->
beforeEach -> beforeEach ->
@LimitationsManager.userHasV2Subscription = sinon.stub().yields(null, false) @LimitationsManager.userHasV2Subscription = sinon.stub().yields(null, false)