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