Repository: ambari Updated Branches: refs/heads/branch-2.0.0 e935d7523 -> a94303e60
AMBARI-10085. Alerts Badge is shown red but only Warning-alerts present (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a94303e6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a94303e6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a94303e6 Branch: refs/heads/branch-2.0.0 Commit: a94303e603cf6c7a6c007a24c6195246e6f9cbe3 Parents: e935d75 Author: Oleg Nechiporenko <[email protected]> Authored: Mon Mar 16 18:57:24 2015 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Mon Mar 16 19:17:47 2015 +0200 ---------------------------------------------------------------------- .../main/alert_definitions_controller.js | 2 +- .../main/alert_definitions_controller_test.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/a94303e6/ambari-web/app/controllers/main/alert_definitions_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alert_definitions_controller.js b/ambari-web/app/controllers/main/alert_definitions_controller.js index f345cb7..cf82e6c 100644 --- a/ambari-web/app/controllers/main/alert_definitions_controller.js +++ b/ambari-web/app/controllers/main/alert_definitions_controller.js @@ -131,7 +131,7 @@ App.MainAlertDefinitionsController = Em.ArrayController.extend({ * @type {Boolean} */ isCriticalAlerts: function () { - return !this.get('content').everyProperty('summary.CRITICAL.count', 0); + return this.get('content').invoke('getWithDefault', 'summary.CRITICAL.count', 0).reduce(Em.sum, 0) !== 0; }.property('[email protected]') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/a94303e6/ambari-web/test/controllers/main/alert_definitions_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alert_definitions_controller_test.js b/ambari-web/test/controllers/main/alert_definitions_controller_test.js index 03a4d80..7d696f8 100644 --- a/ambari-web/test/controllers/main/alert_definitions_controller_test.js +++ b/ambari-web/test/controllers/main/alert_definitions_controller_test.js @@ -53,4 +53,24 @@ describe('App.MainAlertDefinitionsController', function() { }); + describe('#isCriticalAlerts', function () { + + beforeEach(function () { + controller.set('content', Em.A([ + Em.Object.create({summary: {CRITICAL: {count: 0}}}), + Em.Object.create({summary: {CRITICAL: {}}}) + ])); + }); + + it('if summary is undefined, 0 should be used', function () { + expect(controller.get('isCriticalAlerts')).to.be.false; + }); + + it('should be true, if some CRITICAL count is greater than 0', function () { + controller.get('content').pushObject(Em.Object.create({summary: {CRITICAL: {count: 1}}})); + expect(controller.get('isCriticalAlerts')).to.be.true; + }); + + }); + });
