summaryrefslogtreecommitdiff
path: root/spec/services/import/gitlab_projects/file_acquisition_strategies/file_upload_spec.rb
blob: 28af62198122951783d36175db5fc79f2a90aaee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::FileUpload, :aggregate_failures do
  let(:file) { UploadedFile.new( File.join('spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') ) }

  describe 'validation' do
    it 'validates presence of file' do
      valid = described_class.new(params: { file: file })
      expect(valid).to be_valid

      invalid = described_class.new(params: {})
      expect(invalid).not_to be_valid
      expect(invalid.errors.full_messages).to include("File must be uploaded")
    end
  end

  describe '#project_params' do
    it 'returns the file to upload in the params' do
      subject = described_class.new(params: { file: file })

      expect(subject.project_params).to eq(file: file)
    end
  end
end