Commit 7ec1a022 authored by James Lopez's avatar James Lopez

fix file upload

parent 516d33f5
......@@ -8,7 +8,7 @@ module API
end
def file_is_valid?
import_params[:file] && import_params[:file].respond_to?(:read)
import_params[:file] && import_params[:file]['tempfile'].respond_to?(:read)
end
end
......@@ -26,7 +26,7 @@ module API
success Entities::ProjectImportStatus
end
post 'import' do
render_api_error!('The branch refname is invalid', 400) unless file_is_valid?
render_api_error!('The file is invalid', 400) unless file_is_valid?
namespace = import_params[:namespace]
......@@ -38,7 +38,8 @@ module API
Namespace.find_by_path_or_name(namespace)
end
project_params = import_params.merge(namespace_id: namespace.id)
project_params = import_params.merge(namespace_id: namespace.id,
file: import_params[:file]['tempfile'])
project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute
......
......@@ -19,9 +19,9 @@ describe API::ProjectImport do
it 'schedules an import' do
expect_any_instance_of(Project).to receive(:import_schedule)
post api('/projects/import', user), path: 'test-import', file: file, namespace: namespace.full_path
post api('/projects/import', user), path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(201)
expect(Project.find_by_name('test-import').first.status).to eq('started')
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment