Commit b06d5b96 authored by Rémy Coutable's avatar Rémy Coutable

Return only group's members in user dropdowns on issuables list pages

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent cbdd13f6
......@@ -15,6 +15,7 @@ class DropdownUser extends gl.FilteredSearchDropdown {
params: {
per_page: 20,
active: true,
group_id: this.getGroupId(),
project_id: this.getProjectId(),
current_user: true,
},
......@@ -47,6 +48,10 @@ class DropdownUser extends gl.FilteredSearchDropdown {
super.renderContent(forceShowList);
}
getGroupId() {
return this.input.getAttribute('data-group-id');
}
getProjectId() {
return this.input.getAttribute('data-project-id');
}
......
---
title: Return only group's members in user dropdowns on issuables list pages
merge_request: 14249
author:
type: changed
require 'spec_helper'
feature 'Groups > User sees users dropdowns in issuables list' do
let(:entity) { create(:group) }
let(:user_in_dropdown) { create(:user) }
let!(:user_not_in_dropdown) { create(:user) }
let!(:project) { create(:project, group: entity) }
before do
entity.add_developer(user_in_dropdown)
end
it_behaves_like 'issuable user dropdown behaviors' do
let(:issuable) { create(:issue, project: project) }
let(:issuables_path) { issues_group_path(entity) }
end
it_behaves_like 'issuable user dropdown behaviors' do
let(:issuable) { create(:merge_request, source_project: project) }
let(:issuables_path) { merge_requests_group_path(entity) }
end
end
......@@ -10,6 +10,7 @@ describe('Dropdown User', () => {
beforeEach(() => {
spyOn(gl.DropdownUser.prototype, 'bindEvents').and.callFake(() => {});
spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
spyOn(gl.DropdownUser.prototype, 'getGroupId').and.callFake(() => {});
spyOn(gl.DropdownUtils, 'getSearchInput').and.callFake(() => {});
dropdownUser = new gl.DropdownUser({
......@@ -38,6 +39,7 @@ describe('Dropdown User', () => {
beforeEach(() => {
spyOn(gl.DropdownUser.prototype, 'bindEvents').and.callFake(() => {});
spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
spyOn(gl.DropdownUser.prototype, 'getGroupId').and.callFake(() => {});
});
it('should return endpoint', () => {
......
shared_examples 'issuable user dropdown behaviors' do
include FilteredSearchHelpers
before do
issuable # ensure we have at least one issuable
sign_in(user_in_dropdown)
end
%w[author assignee].each do |dropdown|
describe "#{dropdown} dropdown", :js do
it 'only includes members of the project/group' do
visit issuables_path
filtered_search.set("#{dropdown}:")
expect(find("#js-dropdown-#{dropdown} .filter-dropdown")).to have_content(user_in_dropdown.name)
expect(find("#js-dropdown-#{dropdown} .filter-dropdown")).not_to have_content(user_not_in_dropdown.name)
end
end
end
end
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