فهرست منبع

AMBARI-8444 Unable to close Add Host Wizard at step 2. (atkach)

Andrii Tkach 10 سال پیش
والد
کامیت
b4753afd17

+ 0 - 8
ambari-web/app/controllers/main/host/add_controller.js

@@ -78,14 +78,6 @@ App.AddHostController = App.WizardController.extend({
     return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
   },
 
-  /**
-   * return new object extended from installOptionsTemplate
-   * @return Object
-   */
-  getInstallOptions: function () {
-    return jQuery.extend({}, this.get('installOptionsTemplate'));
-  },
-
   /**
    * Remove host from model. Used at <code>Confirm hosts</code> step
    * @param hosts Array of hosts, which we want to delete

+ 3 - 3
ambari-web/app/controllers/wizard.js

@@ -281,7 +281,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * Remove all data for installOptions step
    */
   clearInstallOptions: function () {
-    var installOptions = this.get('getInstallOptions');
+    var installOptions = this.getInstallOptions();
     this.set('content.installOptions', installOptions);
     this.setDBProperty('installOptions', installOptions);
     this.set('content.hosts', {});
@@ -504,8 +504,8 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
   },
 
   getInstallOptions: function() {
-    return jQuery.extend({}, App.get('isHadoopWindowsStack')? this.get('installWindowsOptionsTemplate') : this.get('installOptionsTemplate'));
-  }.property('App.isHadoopWindowsStack'),
+    return jQuery.extend({}, App.get('isHadoopWindowsStack') ? this.get('installWindowsOptionsTemplate') : this.get('installOptionsTemplate'));
+  },
 
   installOptionsTemplate: {
     hostNames: "", //string

+ 0 - 9
ambari-web/test/controllers/main/host/add_controller_test.js

@@ -412,15 +412,6 @@ describe('App.AddHostController', function () {
     });
   });
 
-  describe("#getInstallOptions()", function () {
-    it("", function () {
-      controller.set('installOptionsTemplate', {'prop': 'installOptionsTemplate'});
-      expect(controller.getInstallOptions()).to.be.eql({
-        prop: 'installOptionsTemplate'
-      });
-    });
-  });
-
   describe("#loadServices", function () {
     var services = {
       db: null,

+ 62 - 0
ambari-web/test/controllers/wizard_test.js

@@ -97,4 +97,66 @@ describe('App.WizardController', function () {
     });
   });
 
+  describe('#getInstallOptions', function () {
+
+    var cases = [
+        {
+          isHadoopWindowsStack: true,
+          expected: {
+            useSsh: false
+          }
+        },
+        {
+          isHadoopWindowsStack: false,
+          expected: {
+            useSsh: true
+          }
+        }
+      ],
+      title = 'should return {0}';
+
+    beforeEach(function () {
+      sinon.stub(wizardController, 'get')
+        .withArgs('installOptionsTemplate').returns({useSsh: true})
+        .withArgs('installWindowsOptionsTemplate').returns({useSsh: false});
+    });
+
+    afterEach(function () {
+      App.get.restore();
+      wizardController.get.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(title.format(item.expected), function () {
+        sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
+        expect(wizardController.getInstallOptions()).to.eql(item.expected);
+      });
+    });
+
+  });
+
+  describe('#clearInstallOptions', function () {
+
+    wizardController.setProperties({
+      content: {},
+      name: 'wizard'
+    });
+
+    beforeEach(function () {
+      sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(false);
+    });
+
+    afterEach(function () {
+      App.get.restore();
+    });
+
+    it('should clear install options', function () {
+      wizardController.clearInstallOptions();
+      expect(wizardController.get('content.installOptions')).to.eql(wizardController.get('installOptionsTemplate'));
+      expect(wizardController.get('content.hosts')).to.eql({});
+      expect(wizardController.getDBProperty('installOptions')).to.eql(wizardController.get('installOptionsTemplate'))
+      expect(wizardController.getDBProperty('hosts')).to.eql({});
+    });
+  });
+
 });