Commit 47d088b5 authored by sfang97's avatar sfang97

Use deactivate instead of subject

parent 0820adcf
......@@ -2400,7 +2400,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
end
describe 'POST /users/:id/deactivate' do
subject { post api("/users/#{user_id}/deactivate", api_user) }
subject(:deactivate) { post api("/users/#{user_id}/deactivate", api_user) }
let(:user_id) { user.id }
......@@ -2408,7 +2408,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
let(:api_user) { user }
it 'is not authorized to perform the action' do
subject
deactivate
expect(response).to have_gitlab_http_status(:forbidden)
end
......@@ -2425,7 +2425,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
let(:activity) { { last_activity_on: ::User::MINIMUM_INACTIVE_DAYS.next.days.ago } }
it 'deactivates an active user' do
subject
deactivate
expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('deactivated')
......@@ -2436,7 +2436,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
let(:activity) { { last_activity_on: ::User::MINIMUM_INACTIVE_DAYS.pred.days.ago } }
it 'does not deactivate an active user' do
subject
deactivate
expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq("403 Forbidden - The user you are trying to deactivate has been active in the past #{::User::MINIMUM_INACTIVE_DAYS} days and cannot be deactivated")
......@@ -2451,7 +2451,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 201' do
subject
deactivate
expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('deactivated')
......@@ -2464,7 +2464,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 403' do
subject
deactivate
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')
......@@ -2478,7 +2478,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 403' do
subject
deactivate
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')
......@@ -2490,7 +2490,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
let(:user) { User.alert_bot }
it 'returns 403' do
subject
deactivate
expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden - An internal user cannot be deactivated by the API')
......@@ -2501,7 +2501,7 @@ RSpec.describe API::Users, :do_not_mock_admin_mode do
let(:user_id) { 0 }
before do
subject
deactivate
end
it_behaves_like '404'
......
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