Commit b027a297 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'mwaw/fix-hardcoded-ids-in-projects-spec' into 'master'

Remove hardcoded values from projets api test

See merge request gitlab-org/gitlab!53126
parents 4421c856 0b825802
...@@ -1139,7 +1139,7 @@ RSpec.describe API::Projects do ...@@ -1139,7 +1139,7 @@ RSpec.describe API::Projects do
let!(:public_project) { create(:project, :public, name: 'public_project', creator_id: user4.id, namespace: user4.namespace) } let!(:public_project) { create(:project, :public, name: 'public_project', creator_id: user4.id, namespace: user4.namespace) }
it 'returns error when user not found' do it 'returns error when user not found' do
get api('/users/0/projects/') get api("/users/#{non_existing_record_id}/projects/")
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found') expect(json_response['message']).to eq('404 User Not Found')
...@@ -2154,7 +2154,7 @@ RSpec.describe API::Projects do ...@@ -2154,7 +2154,7 @@ RSpec.describe API::Projects do
end end
it 'fails if forked_from project which does not exist' do it 'fails if forked_from project which does not exist' do
post api("/projects/#{project_fork_target.id}/fork/0", admin) post api("/projects/#{project_fork_target.id}/fork/#{non_existing_record_id}", admin)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -2398,7 +2398,7 @@ RSpec.describe API::Projects do ...@@ -2398,7 +2398,7 @@ RSpec.describe API::Projects do
end end
it 'returns a 404 error when project does not exist' do it 'returns a 404 error when project does not exist' do
delete api("/projects/123/share/#{non_existing_record_id}", user) delete api("/projects/#{non_existing_record_id}/share/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -2955,7 +2955,7 @@ RSpec.describe API::Projects do ...@@ -2955,7 +2955,7 @@ RSpec.describe API::Projects do
end end
it 'returns the proper security headers' do it 'returns the proper security headers' do
get api('/projects/1/starrers', current_user) get api("/projects/#{public_project.id}/starrers", current_user)
expect(response).to include_security_headers expect(response).to include_security_headers
end end
...@@ -3028,7 +3028,7 @@ RSpec.describe API::Projects do ...@@ -3028,7 +3028,7 @@ RSpec.describe API::Projects do
end end
it 'returns not_found(404) for not existing project' do it 'returns not_found(404) for not existing project' do
get api("/projects/0/languages", user) get api("/projects/#{non_existing_record_id}/languages", user)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -3079,7 +3079,7 @@ RSpec.describe API::Projects do ...@@ -3079,7 +3079,7 @@ RSpec.describe API::Projects do
end end
it 'does not remove a non existing project' do it 'does not remove a non existing project' do
delete api('/projects/1328', user) delete api("/projects/#{non_existing_record_id}", user)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
...@@ -3098,7 +3098,7 @@ RSpec.describe API::Projects do ...@@ -3098,7 +3098,7 @@ RSpec.describe API::Projects do
end end
it 'does not remove a non existing project' do it 'does not remove a non existing project' do
delete api('/projects/1328', admin) delete api("/projects/#{non_existing_record_id}", admin)
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
......
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