Skip to content
Snippets Groups Projects
Commit dd9724e4 authored by Vasilli Iakliushin's avatar Vasilli Iakliushin Committed by John Skarbek
Browse files

Revert merge request approval groups behavior

Merge branch '14-8_fix_merge_request_approval_rules' into '14-8-stable-ee'

See merge request gitlab-org/security/gitlab!2334

Changelog: security
parent e44be54c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -142,15 +142,13 @@ export default {
.then((results) => ({ results }));
},
fetchGroups(term) {
const hasTerm = term.trim().length > 0;
const DEVELOPER_ACCESS_LEVEL = 30;
// Don't includeAll when search is empty. Otherwise, the user could get a lot of garbage choices.
// https://gitlab.com/gitlab-org/gitlab/issues/11566
const includeAll = term.trim().length > 0;
 
return Api.projectGroups(this.projectId, {
return Api.groups(term, {
skip_groups: this.skipGroupIds,
...(hasTerm ? { search: term } : {}),
with_shared: true,
shared_visible_only: !this.isFeatureEnabled,
shared_min_access_level: DEVELOPER_ACCESS_LEVEL,
all_available: includeAll,
});
},
fetchUsers(term) {
Loading
Loading
Loading
Loading
@@ -76,6 +76,7 @@ describe('Approvals ApproversSelect', () => {
};
 
beforeEach(() => {
jest.spyOn(Api, 'groups').mockResolvedValue(TEST_GROUPS);
jest.spyOn(Api, 'projectGroups').mockResolvedValue(TEST_GROUPS);
jest.spyOn(Api, 'projectUsers').mockReturnValue(Promise.resolve(TEST_USERS));
});
Loading
Loading
@@ -126,12 +127,9 @@ describe('Approvals ApproversSelect', () => {
});
 
it('fetches all available groups', () => {
expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, {
expect(Api.groups).toHaveBeenCalledWith(term, {
skip_groups: [],
search: term,
with_shared: true,
shared_visible_only: true,
shared_min_access_level: 30,
all_available: true,
});
});
 
Loading
Loading
@@ -153,7 +151,7 @@ describe('Approvals ApproversSelect', () => {
});
});
 
it('fetches all available groups including non-visible shared groups', async (done) => {
it('does not fetch all available', async (done) => {
waitForEvent($input, 'select2-loaded')
.then(jest.runOnlyPendingTimers)
.then(done)
Loading
Loading
@@ -161,11 +159,9 @@ describe('Approvals ApproversSelect', () => {
 
search();
 
expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, {
expect(Api.groups).toHaveBeenCalledWith('', {
skip_groups: [],
with_shared: true,
shared_visible_only: false,
shared_min_access_level: 30,
all_available: false,
});
});
});
Loading
Loading
@@ -191,11 +187,9 @@ describe('Approvals ApproversSelect', () => {
});
 
it('skips groups and does not fetch all available', () => {
expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, {
shared_min_access_level: 30,
shared_visible_only: true,
expect(Api.groups).toHaveBeenCalledWith('', {
skip_groups: skipGroupIds,
with_shared: true,
all_available: false,
});
});
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment