@bluedot-innovation/models 5.1.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 5.1.1
2
+ - Added ProjectPermisisons as required
3
+
1
4
  ## 5.0.4
2
5
  - Removed value 'configurationChanged' from typeEnum from Webhook schema
3
6
 
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- requiredFields: ['username', 'firstName', 'lastName', 'isAdmin', 'accountId'],
2
+ requiredFields: ['username', 'firstName', 'lastName', 'isAdmin', 'accountId', 'projectPermissions'],
3
3
  customValidators: [
4
4
  {name: 'phoneNumber', invalidInputs: ['409203492039284232034398']},
5
5
  {name: 'creationTime', invalidInputs: ['21/07/2017', 'thursday']},
@@ -116,6 +116,17 @@ describe('User', () => {
116
116
  })
117
117
  })
118
118
 
119
+ it('should fail if projectPermissions is not provided', (done) => {
120
+ user = JSON.parse(JSON.stringify(user))
121
+ delete user.projectPermissions
122
+ const User = new UserModel(user)
123
+
124
+ User.validate((err, res) => {
125
+ assert.match(err, /(ProjectPermissions is required)/i)
126
+ done()
127
+ })
128
+ })
129
+
119
130
  it('should fail if permissionLevel is missing', (done) => {
120
131
  user = JSON.parse(JSON.stringify(user))
121
132
  user.projectPermissions[0].permissionLevel = undefined
package/models/User.js CHANGED
@@ -34,7 +34,7 @@ let UserSchema = new mongoose.Schema({
34
34
  lastUpdateTime: {type: Date, default: Date.now},
35
35
  isAdmin: {type: Boolean, required: true},
36
36
  secret: String,
37
- projectPermissions: [ProjectPermission],
37
+ projectPermissions: {type: [ProjectPermission], required: [true, 'ProjectPermissions is required']},
38
38
  accountId: {
39
39
  type: String,
40
40
  required: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",