Commit 154739d7 authored by Arturo Herrero's avatar Arturo Herrero

Merge branch '323191-user-cap-do-not-block-bot-users' into 'master'

Do not mark bot users as pending approval when User Cap is enabled [RUN ALL RSPEC]

See merge request gitlab-org/gitlab!56287
parents 975be5c7 f8e7c520
...@@ -105,6 +105,8 @@ module EE ...@@ -105,6 +105,8 @@ module EE
def set_pending_approval_state(user) def set_pending_approval_state(user)
return unless ::Gitlab::CurrentSettings.should_apply_user_signup_cap? return unless ::Gitlab::CurrentSettings.should_apply_user_signup_cap?
return unless user.human?
user.state = ::User::BLOCKED_PENDING_APPROVAL_STATE user.state = ::User::BLOCKED_PENDING_APPROVAL_STATE
end end
end end
......
---
title: Do not mark bot users as pending approval when User Cap is enabled
merge_request: 56287
author:
type: fixed
...@@ -8,6 +8,31 @@ RSpec.describe Users::BuildService do ...@@ -8,6 +8,31 @@ RSpec.describe Users::BuildService do
{ name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass' } { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass' }
end end
context 'with non admin user' do
let(:non_admin) { create(:user) }
context 'when user signup cap is set' do
before do
allow(Gitlab::CurrentSettings).to receive(:new_user_signups_cap).and_return(10)
end
it 'does not set the user state to blocked_pending_approval for non human users' do
params = {
name: 'Project Bot',
email: 'project_bot@example.com',
username: 'project_bot',
user_type: 'project_bot',
skip_confirmation: true
}
service = described_class.new(non_admin, params)
user = service.execute(skip_authorization: true)
expect(user).to be_active
end
end
end
context 'with an admin user' do context 'with an admin user' do
let!(:admin_user) { create(:admin) } let!(:admin_user) { create(:admin) }
let(:service) { described_class.new(admin_user, ActionController::Parameters.new(params).permit!) } let(:service) { described_class.new(admin_user, ActionController::Parameters.new(params).permit!) }
......
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