Commit 65d20f6e authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett Committed by Jacob Schatz

Resolve "Can't activate approvals: The form contains the following error:...

Resolve "Can't activate approvals: The form contains the following error: Approver groups is invalid"
parent a1771826
......@@ -147,7 +147,7 @@ export default class ApproversSelect {
}
static saveApprovers(fieldName) {
const $input = $(`[name="${fieldName}"]`);
const $input = window.$(`[name="${fieldName}"]`);
const newValue = $input.val();
const $loadWrapper = $('.load-wrapper');
const $approverSelect = $('.js-select-user-and-group');
......@@ -158,7 +158,7 @@ export default class ApproversSelect {
const $form = $('.js-add-approvers').closest('form');
$loadWrapper.removeClass('hidden');
$.ajax({
window.$.ajax({
url: $form.attr('action'),
type: 'POST',
data: {
......@@ -167,7 +167,7 @@ export default class ApproversSelect {
},
success: ApproversSelect.updateApproverList,
complete() {
$input.val('val', '');
$input.val('');
$approverSelect.select2('val', '');
$loadWrapper.addClass('hidden');
},
......
import ApproversSelect from '~/approvers_select';
import ClassSpecHelper from './helpers/class_spec_helper';
describe('ApproversSelect', () => {
describe('saveApprovers', () => {
let complete;
const $input = jasmine.createSpyObj('$input', ['val']);
beforeEach(() => {
spyOn(window, '$').and.returnValue($input);
spyOn(window.$, 'ajax').and.callFake((options) => {
complete = options.complete;
});
$input.val.and.returnValue('newValue');
ApproversSelect.saveApprovers('fieldName');
});
ClassSpecHelper.itShouldBeAStaticMethod(ApproversSelect, 'saveApprovers');
describe('when request completes', () => {
it('should empty the $input value', () => {
$input.val.calls.reset();
complete();
expect($input.val).toHaveBeenCalledWith('');
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment