Commit 37d45e06 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'move-blocked-user-creation-higher' into 'master'

Move blocked user creation higher

See merge request gitlab-org/gitlab!69417
parents 56bbbd79 740b0c7a
...@@ -9,6 +9,7 @@ RSpec.describe API::Users do ...@@ -9,6 +9,7 @@ RSpec.describe API::Users do
let_it_be(:gpg_key) { create(:gpg_key, user: user) } let_it_be(:gpg_key) { create(:gpg_key, user: user) }
let_it_be(:email) { create(:email, user: user) } let_it_be(:email) { create(:email, user: user) }
let(:blocked_user) { create(:user, :blocked) }
let(:omniauth_user) { create(:omniauth_user) } let(:omniauth_user) { create(:omniauth_user) }
let(:ldap_blocked_user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') } let(:ldap_blocked_user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') }
let(:private_user) { create(:user, private_profile: true) } let(:private_user) { create(:user, private_profile: true) }
...@@ -2626,16 +2627,14 @@ RSpec.describe API::Users do ...@@ -2626,16 +2627,14 @@ RSpec.describe API::Users do
end end
context 'for a blocked user' do context 'for a blocked user' do
before do let(:user_id) { blocked_user.id }
user.block
end
it 'returns 403' do it 'returns 403' do
activate activate
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden - A blocked user must be unblocked to be activated') expect(json_response['message']).to eq('403 Forbidden - A blocked user must be unblocked to be activated')
expect(user.reload.state).to eq('blocked') expect(blocked_user.reload.state).to eq('blocked')
end end
end end
...@@ -2723,16 +2722,14 @@ RSpec.describe API::Users do ...@@ -2723,16 +2722,14 @@ RSpec.describe API::Users do
end end
context 'for a blocked user' do context 'for a blocked user' do
before do let(:user_id) { blocked_user.id }
user.block
end
it 'returns 403' do it 'returns 403' do
deactivate deactivate
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden - A blocked user cannot be deactivated by the API') expect(json_response['message']).to eq('403 Forbidden - A blocked user cannot be deactivated by the API')
expect(user.reload.state).to eq('blocked') expect(blocked_user.reload.state).to eq('blocked')
end end
end end
...@@ -2787,8 +2784,6 @@ RSpec.describe API::Users do ...@@ -2787,8 +2784,6 @@ RSpec.describe API::Users do
describe 'POST /users/:id/approve' do describe 'POST /users/:id/approve' do
subject(:approve) { post api("/users/#{user_id}/approve", api_user) } subject(:approve) { post api("/users/#{user_id}/approve", api_user) }
let_it_be(:blocked_user) { create(:user, :blocked) }
context 'performed by a non-admin user' do context 'performed by a non-admin user' do
let(:api_user) { user } let(:api_user) { user }
let(:user_id) { pending_user.id } let(:user_id) { pending_user.id }
...@@ -2923,7 +2918,6 @@ RSpec.describe API::Users do ...@@ -2923,7 +2918,6 @@ RSpec.describe API::Users do
end end
context 'for a blocked user' do context 'for a blocked user' do
let(:blocked_user) { create(:user, :blocked) }
let(:user_id) { blocked_user.id } let(:user_id) { blocked_user.id }
it 'does not reject a blocked user' do it 'does not reject a blocked user' do
...@@ -3006,7 +3000,6 @@ RSpec.describe API::Users do ...@@ -3006,7 +3000,6 @@ RSpec.describe API::Users do
end end
context 'with a blocked user' do context 'with a blocked user' do
let(:blocked_user) { create(:user, state: 'blocked') }
let(:user_id) { blocked_user.id } let(:user_id) { blocked_user.id }
it 'returns a 201 if user is already blocked' do it 'returns a 201 if user is already blocked' do
...@@ -3042,7 +3035,6 @@ RSpec.describe API::Users do ...@@ -3042,7 +3035,6 @@ RSpec.describe API::Users do
end end
context 'with a blocked user' do context 'with a blocked user' do
let(:blocked_user) { create(:user, state: 'blocked') }
let(:user_id) { blocked_user.id } let(:user_id) { blocked_user.id }
it 'unblocks a blocked user' do it 'unblocks a blocked user' do
......
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