Repository: ambari
Updated Branches:
  refs/heads/trunk 4d13432f1 -> 35b28f01e


http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/services/hdfs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/services/hdfs.js 
b/ambari-web/app/views/main/service/services/hdfs.js
index e95ea26..fca6457 100644
--- a/ambari-web/app/views/main/service/services/hdfs.js
+++ b/ambari-web/app/views/main/service/services/hdfs.js
@@ -19,6 +19,19 @@ var App = require('app');
 var date = require('utils/date/date');
 var numberUtils = require('utils/number_utils');
 
+function diskPart(i18nKey, totalKey, usedKey) {
+  return Em.computed(totalKey, usedKey, function () {
+    var text = Em.I18n.t(i18nKey);
+    var total = this.get(totalKey);
+    var used = this.get(usedKey);
+    var percent = total > 0 ? ((used * 100) / total).toFixed(2) : 0;
+    if (percent == "NaN" || percent < 0) {
+      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
+    }
+    return text.format(numberUtils.bytesToSize(used, 1, 'parseFloat'), 
numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
+  });
+}
+
 App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({
   templateName: require('templates/main/service/services/hdfs'),
   serviceName: 'HDFS',
@@ -81,25 +94,17 @@ App.MainDashboardServiceHdfsView = 
App.MainDashboardServiceView.extend({
 
   journalNodesTotal: Em.computed.alias('service.journalNodes.length'),
 
-  dfsTotalBlocks: function(){
-    return this.formatUnavailable(this.get('service.dfsTotalBlocks'));
-  }.property('service.dfsTotalBlocks'),
-  dfsTotalFiles: function(){
-    return this.formatUnavailable(this.get('service.dfsTotalFiles'));
-  }.property('service.dfsTotalFiles'),
-  dfsCorruptBlocks: function(){
-    return this.formatUnavailable(this.get('service.dfsCorruptBlocks'));
-  }.property('service.dfsCorruptBlocks'),
-  dfsMissingBlocks: function(){
-    return this.formatUnavailable(this.get('service.dfsMissingBlocks'));
-  }.property('service.dfsMissingBlocks'),
-  dfsUnderReplicatedBlocks: function(){
-    return 
this.formatUnavailable(this.get('service.dfsUnderReplicatedBlocks'));
-  }.property('service.dfsUnderReplicatedBlocks'),
-
-  blockErrorsMessage: function() {
-    return 
Em.I18n.t('dashboard.services.hdfs.blockErrors').format(this.get('dfsCorruptBlocks'),
 this.get('dfsMissingBlocks'), this.get('dfsUnderReplicatedBlocks'));
-  }.property('dfsCorruptBlocks','dfsMissingBlocks','dfsUnderReplicatedBlocks'),
+  dfsTotalBlocks: Em.computed.formatUnavailable('service.dfsTotalBlocks'),
+
+  dfsTotalFiles: Em.computed.formatUnavailable('service.dfsTotalFiles'),
+
+  dfsCorruptBlocks: Em.computed.formatUnavailable('service.dfsCorruptBlocks'),
+
+  dfsMissingBlocks: Em.computed.formatUnavailable('service.dfsMissingBlocks'),
+
+  dfsUnderReplicatedBlocks: 
Em.computed.formatUnavailable('service.dfsUnderReplicatedBlocks'),
+
+  blockErrorsMessage: 
Em.computed.i18nFormat('dashboard.services.hdfs.blockErrors', 
'dfsCorruptBlocks', 'dfsMissingBlocks', 'dfsUnderReplicatedBlocks'),
 
   nodeUptime: function () {
     var uptime = this.get('service').get('nameNodeStartTime');
@@ -118,62 +123,28 @@ App.MainDashboardServiceHdfsView = 
App.MainDashboardServiceView.extend({
     return "http://"; + (App.singleNodeInstall ? App.singleNodeAlias :  
this.get('service').get('nameNode').get('publicHostName')) + ":50070";
   }.property('service.nameNode'),
 
-  nodeHeap: function () {
-    var memUsed = this.get('service').get('jvmMemoryHeapUsed');
-    var memMax = this.get('service').get('jvmMemoryHeapMax');
-    var percent = memMax > 0 ? ((100 * memUsed) / memMax) : 0;
-    return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
-      numberUtils.bytesToSize(memUsed, 1, 'parseFloat'),
-      numberUtils.bytesToSize(memMax, 1, 'parseFloat'),
-      percent.toFixed(1));
-  }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapMax'),
-
-  dfsUsedDisk: function () {
-    var text = this.t("dashboard.services.hdfs.capacityUsed");
-    var total = this.get('service.capacityTotal');
-    var dfsUsed = this.get('service.capacityUsed');
-    var percent = total > 0 ? ((dfsUsed * 100) / total).toFixed(2) : 0;
-    if (percent == "NaN" || percent < 0) {
-      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
-    }
-    return text.format(numberUtils.bytesToSize(dfsUsed, 1, 'parseFloat'), 
numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
-  }.property('service.capacityUsed', 'service.capacityTotal'),
-  nonDfsUsedDisk: function () {
-    var text = this.t("dashboard.services.hdfs.capacityUsed");
+  nodeHeap: 
App.MainDashboardServiceView.formattedHeap('dashboard.services.hdfs.nodes.heapUsed',
 'service.jvmMemoryHeapUsed', 'service,jvmMemoryHeapMax'),
+
+  dfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 
'service.capacityTotal', 'service.capacityUsed'),
+
+  nonDfsUsed: function () {
     var total = this.get('service.capacityTotal');
     var remaining = this.get('service.capacityRemaining');
     var dfsUsed = this.get('service.capacityUsed');
-    var nonDfsUsed = total !== null && remaining !== null && dfsUsed !== null 
? total - remaining - dfsUsed : null;
-    var percent = total > 0 ? ((nonDfsUsed * 100) / total).toFixed(2) : 0;
-    if (percent == "NaN" || percent < 0) {
-      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
-    }
-    return text.format(numberUtils.bytesToSize(nonDfsUsed, 1, 'parseFloat'), 
numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
-  }.property('service.capacityUsed', 'service.capacityRemaining', 
'service.capacityTotal'),
-  remainingDisk: function () {
-    var text = this.t("dashboard.services.hdfs.capacityUsed");
-    var total = this.get('service.capacityTotal');
-    var remaining = this.get('service.capacityRemaining');
-    var percent = total > 0 ? ((remaining * 100) / total).toFixed(2) : 0;
-    if (percent == "NaN" || percent < 0) {
-      percent = Em.I18n.t('services.service.summary.notAvailable') + " ";
-    }
-    return text.format(numberUtils.bytesToSize(remaining, 1, 'parseFloat'), 
numberUtils.bytesToSize(total, 1, 'parseFloat'), percent);
-  }.property('service.capacityRemaining', 'service.capacityTotal'),
-
-  dataNodeComponent: function () {
-    return Em.Object.create({
-      componentName: 'DATANODE'
-    });
-    //return this.get('service.dataNodes').objectAt(0);
-  }.property(),
+    return total !== null && remaining !== null && dfsUsed !== null ? total - 
remaining - dfsUsed : null;
+  }.property('service.capacityTotal', 'service.capacityRemaining', 
'service.capacityUsed'),
 
-  nfsGatewayComponent: function () {
-    return Em.Object.create({
-      componentName: 'NFS_GATEWAY'
-    });
-    //return this.get('service.dataNodes').objectAt(0);
-  }.property(),
+  nonDfsUsedDisk: diskPart('dashboard.services.hdfs.capacityUsed', 
'service.capacityTotal', 'nonDfsUsed'),
+
+  remainingDisk: diskPart('dashboard.services.hdfs.capacityUsed', 
'service.capacityTotal', 'service.capacityRemaining'),
+
+  dataNodeComponent: Em.Object.create({
+    componentName: 'DATANODE'
+  }),
+
+  nfsGatewayComponent: Em.Object.create({
+    componentName: 'NFS_GATEWAY'
+  }),
 
   /**
    * Define if NFS_GATEWAY is present in the installed stack

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/services/yarn.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/services/yarn.js 
b/ambari-web/app/views/main/service/services/yarn.js
index 66665c0..d4299ff 100644
--- a/ambari-web/app/views/main/service/services/yarn.js
+++ b/ambari-web/app/views/main/service/services/yarn.js
@@ -23,36 +23,15 @@ App.MainDashboardServiceYARNView = 
App.MainDashboardServiceView.extend({
   templateName: require('templates/main/service/services/yarn'),
   serviceName: 'YARN',
 
-  nodeHeap: function () {
-    var memUsed = this.get('service').get('jvmMemoryHeapUsed');
-    var memMax = this.get('service').get('jvmMemoryHeapMax');
-    var percent = memMax > 0 ? ((100 * memUsed) / memMax) : 0;
-    return this.t('dashboard.services.hdfs.nodes.heapUsed').format(
-      numberUtils.bytesToSize(memUsed, 1, 'parseFloat'),
-      numberUtils.bytesToSize(memMax, 1, 'parseFloat'),
-      percent.toFixed(1));
-  }.property('service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapMax'),
-
-  summaryHeader: function () {
-    var text = this.t("dashboard.services.yarn.summary");
-    var totalCount = this.get('service.nodeManagersTotal');
-    var liveCount = this.get('service.nodeManagersStarted');
-    return text.format(liveCount, totalCount);
-  }.property('service.nodeManagersStarted', 'service.nodeManagersTotal'),
+  nodeHeap: 
App.MainDashboardServiceView.formattedHeap('dashboard.services.yarn.summary', 
'service.jvmMemoryHeapUsed', 'service.jvmMemoryHeapMax'),
   
-  nodeManagerComponent: function () {
-    return Em.Object.create({
-      componentName: 'NODEMANAGER'
-    });
-    //return this.get('service.nodeManagerNodes').objectAt(0);
-  }.property(),
+  nodeManagerComponent: Em.Object.create({
+    componentName: 'NODEMANAGER'
+  }),
   
-  yarnClientComponent: function () {
-    return Em.Object.create({
-      componentName: 'YARN_CLIENT'
-    });
-    //return this.get('service.hostComponents').findProperty('componentName', 
'YARN_CLIENT');
-  }.property(),
+  yarnClientComponent: Em.Object.create({
+    componentName: 'YARN_CLIENT'
+  }),
 
   hasManyYarnClients: Em.computed.gt('service.installedClients', 1),
 
@@ -69,58 +48,27 @@ App.MainDashboardServiceYARNView = 
App.MainDashboardServiceView.extend({
     return this.t('services.service.summary.notRunning');
   }.property("service.resourceManagerStartTime"),
 
-  nodeManagerText: function () {
-    if (this.get("service.nodeManagersTotal") === 0) {
-      return '';
-    } else if (this.get("service.nodeManagersTotal") > 1) {
-      return Em.I18n.t('services.service.summary.viewHosts');
-    } else {
-      return Em.I18n.t('services.service.summary.viewHost');
-    }
-  }.property("service.nodeManagersTotal"),
+  nodeManagerText: Em.computed.countBasedMessage('service.nodeManagersTotal', 
'', Em.I18n.t('services.service.summary.viewHost'), 
Em.I18n.t('services.service.summary.viewHosts')),
 
-  nodeManagersStatus: function () {
-    var nmActive = this.get('service.nodeManagersCountActive');
-    var nmLost = this.get('service.nodeManagersCountLost');
-    var nmUnhealthy = this.get('service.nodeManagersCountUnhealthy');
-    var nmRebooted = this.get('service.nodeManagersCountRebooted');
-    var nmDecom = this.get('service.nodeManagersCountDecommissioned');
-    return this.t('dashboard.services.yarn.nodeManagers.status.msg').format(
-      this.formatUnavailable(nmActive),
-      this.formatUnavailable(nmLost),
-      this.formatUnavailable(nmUnhealthy),
-      this.formatUnavailable(nmRebooted),
-      this.formatUnavailable(nmDecom)
-    );
-  }.property('service.nodeManagersCountActive', 
'service.nodeManagersCountLost', 
-      'service.nodeManagersCountUnhealthy', 
'service.nodeManagersCountRebooted', 'service.nodeManagersCountDecommissioned'),
+  _nmActive: Em.computed.formatUnavailable('service.nodeManagersCountActive'),
+  _nmLost: Em.computed.formatUnavailable('service.nodeManagersCountLost'),
+  _nmUnhealthy: 
Em.computed.formatUnavailable('service.nodeManagersCountUnhealthy'),
+  _nmRebooted: 
Em.computed.formatUnavailable('service.nodeManagersCountRebooted'),
+  _nmDecom: 
Em.computed.formatUnavailable('service.nodeManagersCountDecommissioned'),
+  nodeManagersStatus: 
Em.computed.i18nFormat('dashboard.services.yarn.nodeManagers.status.msg', 
'_nmActive', '_nmLost', '_nmUnhealthy', '_nmRebooted', '_nmDecom'),
 
-  containers: function () {
-    var allocated = this.get('service.containersAllocated');
-    var pending = this.get('service.containersPending');
-    var reserved = this.get('service.containersReserved');
-    return this.t('dashboard.services.yarn.containers.msg').format(
-      this.formatUnavailable(allocated),
-      this.formatUnavailable(pending),
-      this.formatUnavailable(reserved)
-    );
-  }.property('service.containersAllocated', 'service.containersPending', 
'service.containersReserved'),
+  _allocated: Em.computed.formatUnavailable('service.containersAllocated'),
+  _pending: Em.computed.formatUnavailable('service.containersPending'),
+  _reserved: Em.computed.formatUnavailable('service.containersReserved'),
+  containers: Em.computed.i18nFormat('dashboard.services.yarn.containers.msg', 
'_allocated', '_pending', '_reserved'),
 
-  apps: function () {
-    var appsSubmitted = this.get('service.appsSubmitted');
-    var appsRunning = this.get('service.appsRunning');
-    var appsPending = this.get('service.appsPending');
-    var appsCompleted = this.get('service.appsCompleted');
-    var appsKilled = this.get('service.appsKilled');
-    var appsFailed = this.get('service.appsFailed');
-    return this.t('dashboard.services.yarn.apps.msg').format(
-      this.formatUnavailable(appsSubmitted),
-      this.formatUnavailable(appsRunning),
-      this.formatUnavailable(appsPending),
-      this.formatUnavailable(appsCompleted),
-      this.formatUnavailable(appsKilled),
-      this.formatUnavailable(appsFailed));
-  }.property('service.appsSubmitted', 'service.appsRunning', 
'service.appsPending', 'service.appsCompleted', 'service.appsKilled', 
'service.appsFailed'),
+  _appsSubmitted: Em.computed.formatUnavailable('service.appsSubmitted'),
+  _appsRunning: Em.computed.formatUnavailable('service.appsRunning'),
+  _appsPending: Em.computed.formatUnavailable('service.appsPending'),
+  _appsCompleted: Em.computed.formatUnavailable('service.appsCompleted'),
+  _appsKilled: Em.computed.formatUnavailable('service.appsKilled'),
+  _appsFailed: Em.computed.formatUnavailable('service.appsFailed'),
+  apps: Em.computed.i18nFormat('dashboard.services.yarn.apps.msg', 
'_appsSubmitted', '_appsRunning', '_appsPending', '_appsCompleted', 
'_appsKilled', '_appsFailed'),
 
   memory: function () {
     return Em.I18n.t('dashboard.services.yarn.memory.msg').format(
@@ -129,9 +77,8 @@ App.MainDashboardServiceYARNView = 
App.MainDashboardServiceView.extend({
         numberUtils.bytesToSize(this.get('service.availableMemory'), 1, 
'parseFloat', 1024 * 1024));
   }.property('service.allocatedMemory', 'service.reservedMemory', 
'service.availableMemory'),
 
-  queues: function() {
-    return 
Em.I18n.t('dashboard.services.yarn.queues.msg').format(this.formatUnavailable(this.get('service.queuesCount')));
-  }.property('service.queuesCount'),
+  _queuesCountFormatted: Em.computed.formatUnavailable('service.queuesCount'),
+  queues: Em.computed.i18nFormat('dashboard.services.yarn.queues.msg', 
'_queuesCountFormatted'),
 
   didInsertElement: function(){
     App.tooltip($("[rel='queue-tooltip']"), {html: true, placement: "right"});

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/main/service/widgets/create/expression_view.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/views/main/service/widgets/create/expression_view.js 
b/ambari-web/app/views/main/service/widgets/create/expression_view.js
index e6dd2ad..0ec7278 100644
--- a/ambari-web/app/views/main/service/widgets/create/expression_view.js
+++ b/ambari-web/app/views/main/service/widgets/create/expression_view.js
@@ -202,10 +202,7 @@ App.AddNumberExpressionView = Em.TextField.extend({
 App.AddMetricExpressionView = Em.View.extend({
   templateName: 
require('templates/main/service/widgets/create/step2_add_metric'),
   controller: Em.computed.alias('parentView.controller'),
-  elementId: function () {
-    var expressionId = "_" + this.get('parentView').get('expression.id');
-    return 'add-metric-menu' + expressionId;
-  }.property(),
+  elementId: 
Em.computed.format('add-metric-menu_{0}','parentView.expression.id'),
   didInsertElement: function () {
     //prevent dropdown closing on click select
     $('html').on('click.dropdown', '.dropdown-menu li', function (e) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/wizard/step3/hostWarningPopupFooter_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step3/hostWarningPopupFooter_view.js 
b/ambari-web/app/views/wizard/step3/hostWarningPopupFooter_view.js
index cc15313..b309a5e 100644
--- a/ambari-web/app/views/wizard/step3/hostWarningPopupFooter_view.js
+++ b/ambari-web/app/views/wizard/step3/hostWarningPopupFooter_view.js
@@ -26,9 +26,7 @@ App.WizardStep3HostWarningPopupFooter = Em.View.extend({
 
   footerControllerBinding: 'App.router.wizardStep3Controller',
 
-  progressWidth: function () {
-    return 'width:' + this.get('footerController.checksUpdateProgress') + '%';
-  }.property('footerController.checksUpdateProgress'),
+  progressWidth: Em.computed.format('width:{0}%', 
'footerController.checksUpdateProgress'),
 
   isUpdateInProgress: function () {
     return (this.get('footerController.checksUpdateProgress') > 0) &&

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/wizard/step3_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step3_view.js 
b/ambari-web/app/views/wizard/step3_view.js
index d107357..0aa5460 100644
--- a/ambari-web/app/views/wizard/step3_view.js
+++ b/ambari-web/app/views/wizard/step3_view.js
@@ -80,9 +80,7 @@ App.WizardStep3View = App.TableView.extend({
    */
   categoryObject: Em.Object.extend({
     hostsCount: 0,
-    label: function () {
-      return "%@ (%@)".fmt(this.get('value'), this.get('hostsCount'));
-    }.property('value', 'hostsCount'),
+    label: Em.computed.format('{0} ({1})', 'value', 'hostsCount'),
     isActive: false,
     itemClass: Em.computed.ifThenElse('isActive', 'active', '')
   }),

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/app/views/wizard/step9_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step9_view.js 
b/ambari-web/app/views/wizard/step9_view.js
index 3a11f33..e58186b 100644
--- a/ambari-web/app/views/wizard/step9_view.js
+++ b/ambari-web/app/views/wizard/step9_view.js
@@ -80,9 +80,7 @@ App.WizardStep9View = App.TableView.extend({
    */
   categoryObject: Em.Object.extend({
     hostsCount: 0,
-    label: function () {
-      return "%@ (%@)".fmt(this.get('value'), this.get('hostsCount'));
-    }.property('value', 'hostsCount'),
+    label: Em.computed.format('{0} ({1})', 'value', 'hostsCount'),
     isActive: false,
     itemClass: Em.computed.ifThenElse('isActive', 'active', '')
   }),
@@ -111,10 +109,7 @@ App.WizardStep9View = App.TableView.extend({
    * Css-string to overall progress-bar width-property
    * @type {string}
    */
-  barWidth: function () {
-    var controller = this.get('controller');
-    return 'width: ' + controller.get('progress') + '%;';
-  }.property('controller.progress'),
+  barWidth: Em.computed.format('width: {0}%;', 'controller.progress'),
 
   /**
    * Filter hosts info shown up on bottom of the box. Set by filter function, 
when 'seletedCategory' changed
@@ -287,6 +282,13 @@ App.WizardStep9View = App.TableView.extend({
 
 });
 
+function hostStatus(statuses) {
+  return Em.computed('isHostCompleted', 'obj.status', function () {
+    statuses = Em.makeArray(statuses);
+    return this.get('isHostCompleted') && 
statuses.contains(this.get('obj.status'));
+  });
+}
+
 App.HostStatusView = Em.View.extend({
 
   tagName: 'tr',
@@ -313,33 +315,25 @@ App.HostStatusView = Em.View.extend({
    * Css-string to progress-bar width-property
    * @type {string}
    */
-  barWidth: function () {
-    return 'width: ' + this.get('obj.progress') + '%;';
-  }.property('obj.progress'),
+  barWidth: Em.computed.format('width: {0}%;','obj.progress'),
 
   /**
    * Is current host failed
    * @type {bool}
    */
-  isFailed: function () {
-    return (this.get('isHostCompleted') && (this.get('obj.status') === 
'failed' || this.get('obj.status') === 'heartbeat_lost'));
-  }.property('obj.status', 'isHostCompleted'),
+  isFailed: hostStatus(['failed', 'heartbeat_lost']),
 
   /**
    * Is current host successfully installed
    * @type {bool}
    */
-  isSuccess: function () {
-    return (this.get('isHostCompleted') && this.get('obj.status') === 
'success');
-  }.property('obj.status', 'isHostCompleted'),
+  isSuccess: hostStatus('success'),
 
   /**
    * Current host has warnings
    * @type {bool}
    */
-  isWarning: function () {
-    return(this.get('isHostCompleted') && this.get('obj.status') === 
'warning');
-  }.property('obj.status', 'isHostCompleted'),
+  isWarning: hostStatus('warning'),
 
   /**
    * Current host completed all its tasks

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/test/controllers/application_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/application_test.js 
b/ambari-web/test/controllers/application_test.js
index 203fff0..dbe5a96 100644
--- a/ambari-web/test/controllers/application_test.js
+++ b/ambari-web/test/controllers/application_test.js
@@ -56,8 +56,6 @@ describe('App.ApplicationController', function () {
     });
   });
 
-
-
   describe('#startKeepAlivePoller', function() {
     it ('Should change run poller state', function() {
       applicationController.set('isPollerRunning', false);
@@ -120,13 +118,15 @@ describe('App.ApplicationController', function () {
 
   describe('#isClusterDataLoaded', function() {
     beforeEach(function () {
-      sinon.stub(App.router, 'get').returns('cl1');
+      var stub = sinon.stub(App, 'get');
+      stub.withArgs('router.clusterController.isLoaded').returns(true);
+      stub.withArgs('router.loggedIn').returns(true);
     });
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it ('Should return true, when data loaded', function() {
-      
expect(applicationController.get('isClusterDataLoaded')).to.be.equal('cl1');
+      expect(applicationController.get('isClusterDataLoaded')).to.be.true;
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/test/controllers/main/service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service_test.js 
b/ambari-web/test/controllers/main/service_test.js
index f51c7eb..2cbaf29 100644
--- a/ambari-web/test/controllers/main/service_test.js
+++ b/ambari-web/test/controllers/main/service_test.js
@@ -106,15 +106,11 @@ describe('App.MainServiceController', function () {
   describe('#isStartStopAllClicked', function () {
 
     beforeEach(function () {
-      sinon.stub(App.router, 'get', function () {
-        return Em.Object.create({
-          allOperationsCount: 1
-        });
-      });
+      sinon.stub(App, 
'get').withArgs('router.backgroundOperationsController.allOperationsCount').returns(1);
     });
 
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
 
     it('should be based on BG ops count', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/test/controllers/main_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main_test.js 
b/ambari-web/test/controllers/main_test.js
index 03f8e47..4a7d606 100644
--- a/ambari-web/test/controllers/main_test.js
+++ b/ambari-web/test/controllers/main_test.js
@@ -70,10 +70,10 @@ describe('App.MainController', function () {
 
   describe('#clusterDataLoadedPercent', function() {
     beforeEach(function () {
-      sinon.stub(App.router, 'get').returns(16);
+      sinon.stub(App, 
'get').withArgs('router.clusterController.clusterDataLoadedPercent').returns(16);
     });
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it ('Should return 16', function() {
       expect(mainController.get('clusterDataLoadedPercent')).to.be.equal(16);

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/test/models/user_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/user_test.js 
b/ambari-web/test/models/user_test.js
index 77598b1..607f4dd 100644
--- a/ambari-web/test/models/user_test.js
+++ b/ambari-web/test/models/user_test.js
@@ -26,11 +26,7 @@ var user,
   userNameField,
   userData = {
     id: 'user'
-  },
-  objectData = Em.Object.create({
-    userName: 'name',
-    isLdap: true
-  });
+  };
 
 describe('App.User', function () {
 
@@ -61,104 +57,6 @@ describe('App.User', function () {
   });
 });
 
-describe('App.EditUserForm', function () {
-
-  beforeEach(function () {
-    form = App.EditUserForm.create();
-  });
-
-  describe('#object', function () {
-
-    before(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserEditController.content') return userData;
-        return Em.get(App.router, k);
-      });
-    });
-
-    after(function () {
-      App.router.get.restore();
-    });
-
-    it('should take data from controller', function () {
-      expect(form.get('object')).to.eql(userData);
-    });
-
-  });
-
-  describe('#disableUsername', function () {
-    it('should update userName field', function () {
-      form.set('object', userData);
-      expect(form.get('field.userName.disabled')).to.equal('disabled');
-    });
-  });
-
-  describe('#disableAdminCheckbox', function () {
-
-    before(function () {
-      sinon.stub(App, 'get', function(k) {
-        switch (k) {
-          case 'router':
-            return {
-              getLoginName: Em.K
-            };
-          default:
-            return Em.get(App, k);
-        }
-      });
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserEditController.content') return objectData;
-        return Em.get(App.router, k);
-      });
-    });
-
-    after(function () {
-      App.get.restore();
-      App.router.get.restore();
-    });
-
-    it('should not disable', function () {
-      expect(form.get('field.admin.disabled')).to.be.false;
-    });
-
-    it('should disable', function () {
-      form.set('object', objectData);
-      expect(form.get('field.admin.disabled')).to.be.false;
-    });
-  });
-
-  describe('#isValid', function () {
-    it('should be true as default', function () {
-      expect(form.isValid()).to.be.true;
-    });
-    it('should be false', function () {
-      form.set('field.new_password.isRequired', true);
-      expect(form.isValid()).to.be.false;
-    });
-  });
-
-  describe('#save', function () {
-
-    before(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserEditController.content') return objectData;
-        return Em.get(App.router, k);
-      });
-    });
-
-    after(function () {
-      App.router.get.restore();
-    });
-
-    it('should record form values to object', function () {
-      form.set('field.userName.value', 'name');
-      form.save();
-      expect(form.get('object.userName')).to.equal('name');
-    });
-  });
-
-});
-
 describe('App.CreateUserForm', function () {
 
   beforeEach(function () {
@@ -168,14 +66,11 @@ describe('App.CreateUserForm', function () {
   describe('#object', function () {
 
     before(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if (k === 'mainAdminUserCreateController.content') return userData;
-        return Em.get(App, k);
-      });
+      sinon.stub(App, 
'get').withArgs('router.mainAdminUserCreateController.content').returns(userData);
     });
 
     after(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
 
     it('should take data from controller', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/35b28f01/ambari-web/test/views/main/dashboard/widgets_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js 
b/ambari-web/test/views/main/dashboard/widgets_test.js
index b0e2f14..558dbe3 100644
--- a/ambari-web/test/views/main/dashboard/widgets_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets_test.js
@@ -129,13 +129,10 @@ describe('App.MainDashboardWidgetsView', function () {
 
   describe('#persistKey', function () {
     beforeEach(function () {
-      sinon.stub(App.router, 'get', function (k) {
-        if ('loginName' === k) return 'tdk';
-        return Em.get(App.router, k);
-      });
+      sinon.stub(App, 'get').withArgs('router.loginName').returns('tdk');
     });
     afterEach(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it('Check it', function () {
       expect(view.get('persistKey')).to.equal('user-pref-tdk-dashboard');
@@ -402,10 +399,10 @@ describe('App.MainDashboardWidgetsView', function () {
 
   describe("#persistKey", function () {
     before(function () {
-      sinon.stub(App.router, 'get').withArgs('loginName').returns('user');
+      sinon.stub(App, 'get').withArgs('router.loginName').returns('user');
     });
     after(function () {
-      App.router.get.restore();
+      App.get.restore();
     });
     it("", function () {
       view.propertyDidChange('persistKey');

Reply via email to