Skip to content
Snippets Groups Projects
Unverified Commit 7ec1a022 authored by James Lopez's avatar James Lopez
Browse files

fix file upload

parent 516d33f5
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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]
 
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment