summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-01-08 19:43:53 -0200
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-01-08 19:43:53 -0200
commit9afb77b6d409ce385b872de430c561b0ee9ae29a (patch)
tree7c48097ca90eb6566f2fc205472f174699c9fdd4
parenta75bbbd92ad28f8d731231104e65d6aeeca1256c (diff)
downloadgitlab-ce-9afb77b6d409ce385b872de430c561b0ee9ae29a.tar.gz
Refactoring spec for the gitlab:uploads:check rake task
-rw-r--r--spec/tasks/gitlab/uploads_rake_spec.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/spec/tasks/gitlab/uploads_rake_spec.rb b/spec/tasks/gitlab/uploads_rake_spec.rb
index 0c779d8a135..ac0005e51e0 100644
--- a/spec/tasks/gitlab/uploads_rake_spec.rb
+++ b/spec/tasks/gitlab/uploads_rake_spec.rb
@@ -2,14 +2,14 @@ require 'rake_helper'
describe 'gitlab:uploads rake tasks' do
describe 'check' do
+ let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) }
+
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
+ expect { run_rake_task('gitlab:uploads:check') }.to output(/Checking file \(#{upload.id}\): #{Regexp.quote(upload.absolute_path)}/).to_stdout
end
it 'errors out about missing files on the file system' do
@@ -19,10 +19,9 @@ describe 'gitlab:uploads rake tasks' do
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')
+ upload.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
+ expect { run_rake_task('gitlab:uploads:check') }.to output(/File checksum \(9e697aa09fe196909813ee36103e34f721fe47a5fdc8aac0e4e4ac47b9b38282\) does not match the one in the database \(#{upload.checksum}\)/).to_stdout
end
end
end