diff options
author | Stan Hu <stanhu@gmail.com> | 2017-06-04 22:12:18 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-06-06 09:51:28 -0700 |
commit | 8a417f5ae89a509a006bac8a2d6104d8b169782c (patch) | |
tree | 3bc284f60f3cb7bccad319891a38f947c62c4812 /spec/uploaders/gitlab_uploader_spec.rb | |
parent | 6ac1caa01a4c059f5bcb7c9da2e83001e5469f73 (diff) | |
download | gitlab-ce-8a417f5ae89a509a006bac8a2d6104d8b169782c.tar.gz |
Set artifact working directory to be in the destination store to prevent unnecessary I/Osh-fix-refactor-uploader-work-dir
Similar to #33218, build artifacts were being uploaded into a CarrierWave
temporary directory in the Rails root directory before moved to their
final destination, which could cause a copy across filesystems. This
merge request refactors the work in !11866 so that any uploader can
just override `work_dir` to change the default implementation.
Closes #33274
Diffstat (limited to 'spec/uploaders/gitlab_uploader_spec.rb')
-rw-r--r-- | spec/uploaders/gitlab_uploader_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/uploaders/gitlab_uploader_spec.rb b/spec/uploaders/gitlab_uploader_spec.rb index 78e9d9cf46c..a144b39f74f 100644 --- a/spec/uploaders/gitlab_uploader_spec.rb +++ b/spec/uploaders/gitlab_uploader_spec.rb @@ -53,4 +53,19 @@ describe GitlabUploader do expect(subject.move_to_store).to eq(true) end end + + describe '#cache!' do + it 'moves the file from the working directory to the cache directory' do + # One to get the work dir, the other to remove it + expect(subject).to receive(:workfile_path).exactly(2).times.and_call_original + # Test https://github.com/carrierwavesubject/carrierwave/blob/v1.0.0/lib/carrierwave/sanitized_file.rb#L200 + expect(FileUtils).to receive(:mv).with(anything, /^#{subject.work_dir}/).and_call_original + expect(FileUtils).to receive(:mv).with(/^#{subject.work_dir}/, /#{subject.cache_dir}/).and_call_original + + fixture = Rails.root.join('spec', 'fixtures', 'rails_sample.jpg') + subject.cache!(fixture_file_upload(fixture)) + + expect(subject.file.path).to match(/#{subject.cache_dir}/) + end + end end |