diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/groups/group_members_controller_spec.rb | 19 | ||||
-rw-r--r-- | spec/controllers/projects/project_members_controller_spec.rb | 32 |
2 files changed, 50 insertions, 1 deletions
diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb index c6fd184ede0..a3659ae9163 100644 --- a/spec/controllers/groups/group_members_controller_spec.rb +++ b/spec/controllers/groups/group_members_controller_spec.rb @@ -97,6 +97,25 @@ RSpec.describe Groups::GroupMembersController do expect(assigns(:members).map(&:user_id)).to contain_exactly(user.id) end end + + context 'when webui_members_inherited_users is disabled' do + let_it_be(:shared_group) { create(:group) } + let_it_be(:shared_group_user) { create(:user) } + let_it_be(:group_link) { create(:group_group_link, shared_group: shared_group, shared_with_group: group) } + + before do + group.add_owner(user) + shared_group.add_owner(shared_group_user) + stub_feature_flags(webui_members_inherited_users: false) + sign_in(user) + end + + it 'lists inherited group members only' do + get :index, params: { group_id: shared_group } + + expect(assigns(:members).map(&:user_id)).to contain_exactly(shared_group_user.id) + end + end end describe 'PUT update' do diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb index 46eb340cbba..fb27fe58cd9 100644 --- a/spec/controllers/projects/project_members_controller_spec.rb +++ b/spec/controllers/projects/project_members_controller_spec.rb @@ -5,6 +5,7 @@ require('spec_helper') RSpec.describe Projects::ProjectMembersController do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group, :public) } + let_it_be(:sub_group) { create(:group, parent: group) } let_it_be(:project, reload: true) { create(:project, :public) } before do @@ -52,7 +53,36 @@ RSpec.describe Projects::ProjectMembersController do end end - context 'when invited members are present' do + context 'when project belongs to a sub-group' do + let_it_be(:user_in_group) { create(:user) } + let_it_be(:project_in_group) { create(:project, :public, group: sub_group) } + + before do + group.add_owner(user_in_group) + project_in_group.add_maintainer(user) + sign_in(user) + end + + it 'lists inherited project members by default' do + get :index, params: { namespace_id: project_in_group.namespace, project_id: project_in_group } + + expect(assigns(:project_members).map(&:user_id)).to contain_exactly(user.id, user_in_group.id) + end + + it 'lists direct project members only' do + get :index, params: { namespace_id: project_in_group.namespace, project_id: project_in_group, with_inherited_permissions: 'exclude' } + + expect(assigns(:project_members).map(&:user_id)).to contain_exactly(user.id) + end + + it 'lists inherited project members only' do + get :index, params: { namespace_id: project_in_group.namespace, project_id: project_in_group, with_inherited_permissions: 'only' } + + expect(assigns(:project_members).map(&:user_id)).to contain_exactly(user_in_group.id) + end + end + + context 'when invited project members are present' do let!(:invited_member) { create(:project_member, :invited, project: project) } before do |