fix file upload
This commit is contained in:
parent
516d33f5ac
commit
7ec1a022b7
2 changed files with 6 additions and 5 deletions
|
@ -8,7 +8,7 @@ module API
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_is_valid?
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ module API
|
||||||
success Entities::ProjectImportStatus
|
success Entities::ProjectImportStatus
|
||||||
end
|
end
|
||||||
post 'import' do
|
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]
|
namespace = import_params[:namespace]
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ module API
|
||||||
Namespace.find_by_path_or_name(namespace)
|
Namespace.find_by_path_or_name(namespace)
|
||||||
end
|
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
|
project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ describe API::ProjectImport do
|
||||||
it 'schedules an import' do
|
it 'schedules an import' do
|
||||||
expect_any_instance_of(Project).to receive(:import_schedule)
|
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')
|
expect(Project.find_by_name('test-import').first.status).to eq('started')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue