BigW Consortium Gitlab

version_checker_spec.rb 1.21 KB
Newer Older
1
require 'spec_helper'
2
include ImportExport::CommonUtil
3 4

describe Gitlab::ImportExport::VersionChecker, services: true do
5 6
  let(:shared) { Gitlab::ImportExport::Shared.new(relative_path: '') }

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  describe 'bundle a project Git repo' do
    let(:version) { Gitlab::ImportExport.version }

    before do
      allow(File).to receive(:open).and_return(version)
    end

    it 'returns true if Import/Export have the same version' do
      expect(described_class.check!(shared: shared)).to be true
    end

    context 'newer version' do
      let(:version) { '900.0'}

      it 'returns false if export version is newer' do
        expect(described_class.check!(shared: shared)).to be false
      end

      it 'shows the correct error message' do
        described_class.check!(shared: shared)

28
        expect(shared.errors.first).to eq("Import version mismatch: Required #{Gitlab::ImportExport.version} but was #{version}")
29 30 31
      end
    end
  end
32 33 34 35 36 37 38 39 40 41 42 43

  describe 'version file access check' do
    it 'does not read a symlink' do
      Dir.mktmpdir do |tmpdir|
        setup_symlink(tmpdir, 'VERSION')

        described_class.check!(shared: shared)

        expect(shared.errors.first).not_to include('test')
      end
    end
  end
44
end