Commit 673bb9ef authored by Robert Speicher's avatar Robert Speicher

Merge branch 'tests/isolate-carrierwave-uploads' into 'master'

Isolate CarrierWave uploads in test enviroment

Purpose of this merge request is to isolate CarrierWave uploads in test environment, from regular development/production uploads.
We need to persist some files in order to test some features thoroughly. If we - for example - want to check if file exists after being uploaded via API, or we need to write tests that check if file has been correctly removed we need to persist uploads using CarrierWave.

This approach simply sets `root` path for uploads in test environment and removes temporary directory after executing RSpec tests suite. We set this in `spec_helper` to keep this in one place, this also can be set up in test environment initializer.

This issue is a workaround for #12968, but does not solve this problem completely, because if uploader defines absolute path in `store_dir` or defines custom `root` path, this may not work correctly (but it looks like we do have such uploaders at this moment).

See merge request !3435
parents c9a7cc4b 6f0cba11
CarrierWave.root = 'tmp/tests/uploads'
RSpec.configure do |config|
config.after(:suite) do
FileUtils.rm_rf('tmp/tests/uploads')
end
end
......@@ -7,8 +7,12 @@ describe 'gitlab:app namespace rake task' do
Rake.application.rake_require 'tasks/gitlab/backup'
Rake.application.rake_require 'tasks/gitlab/shell'
Rake.application.rake_require 'tasks/gitlab/db'
# empty task as env is already loaded
Rake::Task.define_task :environment
# We need this directory to run `gitlab:backup:create` task
FileUtils.mkdir_p('public/uploads')
end
def run_rake_task(task_name)
......
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