diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-06-22 04:03:26 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-07-20 06:28:17 +0300 |
commit | 3a7b724f6a03a19719b05b30e1e76e536230bcca (patch) | |
tree | 077e1e76d9cd1a2ded429386bb374f2260f58782 /spec | |
parent | d3d877813cab8bfdc25ef06011a95190871e3f8e (diff) |
Merge branch 'bvl-remove-appearance-symlink' into 'security-9-3'
Remove the `appearance` symlink that was previously missed
See merge request !2124
Diffstat (limited to 'spec')
-rw-r--r-- | spec/migrations/clean_appearance_symlinks_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/migrations/clean_appearance_symlinks_spec.rb b/spec/migrations/clean_appearance_symlinks_spec.rb new file mode 100644 index 00000000000..9225dc0d894 --- /dev/null +++ b/spec/migrations/clean_appearance_symlinks_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20170613111224_clean_appearance_symlinks.rb') + +describe CleanAppearanceSymlinks do + let(:migration) { described_class.new } + let(:test_dir) { File.join(Rails.root, "tmp", "tests", "clean_appearance_test") } + let(:uploads_dir) { File.join(test_dir, "public", "uploads") } + let(:new_uploads_dir) { File.join(uploads_dir, "system") } + let(:original_path) { File.join(new_uploads_dir, 'appearance') } + let(:symlink_path) { File.join(uploads_dir, 'appearance') } + + before do + FileUtils.remove_dir(test_dir) if File.directory?(test_dir) + FileUtils.mkdir_p(uploads_dir) + allow(migration).to receive(:base_directory).and_return(test_dir) + allow(migration).to receive(:say) + end + + describe "#up" do + before do + FileUtils.mkdir_p(original_path) + FileUtils.ln_s(original_path, symlink_path) + end + + it 'removes the symlink' do + migration.up + + expect(File.symlink?(symlink_path)).to be(false) + end + end + + describe '#down' do + before do + FileUtils.mkdir_p(File.join(original_path)) + FileUtils.touch(File.join(original_path, 'dummy.file')) + end + + it 'creates a symlink' do + expected_path = File.join(symlink_path, "dummy.file") + migration.down + + expect(File.exist?(expected_path)).to be(true) + expect(File.symlink?(symlink_path)).to be(true) + end + end +end |