Commit 6a796439 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'fe-fix-min-approvals-required-for-new-mr-rule' into 'master'

Fix min approvals required for new MR rules

See merge request gitlab-org/gitlab-ee!14988
parents 9bb65490 e6201f72
......@@ -50,7 +50,7 @@ export default {
:disabled="!settings.canEdit"
class="form-control mw-6em"
type="number"
:min="rule.minApprovalsRequired"
:min="rule.minApprovalsRequired || 0"
@input="putRule({ id: rule.id, approvalsRequired: Number($event.target.value) })"
/>
</td>
......
---
title: Fix min approvals required for new MR rules
merge_request: 14988
author:
type: fixed
......@@ -16,8 +16,13 @@ localVue.use(Vuex);
describe('EE Approvals MRRules', () => {
let wrapper;
let store;
let approvalRules;
const factory = () => {
if (approvalRules) {
store.modules.approvals.state.rules = approvalRules;
}
wrapper = mount(localVue.extend(MRRules), {
localVue,
store: new Vuex.Store(store),
......@@ -47,6 +52,8 @@ describe('EE Approvals MRRules', () => {
afterEach(() => {
wrapper.destroy();
wrapper = null;
store = null;
approvalRules = null;
});
describe('when allow multiple rules', () => {
......@@ -64,7 +71,7 @@ describe('EE Approvals MRRules', () => {
const expected = createMRRuleWithSource();
beforeEach(() => {
store.modules.approvals.state.rules = [createMRRuleWithSource()];
approvalRules = [createMRRuleWithSource()];
factory();
});
......@@ -110,17 +117,32 @@ describe('EE Approvals MRRules', () => {
const expected = createMRRule();
beforeEach(() => {
store.modules.approvals.state.rules = [createMRRule()];
factory();
approvalRules = [createMRRule()];
});
it('shows controls', () => {
factory();
const controls = findRuleControls();
expect(controls.exists()).toBe(true);
expect(controls.props('rule')).toEqual(expected);
});
describe('without min approvals required', () => {
beforeEach(() => {
delete approvalRules[0].minApprovalsRequired;
});
it('defaults min approvals required input to 0', () => {
factory();
const input = findRuleApprovalsRequired();
expect(Number(input.attributes('min'))).toEqual(0);
});
});
describe('with settings cannot edit', () => {
beforeEach(() => {
store.state.settings.canEdit = false;
......@@ -155,7 +177,8 @@ describe('EE Approvals MRRules', () => {
describe('with source rule', () => {
beforeEach(() => {
store.modules.approvals.state.rules = [createMRRuleWithSource()];
approvalRules = [createMRRuleWithSource()];
factory();
});
......
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