diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-04-03 21:52:23 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-04-03 21:52:23 +0900 |
commit | 5cdbec20e92c2ff92b2270d0e879573e9bc80629 (patch) | |
tree | 2e20931e02b44e11f3aeee293ca4dd4884a1455d | |
parent | c0997eca4b78c3daae0c158520d30164a146e26a (diff) | |
download | gitlab-ce-5cdbec20e92c2ff92b2270d0e879573e9bc80629.tar.gz |
Add test
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 8 | ||||
-rw-r--r-- | spec/controllers/projects/jobs_controller_spec.rb | 16 |
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) } |