31 lines
1 KiB
Ruby
31 lines
1 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe JobArtifactUploader do
|
|
let(:job_artifact) { create(:ci_job_artifact) }
|
|
let(:uploader) { described_class.new(job_artifact, :file) }
|
|
|
|
subject { uploader }
|
|
|
|
it_behaves_like "builds correct paths",
|
|
store_dir: %r[\h{2}/\h{2}/\h{64}/\d{4}_\d{1,2}_\d{1,2}/\d+/\d+\z],
|
|
cache_dir: %r[artifacts/tmp/cache],
|
|
work_dir: %r[artifacts/tmp/work]
|
|
|
|
context 'file is stored in valid local_path' do
|
|
let(:file) do
|
|
fixture_file_upload(
|
|
Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
|
|
end
|
|
|
|
before do
|
|
uploader.store!(file)
|
|
end
|
|
|
|
subject { uploader.file.path }
|
|
|
|
it { is_expected.to start_with("#{uploader.root}/#{uploader.class.base_dir}") }
|
|
it { is_expected.to include("/#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/") }
|
|
it { is_expected.to include("/#{job_artifact.job_id}/#{job_artifact.id}/") }
|
|
it { is_expected.to end_with("ci_build_artifacts.zip") }
|
|
end
|
|
end
|