mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-23 07:32:25 +00:00
Add new fields to mongoose subscription schema
GitOrigin-RevId: 6b28d7464482a8d5729709f99893b333c3d7f9c2
This commit is contained in:
parent
8c6c67564f
commit
3311066363
3 changed files with 36 additions and 2 deletions
|
@ -56,6 +56,24 @@ const SubscriptionSchema = new Schema(
|
|||
type: Date,
|
||||
},
|
||||
},
|
||||
v1_id: {
|
||||
type: Number,
|
||||
required: false,
|
||||
min: 1,
|
||||
},
|
||||
salesforce_id: {
|
||||
type: String,
|
||||
required: false,
|
||||
validate: {
|
||||
validator: function (salesforceId) {
|
||||
return (
|
||||
salesforceId == null ||
|
||||
salesforceId === '' ||
|
||||
salesforceId.match(/^(?:[A-Za-z0-9]{15}|[A-Za-z0-9]{18})$/)
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
ssoConfig: { type: ObjectId, ref: 'SSOConfig' },
|
||||
},
|
||||
{ minimize: false }
|
||||
|
|
|
@ -47,7 +47,7 @@ describe('mongoose', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Subsription', function () {
|
||||
describe('Subscription', function () {
|
||||
let user
|
||||
|
||||
beforeEach(async function () {
|
||||
|
@ -56,7 +56,11 @@ describe('mongoose', function () {
|
|||
|
||||
it('allows the creation of a subscription', async function () {
|
||||
await expect(
|
||||
Subscription.create({ admin_id: user._id, manager_ids: [user._id] })
|
||||
Subscription.create({
|
||||
admin_id: user._id,
|
||||
manager_ids: [user._id],
|
||||
salesforce_id: 'a0a0a00000AAA0AAAA',
|
||||
})
|
||||
).to.be.fulfilled
|
||||
await expect(Subscription.findOne({ admin_id: user._id })).to.eventually
|
||||
.exist
|
||||
|
@ -65,5 +69,15 @@ describe('mongoose', function () {
|
|||
it('does not allow the creation of a subscription without a manager', async function () {
|
||||
await expect(Subscription.create({ admin_id: user._id })).to.be.rejected
|
||||
})
|
||||
|
||||
it('does not allow the creation of a subscription with an invalid salesforce_id', async function () {
|
||||
await expect(
|
||||
Subscription.create({
|
||||
admin_id: user._id,
|
||||
manager_ids: [user._id],
|
||||
salesforce_id: 'a00aaaAAa0000a',
|
||||
})
|
||||
).to.be.rejected
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -11,4 +11,6 @@ export type Subscription = {
|
|||
customAccount: boolean
|
||||
ssoConfig: SSOConfig
|
||||
managedUsersEnabled: boolean
|
||||
v1_id: number
|
||||
salesforce_id: string
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue