summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-04-03 21:52:23 +0900
committerShinya Maeda <shinya@gitlab.com>2018-04-05 20:42:08 +0900
commit9c990bbe7a4f213778b60fcd63f21719c6433d93 (patch)
treeecff2f9da10d4a0c60fd324d42c8e82afb48acd4
parentd6b18d3946926cff5c6bd47b609a0d2e0c899317 (diff)
downloadgitlab-ce-9c990bbe7a4f213778b60fcd63f21719c6433d93.tar.gz
Add test
-rw-r--r--lib/gitlab/ci/trace/stream.rb8
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb16
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb
index ca9f62ad80c..54894a46077 100644
--- a/lib/gitlab/ci/trace/stream.rb
+++ b/lib/gitlab/ci/trace/stream.rb
@@ -8,7 +8,7 @@ module Gitlab
attr_reader :stream
- delegate :close, :tell, :seek, :size, :path, :url, :truncate, to: :stream, allow_nil: true
+ delegate :close, :tell, :seek, :size, :url, :truncate, to: :stream, allow_nil: true
delegate :valid?, to: :stream, as: :present?, allow_nil: true
@@ -22,7 +22,11 @@ module Gitlab
end
def file?
- self.path.present? if respond_to?(:path)
+ self.path.present?
+ end
+
+ def path
+ self.stream.path if self.stream.respond_to?(:path)
end
def limit(last_bytes = LIMIT_SIZE)
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index 31046c202e6..20a826cc198 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -513,6 +513,22 @@ describe Projects::JobsController do
end
end
+ context 'when job has a trace in database' do
+ let(:job) { create(:ci_build, pipeline: pipeline) }
+
+ before do
+ job.update_column(:trace, 'Sample trace')
+ end
+
+ it 'send a trace file' do
+ response = subject
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response.content_type).to eq 'text/plain; charset=utf-8'
+ expect(response.body).to eq 'Sample trace'
+ end
+ end
+
context 'when job does not have a trace file' do
let(:job) { create(:ci_build, pipeline: pipeline) }