diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 11:41:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 11:41:52 +0300 |
commit | 585826cb22ecea5998a2c2a4675735c94bdeedac (patch) | |
tree | 5b05f0b30d33cef48963609e8a18a4dff260eab3 /spec/requests/api/groups_spec.rb | |
parent | df221d036e5d0c6c0ee4d55b9c97f481ee05dee8 (diff) |
Add latest changes from gitlab-org/gitlab@16-6-stable-eev16.6.0-rc42
Diffstat (limited to 'spec/requests/api/groups_spec.rb')
-rw-r--r-- | spec/requests/api/groups_spec.rb | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 662e11f7cfb..327dfd0a76b 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -572,7 +572,8 @@ RSpec.describe API::Groups, feature_category: :groups_and_projects do expect(json_response['require_two_factor_authentication']).to eq(group1.require_two_factor_authentication) expect(json_response['two_factor_grace_period']).to eq(group1.two_factor_grace_period) expect(json_response['auto_devops_enabled']).to eq(group1.auto_devops_enabled) - expect(json_response['emails_disabled']).to eq(group1.emails_disabled) + expect(json_response['emails_disabled']).to eq(group1.emails_disabled?) + expect(json_response['emails_enabled']).to eq(group1.emails_enabled?) expect(json_response['mentions_disabled']).to eq(group1.mentions_disabled) expect(json_response['project_creation_level']).to eq('maintainer') expect(json_response['subgroup_creation_level']).to eq('maintainer') @@ -870,6 +871,38 @@ RSpec.describe API::Groups, feature_category: :groups_and_projects do end end + before do + stub_application_setting(update_namespace_name_rate_limit: 1) + end + + it 'increments the update_namespace_name rate limit' do + put api("/groups/#{group1.id}", user1), params: { name: "#{new_group_name}_1" } + + expect(::Gitlab::ApplicationRateLimiter.peek(:update_namespace_name, scope: group1)).to be_falsey + + put api("/groups/#{group1.id}", user1), params: { name: "#{new_group_name}_2" } + + expect(::Gitlab::ApplicationRateLimiter.peek(:update_namespace_name, scope: group1)).to be_truthy + expect(response).to have_gitlab_http_status(:ok) + expect(group1.reload.name).to eq("#{new_group_name}_2") + end + + context 'a name is not passed in' do + it 'does not mark name update throttling' do + expect(::Gitlab::ApplicationRateLimiter).not_to receive(:throttled?) + + put api("/groups/#{group1.id}", user1), params: { path: 'another/path' } + end + end + + context 'an empty name is passed in' do + it 'does not mark name update throttling' do + expect(::Gitlab::ApplicationRateLimiter).not_to receive(:throttled?) + + put api("/groups/#{group1.id}", user1), params: { name: '' } + end + end + context 'when authenticated as the group owner' do it 'updates the group', :aggregate_failures do workhorse_form_with_file( @@ -895,7 +928,8 @@ RSpec.describe API::Groups, feature_category: :groups_and_projects do expect(json_response['require_two_factor_authentication']).to eq(false) expect(json_response['two_factor_grace_period']).to eq(48) expect(json_response['auto_devops_enabled']).to eq(nil) - expect(json_response['emails_disabled']).to eq(nil) + expect(json_response['emails_disabled']).to eq(false) + expect(json_response['emails_enabled']).to eq(true) expect(json_response['mentions_disabled']).to eq(nil) expect(json_response['project_creation_level']).to eq("noone") expect(json_response['subgroup_creation_level']).to eq("maintainer") |