diff --git a/uw-frame-components/portal/notifications/services.js b/uw-frame-components/portal/notifications/services.js index 5fede32c0..a2ca74646 100644 --- a/uw-frame-components/portal/notifications/services.js +++ b/uw-frame-components/portal/notifications/services.js @@ -129,15 +129,15 @@ define(['angular', 'jquery'], function(angular, $) { return; } var arrayFilter = angular.fromJson(notification.dataArrayFilter); - objectToFind = $filter('filter')(objectToFind, arrayFilter); - } - - //If the data object is there, we have a match - if (objectToFind && objectToFind.length > 0) { + if ($filter('filter')(objectToFind, arrayFilter).length > 0) { + return notification; + } + } else if (objectToFind) { return notification; - }else{ - return; - } + } + + return; + }).catch (function(reason){ $log.warn("Error retrieving data for notification"); } diff --git a/uw-frame-components/portal/notifications/spec/notification_services_spec.js b/uw-frame-components/portal/notifications/spec/notification_services_spec.js index 268916130..01eefcf30 100644 --- a/uw-frame-components/portal/notifications/spec/notification_services_spec.js +++ b/uw-frame-components/portal/notifications/spec/notification_services_spec.js @@ -510,5 +510,39 @@ define(['angular-mocks', 'portal'], function() { httpBackend.flush(); }); + it("notification should appear when dataObject is present and not an array", function(){ + //setup + httpBackend.whenGET(backendURL).respond( + {"notifications" : + [ + { + "id" : 1, + "groups" : ["Everyone"], + "title" : "Notification 1", + "actionURL" : "http://www.google.com", + "actionAlt" : "Google" + }, + { + "id" : 2, + "groups" : ["Everyone"], + "title" : "Notification 2", + "actionURL" : "http://www.google.com", + "actionAlt" : "Google", + "dataURL" : "http://www.google.com", + "dataObject" : "id" + } + ] + } + ); + httpBackend.whenGET(groupURL).respond({"groups" :[{"name" : "Everyone"}]}); + httpBackend.whenGET("http://www.google.com").respond(200, {"name":"foo" , "id":"bar" , "favorite food":"baz"}); + httpBackend.whenGET(kvURL + "/" + kvKeys.DISMISSED_NOTIFICATION_IDS).respond([]); + notificationsService.getFilteredNotifications().then(function(results){ + expect(results).toBeTruthy(); + expect(results.notDismissed.length).toEqual(2); + }); + httpBackend.flush(); + }); + }); });