Commit 4eb27d7c authored by Tomasz Maczukin's avatar Tomasz Maczukin

Add some modifications to builds API and specs

parent d54bff2a
...@@ -103,7 +103,7 @@ module API ...@@ -103,7 +103,7 @@ module API
authorize_manage_builds! authorize_manage_builds!
build = get_build(params[:build_id]) build = get_build(params[:build_id])
return not_found!(build) unless build && build.retryable? return forbidden!('Build is not retryable') unless build && build.retryable?
build = Ci::Build.retry(build) build = Ci::Build.retry(build)
......
...@@ -50,7 +50,7 @@ describe API::API, api: true do ...@@ -50,7 +50,7 @@ describe API::API, api: true do
context 'authorized user' do context 'authorized user' do
it 'should return project builds for specific commit' do it 'should return project builds for specific commit' do
project.ensure_ci_commit(commit.sha) project.ensure_ci_commit(commit.sha)
get api("/projects/#{project.id}/builds/commit/#{project.ci_commits.first.sha}", user) get api("/projects/#{project.id}/builds/commit/#{commit.sha}", user)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -60,7 +60,7 @@ describe API::API, api: true do ...@@ -60,7 +60,7 @@ describe API::API, api: true do
context 'unauthorized user' do context 'unauthorized user' do
it 'should not return project builds' do it 'should not return project builds' do
project.ensure_ci_commit(commit.sha) project.ensure_ci_commit(commit.sha)
get api("/projects/#{project.id}/builds/commit/#{project.ci_commits.first.sha}") get api("/projects/#{project.id}/builds/commit/#{commit.sha}")
expect(response.status).to eq(401) expect(response.status).to eq(401)
end end
...@@ -99,7 +99,7 @@ describe API::API, api: true do ...@@ -99,7 +99,7 @@ describe API::API, api: true do
end end
end end
describe 'GET /projects/:id/builds/:build_id/cancel' do describe 'POST /projects/:id/builds/:build_id/cancel' do
context 'authorized user' do context 'authorized user' do
context 'user with :manage_builds persmission' do context 'user with :manage_builds persmission' do
it 'should cancel running or pending build' do it 'should cancel running or pending build' do
...@@ -128,7 +128,7 @@ describe API::API, api: true do ...@@ -128,7 +128,7 @@ describe API::API, api: true do
end end
end end
describe 'GET /projects/:id/builds/:build_id/retry' do describe 'POST /projects/:id/builds/:build_id/retry' do
context 'authorized user' do context 'authorized user' do
context 'user with :manage_builds persmission' do context 'user with :manage_builds persmission' do
it 'should retry non-running build' do it 'should retry non-running build' 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