ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-18562 Cannot update repository on the UI. (atkach)
Date Mon, 10 Oct 2016 15:46:30 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 4b45e3c86 -> eeccd3a77


AMBARI-18562 Cannot update repository on the UI. (atkach)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/eeccd3a7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/eeccd3a7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/eeccd3a7

Branch: refs/heads/branch-2.5
Commit: eeccd3a777245de7be690d8f8e0e510582bcc680
Parents: 4b45e3c
Author: Andrii Tkach <atkach@apache.org>
Authored: Mon Oct 10 16:44:35 2016 +0300
Committer: Andrii Tkach <atkach@apache.org>
Committed: Mon Oct 10 18:43:45 2016 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  | 56 ++++++++++++--------
 .../admin/stack_and_upgrade_controller_test.js  | 45 +++++++++++-----
 2 files changed, 66 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eeccd3a7/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index 56a7a61..d00a652 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -1484,38 +1484,48 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
         if (os.get('isSelected')) {
           os.get('repositories').forEach(function (repo) {
             totalCalls++;
-            App.ajax.send({
-              name: 'admin.stack_versions.validate.repo',
-              sender: this,
-              data: {
-                repo: repo,
-                repoId: repo.get('repoId'),
-                baseUrl: repo.get('baseUrl'),
-                osType: os.get('osType'),
-                stackName: App.get('currentStackName'),
-                stackVersion: stackVersionNumber
-              }
+            this.validationCall(repo, os, stackVersionNumber)
+            .success(function () {
+              totalCalls--;
+              if (totalCalls === 0) deferred.resolve(invalidUrls);
             })
-              .success(function () {
-                totalCalls--;
-                if (totalCalls === 0) deferred.resolve(invalidUrls);
-              })
-              .error(function () {
-                repo.set('hasError', true);
-                invalidUrls.push(repo);
-                totalCalls--;
-                if (totalCalls === 0) deferred.resolve(invalidUrls);
-              });
-          });
+            .error(function () {
+              repo.set('hasError', true);
+              invalidUrls.push(repo);
+              totalCalls--;
+              if (totalCalls === 0) deferred.resolve(invalidUrls);
+            });
+          }, this);
         } else {
           return deferred.resolve(invalidUrls);
         }
-      });
+      }, this);
     }
     return deferred.promise();
   },
 
   /**
+   *
+   * @param {Em.Object} repo
+   * @param {Em.Object} os
+   * @param {string} stackVersionNumber
+   */
+  validationCall: function(repo, os, stackVersionNumber) {
+    return App.ajax.send({
+      name: 'admin.stack_versions.validate.repo',
+      sender: this,
+      data: {
+        repo: repo,
+        repoId: repo.get('repoId'),
+        baseUrl: repo.get('baseUrl'),
+        osType: os.get('osType'),
+        stackName: App.get('currentStackName'),
+        stackVersion: stackVersionNumber
+      }
+    })
+  },
+
+  /**
    * success callback for <code>installRepoVersion()<code>
    * saves request id to the db
    * @param data

http://git-wip-us.apache.org/repos/asf/ambari/blob/eeccd3a7/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index 12d0da3..be4a3b0 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -1404,24 +1404,45 @@ describe('App.MainAdminStackAndUpgradeController', function() {
 
   describe("#validateRepoVersions()", function () {
 
-    it("skip validation", function () {
+    beforeEach(function() {
+      sinon.stub(controller, 'validationCall').returns({
+        success: function() {
+          return {error: Em.K}
+        }
+      });
+      sinon.stub(controller, 'getStackVersionNumber').returns('v1')
+    });
+
+    afterEach(function() {
+      controller.validationCall.restore();
+      controller.getStackVersionNumber.restore();
+    });
+
+
+    it("validationCall should not be called", function () {
       controller.validateRepoVersions(Em.Object.create({repoVersionId: 1}), true);
-      var args = testHelpers.findAjaxRequest('name', 'admin.stack_versions.validate.repo');
-      expect(args).to.not.exists;
+      expect(controller.validationCall.called).to.be.false;
     });
-    it("do validation", function () {
+    it("validationCall should be called", function () {
+      var os = Em.Object.create({
+        isSelected: true,
+        repositories: [
+          Em.Object.create()
+        ]
+      });
       var repo = Em.Object.create({
         repoVersionId: 1,
-        operatingSystems: [
-          Em.Object.create({
-            isSelected: true,
-            repositories: [
-              Em.Object.create()
-            ]
-          })
-        ]
+        operatingSystems: [ os ]
       });
       controller.validateRepoVersions(repo, false);
+      expect(controller.validationCall.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#validationCall()", function () {
+
+    it("App.ajax.send should be called", function() {
+      controller.validationCall(Em.Object.create(), Em.Object.create(), 'v1');
       var args = testHelpers.findAjaxRequest('name', 'admin.stack_versions.validate.repo');
       expect(args[0]).to.exists;
     });


Mime
View raw message