summaryrefslogtreecommitdiff
path: root/spec/uploaders
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-02-06 15:19:35 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-02-06 15:19:35 +0000
commit9ab4c5b735e0e121996b092cb20bcdc423045c5e (patch)
tree981ea32cf01d5261e9956439ce9745c5e2ae6dcf /spec/uploaders
parent86342966a1b61d30dca019e983235aadc14a36ef (diff)
parent939391af7bc471f1588ab75ab0cf08d8e4286a05 (diff)
downloadgitlab-ce-9ab4c5b735e0e121996b092cb20bcdc423045c5e.tar.gz
Merge branch '14256-upload-destroy-removes-file' into 'master'
Uploads should delete files when destroyed Closes #14256 See merge request gitlab-org/gitlab-ce!16799
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/file_uploader_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb
index a559681a079..6a92e7fae51 100644
--- a/spec/uploaders/file_uploader_spec.rb
+++ b/spec/uploaders/file_uploader_spec.rb
@@ -48,6 +48,29 @@ describe FileUploader do
end
end
+ describe 'callbacks' do
+ describe '#prune_store_dir after :remove' do
+ before do
+ uploader.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
+ end
+
+ def store_dir
+ File.expand_path(uploader.store_dir, uploader.root)
+ end
+
+ it 'is called' do
+ expect(uploader).to receive(:prune_store_dir).once
+
+ uploader.remove!
+ end
+
+ it 'prune the store directory' do
+ expect { uploader.remove! }
+ .to change { File.exist?(store_dir) }.from(true).to(false)
+ end
+ end
+ end
+
describe '#secret' do
it 'generates a secret if none is provided' do
expect(described_class).to receive(:generate_secret).and_return('secret')