diff options
author | James Lopez <james@jameslopez.es> | 2018-02-12 12:13:08 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2018-02-13 17:25:47 +0300 |
commit | de3edb7178bd7df2f72ef403e57bfdf4e6f732df (patch) | |
tree | 70bf979ec8e9be939e6600f26c1df04e607fe030 /spec/requests | |
parent | 9bfa690b7d0a14bdd2791fe62f46dd38f57aa23e (diff) |
add more specs
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/project_import_spec.rb | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb index 51980dc1872..bf7bde0325a 100644 --- a/spec/requests/api/project_import_spec.rb +++ b/spec/requests/api/project_import_spec.rb @@ -4,7 +4,7 @@ describe API::ProjectImport do let(:export_path) { "#{Dir.tmpdir}/project_export_spec" } let(:user) { create(:user) } let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') } - let(:namespace){ create(:group) } + let(:namespace) { create(:group) } before do allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) @@ -15,11 +15,35 @@ describe API::ProjectImport do FileUtils.rm_rf(export_path, secure: true) end - it 'schedules an import' do - expect_any_instance_of(Project).to receive(:import_schedule) + describe 'POST /projects/import' do - post "/projects/import", file: file, namespace: namespace.full_path + it 'schedules an import' do + expect_any_instance_of(Project).to receive(:import_schedule) - expect(project.status).to eq('started') + post api('/projects/import', user), file: file, namespace: namespace.full_path + + expect(project.status).to eq('started') + end + end + + describe 'GET /projects/:id/import' do + it 'returns the import status' do + project = create(:project, import_status: 'started') + + get api("/projects/#{project.id}/import", user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response).to eq('import_status' => 'started') + end + + it 'returns the import status and the error if failed' do + project = create(:project, import_status: 'failed', import_error: 'error') + + get api("/projects/#{project.id}/import", user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response).to eq('import_status' => 'failed', + 'import_error' => 'error') + end end end |