diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-07-17 13:02:28 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-07-18 15:38:54 +0200 |
commit | 79f591df4dfd6577c55d3bb843e423bba859e9b9 (patch) | |
tree | c0715f34cc300996b3eb05490ba69790ad299100 /spec/migrations/move_system_upload_folder_spec.rb | |
parent | 27a6aa4f515cb46ef3f72cad962b25ceee52986a (diff) | |
download | gitlab-ce-79f591df4dfd6577c55d3bb843e423bba859e9b9.tar.gz |
Move the `uploads/system` folder to `uploads/-/system`
Without downtime, so we need the symlinks
Diffstat (limited to 'spec/migrations/move_system_upload_folder_spec.rb')
-rw-r--r-- | spec/migrations/move_system_upload_folder_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/migrations/move_system_upload_folder_spec.rb b/spec/migrations/move_system_upload_folder_spec.rb new file mode 100644 index 00000000000..b622b4e9536 --- /dev/null +++ b/spec/migrations/move_system_upload_folder_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper' +require Rails.root.join("db", "migrate", "20170717074009_move_system_upload_folder.rb") + +describe MoveSystemUploadFolder do + let(:migration) { described_class.new } + let(:test_base) { File.join(Rails.root, 'tmp', 'tests', 'move-system-upload-folder') } + + before do + allow(migration).to receive(:base_directory).and_return(test_base) + FileUtils.rm_rf(test_base) + FileUtils.mkdir_p(test_base) + allow(migration).to receive(:say) + end + + describe '#up' do + let(:test_folder) { File.join(test_base, 'system') } + let(:test_file) { File.join(test_folder, 'file') } + + before do + FileUtils.mkdir_p(test_folder) + FileUtils.touch(test_file) + end + + it 'moves the related folder' do + migration.up + + expect(File.exist?(File.join(test_base, '-', 'system', 'file'))).to be_truthy + end + + it 'creates a symlink linking making the new folder available on the old path' do + migration.up + + expect(File.symlink?(File.join(test_base, 'system'))).to be_truthy + expect(File.exist?(File.join(test_base, 'system', 'file'))).to be_truthy + end + end + + describe '#down' do + let(:test_folder) { File.join(test_base, '-', 'system') } + let(:test_file) { File.join(test_folder, 'file') } + + before do + FileUtils.mkdir_p(test_folder) + FileUtils.touch(test_file) + end + + it 'moves the system folder back to the old location' do + migration.down + + expect(File.exist?(File.join(test_base, 'system', 'file'))).to be_truthy + end + + it 'removes the symlink if it existed' do + FileUtils.ln_s(test_folder, File.join(test_base, 'system')) + + migration.down + + expect(File.directory?(File.join(test_base, 'system'))).to be_truthy + expect(File.symlink?(File.join(test_base, 'system'))).to be_falsey + end + end +end |