BigW Consortium Gitlab

uploads_rake_spec.rb 1.06 KB
Newer Older
1 2 3 4
require 'rake_helper'

describe 'gitlab:uploads rake tasks' do
  describe 'check' do
5 6
    let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) }

7 8 9 10 11
    before do
      Rake.application.rake_require 'tasks/gitlab/uploads'
    end

    it 'outputs the integrity check for each uploaded file' do
12
      expect { run_rake_task('gitlab:uploads:check') }.to output(/Checking file \(#{upload.id}\): #{Regexp.quote(upload.absolute_path)}/).to_stdout
13 14 15
    end

    it 'errors out about missing files on the file system' do
16
      create(:upload)
17 18 19 20 21

      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
22
      upload.update_column(:checksum, '01a3156db2cf4f67ec823680b40b7302f89ab39179124ad219f94919b8a1769e')
23

24
      expect { run_rake_task('gitlab:uploads:check') }.to output(/File checksum \(9e697aa09fe196909813ee36103e34f721fe47a5fdc8aac0e4e4ac47b9b38282\) does not match the one in the database \(#{upload.checksum}\)/).to_stdout
25 26 27
    end
  end
end