Commit b7559e32 authored by Serena Fang's avatar Serena Fang Committed by Matthias Käppler

Remove repeat creation of deactivated user

parent 1ec37548
...@@ -2602,15 +2602,13 @@ RSpec.describe API::Users do ...@@ -2602,15 +2602,13 @@ RSpec.describe API::Users do
let(:api_user) { admin } let(:api_user) { admin }
context 'for a deactivated user' do context 'for a deactivated user' do
before do let(:user_id) { deactivated_user.id }
user.deactivate
end
it 'activates a deactivated user' do it 'activates a deactivated user' do
activate activate
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('active') expect(deactivated_user.reload.state).to eq('active')
end end
end end
...@@ -2714,15 +2712,13 @@ RSpec.describe API::Users do ...@@ -2714,15 +2712,13 @@ RSpec.describe API::Users do
end end
context 'for a deactivated user' do context 'for a deactivated user' do
before do let(:user_id) { deactivated_user.id }
user.deactivate
end
it 'returns 201' do it 'returns 201' do
deactivate deactivate
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('deactivated') expect(deactivated_user.reload.state).to eq('deactivated')
end end
end end
...@@ -2791,7 +2787,6 @@ RSpec.describe API::Users do ...@@ -2791,7 +2787,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(:deactivated_user) { create(:user, :deactivated) }
let_it_be(:blocked_user) { create(:user, :blocked) } let_it_be(:blocked_user) { create(:user, :blocked) }
context 'performed by a non-admin user' do context 'performed by a non-admin 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