diff --git a/services/notifications/app/coffee/Notifications.coffee b/services/notifications/app/coffee/Notifications.coffee index 3c7bcd70c8..f67605617f 100644 --- a/services/notifications/app/coffee/Notifications.coffee +++ b/services/notifications/app/coffee/Notifications.coffee @@ -20,10 +20,10 @@ module.exports = user_id: ObjectId(user_id) key: notification.key db.notifications.count query, (err, number)-> - if number > 0 and !notification.override + if number > 0 and !notification.forceCreate logger.log number:number, user_id:user_id, key:notification.key, "alredy has notification key for user" return callback(number) - else if number > 0 and notification.override + else if number > 0 and notification.forceCreate self.removeNotificationKey user_id, notification.key, callback else callback() diff --git a/services/notifications/test/unit/coffee/NotificationsTests.coffee b/services/notifications/test/unit/coffee/NotificationsTests.coffee index d1c9c6d8e1..74351b0d9e 100644 --- a/services/notifications/test/unit/coffee/NotificationsTests.coffee +++ b/services/notifications/test/unit/coffee/NotificationsTests.coffee @@ -77,12 +77,12 @@ describe 'Notifications Tests', -> @insertStub.calledWith(@expectedDocument).should.equal false done() - describe "when key already exists but override is passed", (done)-> + describe "when key already exists but forceCreate is passed", (done)-> it "should delete the old key and insert the new one", -> @insertStub.callsArgWith(1, null) @countStub.callsArgWith(1, null, 1) - @stubbedNotification.override = true + @stubbedNotification.forceCreate = true @notifications.addNotification user_id, @stubbedNotification, (err)=> assert.deepEqual(@insertStub.lastCall.args[0], @expectedDocument) @notifications.removeNotificationKey.calledWith(user_id, @stubbedNotification.key).should.equal true