Commit 737666a3 authored by Kamil Trzciński's avatar Kamil Trzciński

Fix specs

parent 5a9f23e7
...@@ -76,11 +76,12 @@ class GitlabUploader < CarrierWave::Uploader::Base ...@@ -76,11 +76,12 @@ class GitlabUploader < CarrierWave::Uploader::Base
end end
def open def open
stream = if file_storage? stream =
File.open(path, "rb") if path if file_storage?
else File.open(path, "rb") if path
::Gitlab::HttpIO.new(url, cached_size) if url else
end ::Gitlab::HttpIO.new(url, cached_size) if url
end
return unless stream return unless stream
return stream unless block_given? return stream unless block_given?
......
...@@ -216,20 +216,19 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -216,20 +216,19 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end end
context 'when trace artifact is in ObjectStorage' do context 'when trace artifact is in ObjectStorage' do
let(:url) { 'http://object-storage/trace' }
let(:file_path) { expand_fixture_path('trace/sample_trace') }
let!(:job) { create(:ci_build, :success, :trace_artifact, pipeline: pipeline) } let!(:job) { create(:ci_build, :success, :trace_artifact, pipeline: pipeline) }
before do before do
allow_any_instance_of(JobArtifactUploader).to receive(:file_storage?) { false } allow_any_instance_of(JobArtifactUploader).to receive(:file_storage?) { false }
allow_any_instance_of(JobArtifactUploader).to receive(:url) { remote_trace_url } allow_any_instance_of(JobArtifactUploader).to receive(:url) { url }
allow_any_instance_of(JobArtifactUploader).to receive(:size) { remote_trace_size } allow_any_instance_of(JobArtifactUploader).to receive(:size) { File.size(file_path) }
end end
context 'when there are no network issues' do context 'when there are no network issues' do
let(:url) { 'http://object-storage/trace' }
let(:file) { expand_fixture_path('trace/sample_trace') }
before do before do
stub_remote_url_206(url, file) stub_remote_url_206(url, file_path)
get_trace get_trace
end end
......
...@@ -536,13 +536,13 @@ describe API::Jobs do ...@@ -536,13 +536,13 @@ describe API::Jobs do
context 'when trace is in ObjectStorage' do context 'when trace is in ObjectStorage' do
let!(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) } let!(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
let(:url) { 'http://object-storage/trace' } let(:url) { 'http://object-storage/trace' }
let(:file) { expand_fixture_path('trace/sample_trace') } let(:file_path) { expand_fixture_path('trace/sample_trace') }
before do before do
stub_remote_url_206(url, file_path) stub_remote_url_206(url, file_path)
allow_any_instance_of(JobArtifactUploader).to receive(:file_storage?) { false } allow_any_instance_of(JobArtifactUploader).to receive(:file_storage?) { false }
allow_any_instance_of(JobArtifactUploader).to receive(:url) { url } allow_any_instance_of(JobArtifactUploader).to receive(:url) { url }
allow_any_instance_of(JobArtifactUploader).to receive(:size) { File.size(file) } allow_any_instance_of(JobArtifactUploader).to receive(:size) { File.size(file_path) }
end end
it 'returns specific job trace' do it 'returns specific job trace' 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