You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jg...@apache.org on 2018/05/16 16:55:33 UTC

[ambari] branch branch-feature-AMBARI-14714 updated (2301672 -> ff435c3)

This is an automated email from the ASF dual-hosted git repository.

jgolieb pushed a change to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git.


    from 2301672  Captured upgrade states as constants for future use.
     new 369bf9e  Do not repeatedly add same mpack to registered mpacks list.
     new ff435c3  Do not repeatedly add same mpack to registered mpacks list.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../wizard/downloadMpacks_controller.js            | 19 ++++++++++------
 .../test/controllers/wizard/downloadMpacks_test.js | 26 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 9 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
jgolieb@apache.org.

[ambari] 02/02: Do not repeatedly add same mpack to registered mpacks list.

Posted by jg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jgolieb pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit ff435c3681c24213115e7cfa2915feb5e2df8f02
Author: Jason Golieb <jg...@hortonworks.com>
AuthorDate: Tue May 15 16:23:13 2018 -0700

    Do not repeatedly add same mpack to registered mpacks list.
---
 ambari-web/test/controllers/wizard/downloadMpacks_test.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ambari-web/test/controllers/wizard/downloadMpacks_test.js b/ambari-web/test/controllers/wizard/downloadMpacks_test.js
index 902e7c2..97fdd61 100644
--- a/ambari-web/test/controllers/wizard/downloadMpacks_test.js
+++ b/ambari-web/test/controllers/wizard/downloadMpacks_test.js
@@ -127,7 +127,7 @@ describe('App.WizardConfigureDownloadController', function () {
     });
   });
 
-  describe.only('#loadMpackInfo', function () {
+  describe('#loadMpackInfo', function () {
     it('Adds mpackInfo to registered mpacks list only once.', function () {
       controller.set('content.registeredMpacks', []);
       var mpackInfo = { MpackInfo: { id: 1 } };

-- 
To stop receiving notification emails like this one, please contact
jgolieb@apache.org.

[ambari] 01/02: Do not repeatedly add same mpack to registered mpacks list.

Posted by jg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jgolieb pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 369bf9e26d9b906926b39feedaa98435ab0fe9e5
Author: Jason Golieb <jg...@hortonworks.com>
AuthorDate: Tue May 15 16:23:13 2018 -0700

    Do not repeatedly add same mpack to registered mpacks list.
---
 .../wizard/downloadMpacks_controller.js            | 19 ++++++++++------
 .../test/controllers/wizard/downloadMpacks_test.js | 26 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/ambari-web/app/controllers/wizard/downloadMpacks_controller.js b/ambari-web/app/controllers/wizard/downloadMpacks_controller.js
index 5eb63d4..72a7bce 100644
--- a/ambari-web/app/controllers/wizard/downloadMpacks_controller.js
+++ b/ambari-web/app/controllers/wizard/downloadMpacks_controller.js
@@ -94,13 +94,18 @@ App.WizardDownloadMpacksController = App.WizardStepController.extend({
   },
 
   loadMpackInfo: function (data) {
-    App.ajax.send({
-      name: 'mpack.get_registered_mpack',
-      sender: this,
-      data: {
-        id: data.resources[0].MpackInfo.id
-      }
-    }).then(mpackInfo => this.get('content.registeredMpacks').push(mpackInfo));
+    const id = data.resources[0].MpackInfo.id;
+    const registeredMpacks = this.get('content.registeredMpacks');
+    
+    if (!registeredMpacks.find(mpack => mpack.MpackInfo.id === id)) {
+      App.ajax.send({
+        name: 'mpack.get_registered_mpack',
+        sender: this,
+        data: {
+          id: id
+        }
+      }).then(mpackInfo => registeredMpacks.push(mpackInfo));
+    }  
   },
 
   retryDownload: function (event) {
diff --git a/ambari-web/test/controllers/wizard/downloadMpacks_test.js b/ambari-web/test/controllers/wizard/downloadMpacks_test.js
index 0fcc9c4..902e7c2 100644
--- a/ambari-web/test/controllers/wizard/downloadMpacks_test.js
+++ b/ambari-web/test/controllers/wizard/downloadMpacks_test.js
@@ -37,6 +37,7 @@ describe('App.WizardConfigureDownloadController', function () {
     ];
 
     controller.set('mpacks', mpacks);
+    controller.set('content', {});
   })
 
   describe('#downloadMpackSuccess', function () {
@@ -107,7 +108,7 @@ describe('App.WizardConfigureDownloadController', function () {
       expect(controller.downloadMpack).to.be.called;
 
       controller.downloadMpack.restore();
-    })
+    });
   });
 
   describe('#showError', function () {
@@ -123,6 +124,27 @@ describe('App.WizardConfigureDownloadController', function () {
       expect(App.ModalPopup.show).to.be.called;
 
       App.ModalPopup.show.restore();
-    })
+    });
+  });
+
+  describe.only('#loadMpackInfo', function () {
+    it('Adds mpackInfo to registered mpacks list only once.', function () {
+      controller.set('content.registeredMpacks', []);
+      var mpackInfo = { MpackInfo: { id: 1 } };
+      var expected = [mpackInfo];
+      
+      App.ajax.send.restore();
+      sinon.stub(App.ajax, 'send').returns({
+        then: function () {
+          controller.get('content.registeredMpacks').push(mpackInfo);
+        }
+      });
+
+      controller.loadMpackInfo({ resources: [mpackInfo] });
+      expect(controller.get('content.registeredMpacks')).to.deep.equal(expected);
+
+      controller.loadMpackInfo({ resources: [mpackInfo] });
+      expect(controller.get('content.registeredMpacks').length).to.equal(1);
+    });
   });
 });
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
jgolieb@apache.org.