Commit 153266f2 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch...

Merge branch '2334-can-t-activate-approvals-the-form-contains-the-following-error-approver-groups-is-invalid' into 'master'

Resolve "Can't activate approvals: The form contains the following error: Approver groups is invalid"

Closes #2334

See merge request !1831
parents a1771826 65d20f6e
...@@ -147,7 +147,7 @@ export default class ApproversSelect { ...@@ -147,7 +147,7 @@ export default class ApproversSelect {
} }
static saveApprovers(fieldName) { static saveApprovers(fieldName) {
const $input = $(`[name="${fieldName}"]`); const $input = window.$(`[name="${fieldName}"]`);
const newValue = $input.val(); const newValue = $input.val();
const $loadWrapper = $('.load-wrapper'); const $loadWrapper = $('.load-wrapper');
const $approverSelect = $('.js-select-user-and-group'); const $approverSelect = $('.js-select-user-and-group');
...@@ -158,7 +158,7 @@ export default class ApproversSelect { ...@@ -158,7 +158,7 @@ export default class ApproversSelect {
const $form = $('.js-add-approvers').closest('form'); const $form = $('.js-add-approvers').closest('form');
$loadWrapper.removeClass('hidden'); $loadWrapper.removeClass('hidden');
$.ajax({ window.$.ajax({
url: $form.attr('action'), url: $form.attr('action'),
type: 'POST', type: 'POST',
data: { data: {
...@@ -167,7 +167,7 @@ export default class ApproversSelect { ...@@ -167,7 +167,7 @@ export default class ApproversSelect {
}, },
success: ApproversSelect.updateApproverList, success: ApproversSelect.updateApproverList,
complete() { complete() {
$input.val('val', ''); $input.val('');
$approverSelect.select2('val', ''); $approverSelect.select2('val', '');
$loadWrapper.addClass('hidden'); $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