瀏覽代碼

AMBARI-9890. Web Client Should Create Alert Target With 'overwriteExisting' Directive (onechiporenko)

Oleg Nechiporenko 10 年之前
父節點
當前提交
6f5d57e0cf

+ 1 - 0
ambari-web/app/controllers/wizard/step8_controller.js

@@ -1853,6 +1853,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
     this.addRequestToAjaxQueue({
       name: 'alerts.create_alert_notification',
       data: {
+        urlParams: 'overwriteExisting=true',
         data: apiObject
       }
     });

+ 1 - 1
ambari-web/app/utils/ajax/ajax.js

@@ -415,7 +415,7 @@ var urls = {
     'type': 'DELETE'
   },
   'alerts.create_alert_notification': {
-    'real': '/alert_targets',
+    'real': '/alert_targets?{urlParams}',
     'mock': '',
     'format': function (data) {
       return {

+ 6 - 5
ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js

@@ -24,11 +24,11 @@ describe('App.ManageAlertNotificationsController', function () {
 
   beforeEach(function () {
     controller = App.ManageAlertNotificationsController.create({});
-    sinon.stub(App.ajax, 'send');
+    sinon.stub($, 'ajax', Em.K);
   });
 
   afterEach(function () {
-    App.ajax.send.restore();
+    $.ajax.restore();
   });
 
   describe('#alertNotifications', function () {
@@ -572,7 +572,8 @@ describe('App.ManageAlertNotificationsController', function () {
     it("should send ajax request", function () {
 
       controller.createAlertNotification();
-      expect(App.ajax.send.calledOnce).to.be.true;
+      expect($.ajax.calledOnce).to.be.true;
+      expect($.ajax.args[0][0].url.contains('overwriteExisting=true')).to.be.false;
     });
 
   });
@@ -607,7 +608,7 @@ describe('App.ManageAlertNotificationsController', function () {
     it("should send ajax request", function () {
 
       controller.updateAlertNotification();
-      expect(App.ajax.send.calledOnce).to.be.true;
+      expect($.ajax.calledOnce).to.be.true;
     });
 
   });
@@ -653,7 +654,7 @@ describe('App.ManageAlertNotificationsController', function () {
 
       expect(App.showConfirmationPopup.calledOnce).to.be.true;
       popup.onPrimary();
-      expect(App.ajax.send.calledOnce).to.be.true;
+      expect($.ajax.calledOnce).to.be.true;
     });
 
   });

+ 7 - 5
ambari-web/test/controllers/wizard/step8_test.js

@@ -1369,10 +1369,8 @@ describe('App.WizardStep8Controller', function () {
     describe('#createNotification', function () {
 
       beforeEach(function () {
-        sinon.stub(App, 'get', function (k) {
-          if ('testMode' === k) return false;
-          return Em.get(App, k);
-        });
+        var stub = sinon.stub(App, 'get');
+        stub.withArgs('testMode').returns(false);
         installerStep8Controller.clearStep();
         installerStep8Controller.set('content', {controllerName: 'installerController'});
         installerStep8Controller.set('configs', [
@@ -1389,16 +1387,20 @@ describe('App.WizardStep8Controller', function () {
           {name: 'some_p', value: 'some_v', serviceName: 'MISC', filename: 'alert_notification'}
         ]);
         installerStep8Controller.get('ajaxRequestsQueue').clear();
+        sinon.stub($, 'ajax', function () {return {complete: Em.K}});
       });
 
       afterEach(function () {
         App.get.restore();
+        $.ajax.restore();
       });
 
       it('should add request to queue', function () {
         installerStep8Controller.createNotification();
         expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(1);
-
+        installerStep8Controller.get('ajaxRequestsQueue').runNextRequest();
+        expect($.ajax.calledOnce).to.be.true;
+        expect($.ajax.args[0][0].url.contains('overwriteExisting=true')).to.be.true;
       });
 
       it('sent data should be valid', function () {