Commit 1e2e0de9 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Define actions in let so that it could be overridden

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8091/diffs#note_20236356
parent ec003d9e
...@@ -249,7 +249,13 @@ describe Ci::API::Builds do ...@@ -249,7 +249,13 @@ describe Ci::API::Builds do
end end
describe 'PATCH /builds/:id/trace.txt' do describe 'PATCH /builds/:id/trace.txt' do
let(:build) { create(:ci_build, :pending, :trace, runner_id: runner.id) } let(:build) do
attributes = {runner_id: runner.id, pipeline: pipeline}
create(:ci_build, :pending, :trace, attributes) do |build|
build.run
end
end
let(:headers) { { Ci::API::Helpers::BUILD_TOKEN_HEADER => build.token, 'Content-Type' => 'text/plain' } } let(:headers) { { Ci::API::Helpers::BUILD_TOKEN_HEADER => build.token, 'Content-Type' => 'text/plain' } }
let(:headers_with_range) { headers.merge({ 'Content-Range' => '11-20' }) } let(:headers_with_range) { headers.merge({ 'Content-Range' => '11-20' }) }
let(:update_interval) { 10.seconds.to_i } let(:update_interval) { 10.seconds.to_i }
...@@ -276,7 +282,6 @@ describe Ci::API::Builds do ...@@ -276,7 +282,6 @@ describe Ci::API::Builds do
end end
before do before do
build.run!
initial_patch_the_trace initial_patch_the_trace
end end
...@@ -332,17 +337,15 @@ describe Ci::API::Builds do ...@@ -332,17 +337,15 @@ describe Ci::API::Builds do
context 'when project for the build has been deleted' do context 'when project for the build has been deleted' do
let(:build) do let(:build) do
result = create(:ci_build, attributes = {runner_id: runner.id, pipeline: pipeline}
:pending, create(:ci_build, :pending, :trace, attributes) do |build|
:trace, build.run
runner_id: runner.id, build.project.update(pending_delete: true)
pipeline: pipeline) end
result.project.update(pending_delete: true)
result
end end
it 'responds with forbidden' do it 'responds with forbidden' do
expect(response.status).to eq 403 expect(response.status).to eq(403)
end end
end end
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