AMBARI-20441. Alert Definition "Last Changed" field is shown incorrect if alert wan't triggered any time (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e2818c61 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e2818c61 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e2818c61 Branch: refs/heads/branch-feature-AMBARI-12556 Commit: e2818c61c15ec703e15581ca149c27bbfb7c1909 Parents: 645407b Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Tue Mar 14 11:32:45 2017 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Tue Mar 14 11:32:45 2017 +0200 ---------------------------------------------------------------------- ambari-web/app/models/alerts/alert_definition.js | 3 ++- .../main/service/configs/component_actions_by_configs_test.js | 2 +- ambari-web/test/models/alerts/alert_definition_test.js | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e2818c61/ambari-web/app/models/alerts/alert_definition.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/alerts/alert_definition.js b/ambari-web/app/models/alerts/alert_definition.js index b55ef1b..09089e6 100644 --- a/ambari-web/app/models/alerts/alert_definition.js +++ b/ambari-web/app/models/alerts/alert_definition.js @@ -100,7 +100,8 @@ App.AlertDefinition = DS.Model.extend({ * @type {string} */ lastTriggeredFormatted: function () { - return dateUtils.dateFormat(this.get('lastTriggered')); + let lastTriggered = this.get('lastTriggered'); + return lastTriggered ? dateUtils.dateFormat(lastTriggered) : ''; }.property('lastTriggered'), /** http://git-wip-us.apache.org/repos/asf/ambari/blob/e2818c61/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js b/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js index f987c52..9a73a9a 100644 --- a/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js +++ b/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js @@ -226,7 +226,7 @@ describe('App.ComponentActionsByConfigs', function () { name: 'common.batch.request_schedules', sender: mixin, data: { - intervalTimeSeconds: 1, + intervalTimeSeconds: 60, tolerateSize: 0, batches: [{}, {}] } http://git-wip-us.apache.org/repos/asf/ambari/blob/e2818c61/ambari-web/test/models/alerts/alert_definition_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/alerts/alert_definition_test.js b/ambari-web/test/models/alerts/alert_definition_test.js index 3d8b62d..26309ae 100644 --- a/ambari-web/test/models/alerts/alert_definition_test.js +++ b/ambari-web/test/models/alerts/alert_definition_test.js @@ -175,6 +175,13 @@ describe('App.AlertDefinition', function () { RECOVERY: 'glyphicon glyphicon-oil' }}); + describe('#lastTriggeredFormatted', function () { + it('should be empty', function () { + model.set('lastTriggered', 0); + expect(model.get('lastTriggeredFormatted')).to.be.equal(''); + }); + }); + describe('REOPEN', function () { describe('#getSortDefinitionsByStatus', function () {