Repository: ambari Updated Branches: refs/heads/branch-1.7.0 4a83d3b11 -> ee70e1743
AMBARI-7861. Apps table contains two apps with equal names after app start. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ee70e174 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ee70e174 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ee70e174 Branch: refs/heads/branch-1.7.0 Commit: ee70e1743f812935090b22f206c062f58e696543 Parents: 4a83d3b Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Mon Oct 20 17:38:33 2014 +0300 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Mon Oct 20 20:50:41 2014 +0300 ---------------------------------------------------------------------- .../ui/app/mappers/slider_apps_mapper.js | 5 ++- .../unit/mappers/slider_apps_mapper_test.js | 32 +++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ee70e174/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js index 2d724eb..4718654 100644 --- a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js +++ b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js @@ -230,7 +230,7 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, { parse: function (data) { var apps = [], self = this, - appsToDelete = App.SliderApp.store.all('sliderApp').get('content').mapProperty('id'); + appsToDelete = App.SliderApp.store.all('sliderApp').mapBy('id'); App.__container__.lookup('controller:application').set('hasConfigErrors', false); @@ -277,9 +277,8 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, { }) ); - appsToDelete.splice(appsToDelete.indexOf(app.id), 1); + appsToDelete = appsToDelete.without(app.id); }); - appsToDelete.forEach(function (app) { var appRecord = App.SliderApp.store.getById('sliderApp', app); if (appRecord) { http://git-wip-us.apache.org/repos/asf/ambari/blob/ee70e174/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js b/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js index 8c02e71..012951f 100644 --- a/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js +++ b/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js @@ -28,7 +28,7 @@ QUnit.module('App.SliderAppsMapper', { }); -test('App.SliderAppsMapper.parseQuickLinks', function () { +test('parseQuickLinks', function () { var mapper = App.SliderAppsMapper; @@ -53,3 +53,33 @@ test('App.SliderAppsMapper.parseQuickLinks', function () { equal(mapper.get('result')[0].get('id'), 'YARN application 1', 'model id set correctly'); }); + +test('parse | add/remove apps', function () { + + Em.run(function () { + + App.SliderAppsMapper.parse({ + items: [ + {id: '1', type: 't1'}, + {id: '2', type: 't2'} + ] + }); + + }); + + deepEqual(App.SliderApp.store.all('sliderApp').mapBy('id'), ['1', '2'], 'Mapped all apps'); + + Em.run(function () { + + App.SliderAppsMapper.parse({ + items: [ + {id: '2', type: 't2'}, + {id: '3', type: 't3'} + ] + }); + + }); + + deepEqual(App.SliderApp.store.all('sliderApp').mapBy('id'), ['2', '3'], 'Delete not-existing app and add new'); + +}); \ No newline at end of file