diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/controllers/groups_controller_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/controllers/groups_controller_spec.rb')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 91b11cd46c5..a7625e65603 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -370,6 +370,57 @@ RSpec.describe GroupsController, factory_default: :keep do end end end + + context 'when creating a group with the `role` attribute present' do + it 'changes the users role' do + sign_in(user) + + expect do + post :create, params: { group: { name: 'new_group', path: 'new_group' }, user: { role: 'devops_engineer' } } + end.to change { user.reload.role }.to('devops_engineer') + end + end + + context 'when creating a group with the `setup_for_company` attribute present' do + before do + sign_in(user) + end + + subject do + post :create, params: { group: { name: 'new_group', path: 'new_group', setup_for_company: 'false' } } + end + + it 'sets the groups `setup_for_company` value' do + subject + expect(Group.last.setup_for_company).to be(false) + end + + context 'when the user already has a value for `setup_for_company`' do + before do + user.update_attribute(:setup_for_company, true) + end + + it 'does not change the users `setup_for_company` value' do + expect(Users::UpdateService).not_to receive(:new) + expect { subject }.not_to change { user.reload.setup_for_company }.from(true) + end + end + + context 'when the user has no value for `setup_for_company`' do + it 'changes the users `setup_for_company` value' do + expect(Users::UpdateService).to receive(:new).and_call_original + expect { subject }.to change { user.reload.setup_for_company }.to(false) + end + end + end + + context 'when creating a group with the `jobs_to_be_done` attribute present' do + it 'sets the groups `jobs_to_be_done` value' do + sign_in(user) + post :create, params: { group: { name: 'new_group', path: 'new_group', jobs_to_be_done: 'other' } } + expect(Group.last.jobs_to_be_done).to eq('other') + end + end end describe 'GET #index' do |