summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-01-08 18:29:33 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-01-08 19:25:32 -0200
commit4b1546159c29ef46f106bb1393a542187b950c4e (patch)
treebd625fc5d026d24935858dc3833b002cf7903ddb
parentb1378f05a11345f761cd31ae51aafc268003150a (diff)
downloadgitlab-ce-4b1546159c29ef46f106bb1393a542187b950c4e.tar.gz
Add spec for gitlab:uploads rake tasks
-rw-r--r--spec/tasks/gitlab/uploads_rake_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/uploads_rake_spec.rb b/spec/tasks/gitlab/uploads_rake_spec.rb
new file mode 100644
index 00000000000..9330539f8c9
--- /dev/null
+++ b/spec/tasks/gitlab/uploads_rake_spec.rb
@@ -0,0 +1,28 @@
+require 'rake_helper'
+
+describe 'gitlab:uploads rake tasks' do
+ describe 'check' do
+ before do
+ Rake.application.rake_require 'tasks/gitlab/uploads'
+ end
+
+ it 'outputs the integrity check for each uploaded file' do
+ uploaded_file = create(:upload)
+
+ expect { run_rake_task('gitlab:uploads:check') }.to output(/Checking file \(#{uploaded_file.id}\): #{Regexp.quote(uploaded_file.absolute_path)}/).to_stdout
+ end
+
+ it 'errors out about missing files on the file system' do
+ uploaded_file = create(:upload)
+
+ expect { run_rake_task('gitlab:uploads:check') }.to output(/File does not exist on the file system/).to_stdout
+ end
+
+ it 'errors out about invalid checksum' do
+ uploaded_file = create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif'))
+ uploaded_file.update_column(:checksum, '01a3156db2cf4f67ec823680b40b7302f89ab39179124ad219f94919b8a1769e')
+
+ expect { run_rake_task('gitlab:uploads:check') }.to output(/File checksum \(9e697aa09fe196909813ee36103e34f721fe47a5fdc8aac0e4e4ac47b9b38282\) does not match the one in the database \(#{uploaded_file.checksum}\)/).to_stdout
+ end
+ end
+end