Commit d9739651 authored by Fernando's avatar Fernando

Fix rspec failures

- Rework initRule logic to fix failing tests
parent a289e20d
...@@ -54,7 +54,7 @@ export default { ...@@ -54,7 +54,7 @@ export default {
}; };
// TODO: Remove feature flag in https://gitlab.com/gitlab-org/gitlab/-/issues/235114 // TODO: Remove feature flag in https://gitlab.com/gitlab-org/gitlab/-/issues/235114
if (this.glFeatures.approvalSuggestions) { if (this.glFeatures.approvalSuggestions) {
return { ...defaults, name: this.defaultRuleName || '' }; return { ...defaults, name: this.defaultRuleName || defaults.name };
} }
return defaults; return defaults;
...@@ -145,7 +145,7 @@ export default { ...@@ -145,7 +145,7 @@ export default {
); );
}, },
isPersisted() { isPersisted() {
return this.rule && this.rule.id; return this.initRule && this.initRule.id;
}, },
isNameVisible() { isNameVisible() {
return !this.settings.lockedApprovalsRuleName; return !this.settings.lockedApprovalsRuleName;
...@@ -164,7 +164,7 @@ export default { ...@@ -164,7 +164,7 @@ export default {
}, },
submissionData() { submissionData() {
return { return {
id: this.rule && this.rule.id, id: this.initRule && this.initRule.id,
name: this.settings.lockedApprovalsRuleName || this.name || DEFAULT_NAME, name: this.settings.lockedApprovalsRuleName || this.name || DEFAULT_NAME,
approvalsRequired: this.approvalsRequired, approvalsRequired: this.approvalsRequired,
users: this.userIds, users: this.userIds,
...@@ -247,7 +247,7 @@ export default { ...@@ -247,7 +247,7 @@ export default {
* Also delete the rule if necessary. * Also delete the rule if necessary.
*/ */
submitEmptySingleRule() { submitEmptySingleRule() {
const id = this.rule && this.rule.id; const id = this.initRule && this.initRule.id;
return Promise.all([this.submitFallback(), id ? this.deleteRule(id) : Promise.resolve()]); return Promise.all([this.submitFallback(), id ? this.deleteRule(id) : Promise.resolve()]);
}, },
...@@ -257,27 +257,27 @@ export default { ...@@ -257,27 +257,27 @@ export default {
return this.isValid; return this.isValid;
}, },
getInitialData() { getInitialData() {
if (!this.rule) { if (!this.initRule || this.defaultRuleName) {
return {}; return {};
} }
if (this.rule.isFallback) { if (this.initRule.isFallback) {
return { return {
approvalsRequired: this.rule.approvalsRequired, approvalsRequired: this.initRule.approvalsRequired,
isFallback: this.rule.isFallback, isFallback: this.initRule.isFallback,
}; };
} }
const { containsHiddenGroups = false, removeHiddenGroups = false } = this.rule; const { containsHiddenGroups = false, removeHiddenGroups = false } = this.initRule;
const users = this.rule.users.map(x => ({ ...x, type: TYPE_USER })); const users = this.initRule.users.map(x => ({ ...x, type: TYPE_USER }));
const groups = this.rule.groups.map(x => ({ ...x, type: TYPE_GROUP })); const groups = this.initRule.groups.map(x => ({ ...x, type: TYPE_GROUP }));
const branches = this.rule.protectedBranches?.map(x => x.id) || []; const branches = this.initRule.protectedBranches?.map(x => x.id) || [];
return { return {
name: this.rule.name || '', name: this.initRule.name || '',
approvalsRequired: this.rule.approvalsRequired || 0, approvalsRequired: this.initRule.approvalsRequired || 0,
minApprovalsRequired: this.rule.minApprovalsRequired || 0, minApprovalsRequired: this.initRule.minApprovalsRequired || 0,
containsHiddenGroups, containsHiddenGroups,
approvers: groups approvers: groups
.concat(users) .concat(users)
......
...@@ -105,12 +105,12 @@ module EE ...@@ -105,12 +105,12 @@ module EE
'security_approvals_help_page_path': help_page_path('user/application_security/index.md', anchor: 'security-approvals-in-merge-requests-ultimate'), 'security_approvals_help_page_path': help_page_path('user/application_security/index.md', anchor: 'security-approvals-in-merge-requests-ultimate'),
'security_configuration_path': project_security_configuration_path(project), 'security_configuration_path': project_security_configuration_path(project),
'vulnerability_check_help_page_path': help_page_path('user/application_security/index', anchor: 'enabling-security-approvals-within-a-project'), 'vulnerability_check_help_page_path': help_page_path('user/application_security/index', anchor: 'enabling-security-approvals-within-a-project'),
'license_check_help_page_path': help_page_path('user/application_security/index', anchor: 'enabling-license-approvals-within-a-project')} } 'license_check_help_page_path': help_page_path('user/application_security/index', anchor: 'enabling-license-approvals-within-a-project') } }
end end
def can_modify_approvers(project = @project) def can_modify_approvers(project = @project)
can?(current_user, :modify_approvers_rules, project) can?(current_user, :modify_approvers_rules, project)
end end
def permanent_delete_message(project) def permanent_delete_message(project)
message = _('This action will %{strongOpen}permanently delete%{strongClose} %{codeOpen}%{project}%{codeClose} %{strongOpen}immediately%{strongClose}, including its repositories and all content: issues, merge requests, etc.') message = _('This action will %{strongOpen}permanently delete%{strongClose} %{codeOpen}%{project}%{codeClose} %{strongOpen}immediately%{strongClose}, including its repositories and all content: issues, merge requests, etc.')
......
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