summaryrefslogtreecommitdiff
path: root/spec/requests/ci
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-19 22:01:37 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-12-19 22:01:37 +0800
commit1e2e0de9441a2f9777bb989e8a8c275c2b103ca7 (patch)
tree8e09cdfe519e9686ceb56fa4b9ebeef234349499 /spec/requests/ci
parentec003d9eb338f9172696f5540637e759a93f9fcf (diff)
downloadgitlab-ce-1e2e0de9441a2f9777bb989e8a8c275c2b103ca7.tar.gz
Define actions in let so that it could be overridden
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8091/diffs#note_20236356
Diffstat (limited to 'spec/requests/ci')
-rw-r--r--spec/requests/ci/api/builds_spec.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index 2963fe85478..fdb2234d32b 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -249,7 +249,13 @@ describe Ci::API::Builds do
end
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_with_range) { headers.merge({ 'Content-Range' => '11-20' }) }
let(:update_interval) { 10.seconds.to_i }
@@ -276,7 +282,6 @@ describe Ci::API::Builds do
end
before do
- build.run!
initial_patch_the_trace
end
@@ -332,17 +337,15 @@ describe Ci::API::Builds do
context 'when project for the build has been deleted' do
let(:build) do
- result = create(:ci_build,
- :pending,
- :trace,
- runner_id: runner.id,
- pipeline: pipeline)
- result.project.update(pending_delete: true)
- result
+ attributes = {runner_id: runner.id, pipeline: pipeline}
+ create(:ci_build, :pending, :trace, attributes) do |build|
+ build.run
+ build.project.update(pending_delete: true)
+ end
end
it 'responds with forbidden' do
- expect(response.status).to eq 403
+ expect(response.status).to eq(403)
end
end
end