diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/tasks/gitlab/user_management_rake_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/tasks/gitlab/user_management_rake_spec.rb')
-rw-r--r-- | spec/tasks/gitlab/user_management_rake_spec.rb | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/user_management_rake_spec.rb b/spec/tasks/gitlab/user_management_rake_spec.rb new file mode 100644 index 00000000000..958055780d0 --- /dev/null +++ b/spec/tasks/gitlab/user_management_rake_spec.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +require 'rake_helper' + +RSpec.describe 'gitlab:user_management tasks' do + before do + Rake.application.rake_require 'tasks/gitlab/user_management' + end + + describe 'disable_project_and_group_creation' do + let(:group) { create(:group) } + + subject(:run_rake) { run_rake_task('gitlab:user_management:disable_project_and_group_creation', group.id) } + + it 'returns output info' do + expect { run_rake }.to output(/.*Done.*/).to_stdout + end + + context 'with users' do + let(:user_1) { create(:user, projects_limit: 10, can_create_group: true) } + let(:user_2) { create(:user, projects_limit: 10, can_create_group: true) } + let(:user_other) { create(:user, projects_limit: 10, can_create_group: true) } + + shared_examples 'updates proper users' do + it 'updates members' do + run_rake + + expect(user_1.reload.projects_limit).to eq(0) + expect(user_1.can_create_group).to eq(false) + expect(user_2.reload.projects_limit).to eq(0) + expect(user_2.can_create_group).to eq(false) + end + + it 'does not update other users' do + run_rake + + expect(user_other.reload.projects_limit).to eq(10) + expect(user_other.reload.can_create_group).to eq(true) + end + end + + context 'in the group' do + let(:other_group) { create(:group) } + + before do + group.add_developer(user_1) + group.add_developer(user_2) + other_group.add_developer(user_other) + end + + it_behaves_like 'updates proper users' + end + + context 'in the descendant groups' do + let(:subgroup) { create(:group, parent: group) } + let(:sub_subgroup) { create(:group, parent: subgroup) } + let(:other_group) { create(:group) } + + before do + subgroup.add_developer(user_1) + sub_subgroup.add_developer(user_2) + other_group.add_developer(user_other) + end + + it_behaves_like 'updates proper users' + end + + context 'in the children projects' do + let(:project_1) { create(:project, namespace: group) } + let(:project_2) { create(:project, namespace: group) } + let(:other_project) { create(:project) } + + before do + project_1.add_developer(user_1) + project_2.add_developer(user_2) + other_project.add_developer(user_other) + end + + it_behaves_like 'updates proper users' + end + end + end +end |