From c4fa86505d8009e723253880c1addaa81d6e1cc3 Mon Sep 17 00:00:00 2001 From: lgalis Date: Wed, 13 Dec 2017 16:00:56 -0500 Subject: [PATCH] Fix spec for generic object custom button endpoints --- .../dialog_user/dialog_user_controller.spec.js | 15 ++++++++------- spec/services/dialog_local_service_spec.rb | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/javascripts/controllers/dialog_user/dialog_user_controller.spec.js b/spec/javascripts/controllers/dialog_user/dialog_user_controller.spec.js index f10b662a2337..3211cd12f786 100644 --- a/spec/javascripts/controllers/dialog_user/dialog_user_controller.spec.js +++ b/spec/javascripts/controllers/dialog_user/dialog_user_controller.spec.js @@ -16,6 +16,7 @@ describe('dialogUserController', function() { spyOn(dialogFieldRefreshService, 'refreshField'); spyOn(miqService, 'miqAjaxButton'); + spyOn(miqService, 'redirectBack'); spyOn(miqService, 'sparkleOn'); spyOn(miqService, 'sparkleOff'); @@ -90,15 +91,18 @@ describe('dialogUserController', function() { context('when the submit endpoint deals with generic objects', function() { beforeEach(inject(function(_$controller_) { - $controller = _$controller_('dialogUserController', { + $controller = _$controller_('dialogUserController', { API: API, dialogFieldRefreshService: dialogFieldRefreshService, miqService: miqService, dialogId: '1234', - apiSubmitEndpoint: 'generic_objects', + apiSubmitEndpoint: 'service/explorer', apiAction: 'custom_action', cancelEndpoint: 'cancel endpoint', finishSubmitEndpoint: 'finish submit endpoint', + resourceActionId: '789', + targetId: '987', + targetType: 'targettype', }); $controller.setDialogData({data: {field1: 'field1'}}); @@ -110,9 +114,8 @@ describe('dialogUserController', function() { $controller.submitButtonClicked(); setTimeout(function() { - expect(API.post).toHaveBeenCalledWith('generic_objects', { - action: 'custom_action', parameters: {field1: 'field1'} - }); + expect(API.post).toHaveBeenCalledWith('service/explorer', { + field1: 'field1', action: 'custom_action'}, {skipErrors: [400]}); done(); }); }); @@ -120,7 +123,6 @@ describe('dialogUserController', function() { context('when the API call succeeds', function() { beforeEach(function() { - spyOn(miqService, 'redirectBack'); spyOn(API, 'post').and.returnValue(Promise.resolve('awesome')); }); @@ -159,7 +161,6 @@ describe('dialogUserController', function() { context('when the API call fails', function() { beforeEach(function() { var rejectionData = {data: {error: {message: "Failed! -One,Two"}}}; - spyOn(miqService, 'redirectBack'); spyOn(API, 'post').and.returnValue(Promise.reject(rejectionData)); spyOn(window, 'clearFlash'); spyOn(window, 'add_flash'); diff --git a/spec/services/dialog_local_service_spec.rb b/spec/services/dialog_local_service_spec.rb index 25f1fccd9421..e9a11f6421d8 100644 --- a/spec/services/dialog_local_service_spec.rb +++ b/spec/services/dialog_local_service_spec.rb @@ -125,8 +125,8 @@ :force_old_dialog_use => false, :api_submit_endpoint => "/api/generic_objects/123", :api_action => "custom-button-name", - :finish_submit_endpoint => "/generic_object/show_list", - :cancel_endpoint => "/generic_object/show_list" + :finish_submit_endpoint => "/service/explorer", + :cancel_endpoint => "/service/explorer" ) end end