|
|
@@ -48,12 +48,6 @@ describe('LimitationsManager', function () {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- this.V1SubscriptionManager = {
|
|
|
- promises: {
|
|
|
- getSubscriptionsFromV1: sinon.stub().resolves(),
|
|
|
- },
|
|
|
- }
|
|
|
-
|
|
|
this.CollaboratorsGetter = {
|
|
|
promises: {
|
|
|
getInvitedCollaboratorCount: sinon.stub().resolves(),
|
|
|
@@ -560,7 +554,7 @@ describe('LimitationsManager', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe('userHasV2Subscription', function () {
|
|
|
+ describe('userHasSubscription', function () {
|
|
|
beforeEach(function () {
|
|
|
this.SubscriptionLocator.promises.getUsersSubscription = sinon
|
|
|
.stub()
|
|
|
@@ -573,7 +567,7 @@ describe('LimitationsManager', function () {
|
|
|
.resolves({
|
|
|
recurlySubscription_id: '1234',
|
|
|
})
|
|
|
- this.LimitationsManager.userHasV2Subscription(
|
|
|
+ this.LimitationsManager.userHasSubscription(
|
|
|
this.user,
|
|
|
(err, hasSubscription) => {
|
|
|
assert.equal(err, null)
|
|
|
@@ -586,7 +580,7 @@ describe('LimitationsManager', function () {
|
|
|
it('should return false if the recurly token is not set', function (done) {
|
|
|
this.SubscriptionLocator.promises.getUsersSubscription.resolves({})
|
|
|
this.subscription = {}
|
|
|
- this.LimitationsManager.userHasV2Subscription(
|
|
|
+ this.LimitationsManager.userHasSubscription(
|
|
|
this.user,
|
|
|
(err, hasSubscription) => {
|
|
|
assert.equal(err, null)
|
|
|
@@ -598,7 +592,7 @@ describe('LimitationsManager', function () {
|
|
|
|
|
|
it('should return false if the subscription is undefined', function (done) {
|
|
|
this.SubscriptionLocator.promises.getUsersSubscription.resolves()
|
|
|
- this.LimitationsManager.userHasV2Subscription(
|
|
|
+ this.LimitationsManager.userHasSubscription(
|
|
|
this.user,
|
|
|
(err, hasSubscription) => {
|
|
|
assert.equal(err, null)
|
|
|
@@ -613,7 +607,7 @@ describe('LimitationsManager', function () {
|
|
|
this.SubscriptionLocator.promises.getUsersSubscription.resolves(
|
|
|
stubbedSubscription
|
|
|
)
|
|
|
- this.LimitationsManager.userHasV2Subscription(
|
|
|
+ this.LimitationsManager.userHasSubscription(
|
|
|
this.user,
|
|
|
(err, hasSubOrIsGroupMember, subscription) => {
|
|
|
assert.equal(err, null)
|
|
|
@@ -632,7 +626,7 @@ describe('LimitationsManager', function () {
|
|
|
})
|
|
|
|
|
|
it('should return true', function (done) {
|
|
|
- this.LimitationsManager.userHasV2Subscription(
|
|
|
+ this.LimitationsManager.userHasSubscription(
|
|
|
this.user,
|
|
|
(err, hasSubscription, subscription) => {
|
|
|
assert.equal(err, null)
|
|
|
@@ -643,7 +637,7 @@ describe('LimitationsManager', function () {
|
|
|
})
|
|
|
|
|
|
it('should return the subscription', function (done) {
|
|
|
- this.LimitationsManager.userHasV2Subscription(
|
|
|
+ this.LimitationsManager.userHasSubscription(
|
|
|
this.user,
|
|
|
(err, hasSubscription, subscription) => {
|
|
|
assert.equal(err, null)
|
|
|
@@ -699,9 +693,6 @@ describe('LimitationsManager', function () {
|
|
|
this.SubscriptionLocator.promises.getUsersSubscription = sinon
|
|
|
.stub()
|
|
|
.resolves(null)
|
|
|
- this.V1SubscriptionManager.promises.userHasV1Subscription = sinon
|
|
|
- .stub()
|
|
|
- .yields(null, null)
|
|
|
})
|
|
|
|
|
|
it('should return true if userIsMemberOfGroupSubscription', function (done) {
|
|
|
@@ -718,7 +709,7 @@ describe('LimitationsManager', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
- it('should return true if userHasV2Subscription', function (done) {
|
|
|
+ it('should return true if userHasSubscription', function (done) {
|
|
|
this.SubscriptionLocator.promises.getUsersSubscription = sinon
|
|
|
.stub()
|
|
|
.resolves({ recurlySubscription_id: '123' })
|
|
|
@@ -732,20 +723,6 @@ describe('LimitationsManager', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
- it('should return true if userHasV1Subscription', function (done) {
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1 = sinon
|
|
|
- .stub()
|
|
|
- .resolves({ has_subscription: true })
|
|
|
- this.LimitationsManager.hasPaidSubscription(
|
|
|
- this.user,
|
|
|
- (err, hasSubOrIsGroupMember) => {
|
|
|
- assert.equal(err, null)
|
|
|
- hasSubOrIsGroupMember.should.equal(true)
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
it('should return false if none are true', function (done) {
|
|
|
this.LimitationsManager.hasPaidSubscription(
|
|
|
this.user,
|
|
|
@@ -769,56 +746,6 @@ describe('LimitationsManager', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe('userHasV1OrV2Subscription', function () {
|
|
|
- beforeEach(function () {
|
|
|
- this.SubscriptionLocator.promises.getUsersSubscription = sinon
|
|
|
- .stub()
|
|
|
- .resolves()
|
|
|
- this.V1SubscriptionManager.promises.userHasV1Subscription = sinon
|
|
|
- .stub()
|
|
|
- .resolves()
|
|
|
- })
|
|
|
-
|
|
|
- it('should return true if userHasV2Subscription', function (done) {
|
|
|
- this.SubscriptionLocator.promises.getUsersSubscription = sinon
|
|
|
- .stub()
|
|
|
- .resolves({ recurlySubscription_id: '123' })
|
|
|
- this.LimitationsManager.userHasV1OrV2Subscription(
|
|
|
- this.user,
|
|
|
- (err, hasSub) => {
|
|
|
- assert.equal(err, null)
|
|
|
- hasSub.should.equal(true)
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- it('should return true if userHasV1Subscription', function (done) {
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1 = sinon
|
|
|
- .stub()
|
|
|
- .resolves({ has_subscription: true })
|
|
|
- this.LimitationsManager.userHasV1OrV2Subscription(
|
|
|
- this.user,
|
|
|
- (err, hasSub) => {
|
|
|
- assert.equal(err, null)
|
|
|
- hasSub.should.equal(true)
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- it('should return false if none are true', function (done) {
|
|
|
- this.LimitationsManager.userHasV1OrV2Subscription(
|
|
|
- this.user,
|
|
|
- (err, hasSub) => {
|
|
|
- assert.equal(err, null)
|
|
|
- hasSub.should.equal(false)
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
describe('hasGroupMembersLimitReached', function () {
|
|
|
beforeEach(function () {
|
|
|
this.subscriptionId = '12312'
|
|
|
@@ -875,57 +802,4 @@ describe('LimitationsManager', function () {
|
|
|
)
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- describe('userHasV1Subscription', function () {
|
|
|
- it('should return true if v1 returns has_subscription = true', function (done) {
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1 = sinon
|
|
|
- .stub()
|
|
|
- .resolves({ has_subscription: true })
|
|
|
- this.LimitationsManager.userHasV1Subscription(
|
|
|
- this.user,
|
|
|
- (error, result) => {
|
|
|
- assert.equal(error, null)
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1
|
|
|
- .calledWith(this.userId)
|
|
|
- .should.equal(true)
|
|
|
- result.should.equal(true)
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- it('should return false if v1 returns has_subscription = false', function (done) {
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1 = sinon
|
|
|
- .stub()
|
|
|
- .resolves({ has_subscription: false })
|
|
|
- this.LimitationsManager.userHasV1Subscription(
|
|
|
- this.user,
|
|
|
- (error, result) => {
|
|
|
- assert.equal(error, null)
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1
|
|
|
- .calledWith(this.userId)
|
|
|
- .should.equal(true)
|
|
|
- result.should.equal(false)
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- it('should return false if v1 returns nothing', function (done) {
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1 = sinon
|
|
|
- .stub()
|
|
|
- .resolves({ has_subscription: false })
|
|
|
- this.LimitationsManager.userHasV1Subscription(
|
|
|
- this.user,
|
|
|
- (error, result) => {
|
|
|
- assert.equal(error, null)
|
|
|
- this.V1SubscriptionManager.promises.getSubscriptionsFromV1
|
|
|
- .calledWith(this.userId)
|
|
|
- .should.equal(true)
|
|
|
- result.should.equal(false)
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
- })
|
|
|
})
|