@bluedot-innovation/models 10.12.2 → 10.12.3

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
+ ## 10.12.3
2
+ - Allow a Push notification campaign has no zones when campaign status is draft.
3
+
1
4
  ## 10.12.2
2
5
  - Fix APNs environment enum: change 'sandbox' to 'development' to match Apple's APNs environment values
3
6
 
@@ -1196,6 +1196,13 @@ describe('Project', () => {
1196
1196
  assert.notExists(res)
1197
1197
  }
1198
1198
  })
1199
+ it('should allow empty zones when campaign status is draft', async () => {
1200
+ project.campaigns[0].status = 'draft'
1201
+ project.campaigns[0].zones = []
1202
+ let Project = new ProjectModel(project)
1203
+ const res = await Project.validate()
1204
+ assert.notExists(res)
1205
+ })
1199
1206
  })
1200
1207
 
1201
1208
  describe('Invalid Campaigns', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "10.12.2",
3
+ "version": "10.12.3",
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",
@@ -22,7 +22,10 @@ let CampaignSchema = new mongoose.Schema({
22
22
  required: [true, 'campaign zones are required'],
23
23
  validate: {
24
24
  validator: function(zones) {
25
- return zones && zones.length > 0
25
+ if (this.status === 'active' || this.status === 'paused') {
26
+ return zones && zones.length > 0
27
+ }
28
+ return true
26
29
  },
27
30
  msg: 'campaign must have at least one zone'
28
31
  }