Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check dialog-user for info on valid inputs #3686

Merged
merged 3 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ManageIQ.angular.app.controller('dialogUserController', ['API', 'dialogFieldRefr
vm.submitButtonClicked = submitButtonClicked;
vm.cancelClicked = cancelClicked;
vm.saveable = saveable;
vm.isValid = false;

function refreshField(field) {
var idList = {
Expand All @@ -37,6 +38,7 @@ ManageIQ.angular.app.controller('dialogUserController', ['API', 'dialogFieldRefr
}

function setDialogData(data) {
vm.isValid = data.validations.isValid;
vm.dialogData = data.data;
}

Expand Down Expand Up @@ -69,6 +71,6 @@ ManageIQ.angular.app.controller('dialogUserController', ['API', 'dialogFieldRefr
}

function saveable() {
return ! dialogFieldRefreshService.areFieldsBeingRefreshed;
return vm.isValid && ! dialogFieldRefreshService.areFieldsBeingRefreshed;
}
}]);
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ describe('dialogUserController', function() {
it('sets the data attribute of the data passed in to dialogData', function() {
expect($controller.dialogData).toEqual(undefined);

$controller.setDialogData({data: 'newData'});
$controller.setDialogData({data: 'newData', validations: { isValid : true}});

expect($controller.dialogData).toEqual('newData');
});
});

describe('submitButtonClicked', function() {
beforeEach(function() {
$controller.setDialogData({data: {field1: 'field1'}});
$controller.setDialogData({data: {field1: 'field1'}, validations: { isValid : true}});
});

context('when the submit endpoint deals with generic objects', function() {
Expand All @@ -103,9 +103,10 @@ describe('dialogUserController', function() {
resourceActionId: '789',
targetId: '987',
targetType: 'targettype',
saveable: true,
});

$controller.setDialogData({data: {field1: 'field1'}});
$controller.setDialogData({data: {field1: 'field1'}, validations: { isValid : true}});

spyOn(API, 'post').and.returnValue(Promise.resolve('awesome'));
}));
Expand Down Expand Up @@ -206,16 +207,18 @@ describe('dialogUserController', function() {
context('when fields are being refreshed', function() {
beforeEach(function() {
dialogFieldRefreshService.areFieldsBeingRefreshed = true;
$controller.isValid = true;
});

it('returns false', function() {
expect($controller.saveable()).toBe(false);
});
});

context('when fields are not being refrshed', function() {
context('when fields are not being refreshed', function() {
beforeEach(function() {
dialogFieldRefreshService.areFieldsBeingRefreshed = false;
$controller.isValid = true;
});

it('returns true', function() {
Expand Down