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
This commit is contained in:
commit
673bb9ef1e
2 changed files with 11 additions and 0 deletions
7
spec/support/carrierwave.rb
Normal file
7
spec/support/carrierwave.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue