2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-04 00:42:52 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Import::GitlabProjectsController do
|
|
|
|
set(:namespace) { create(:namespace) }
|
|
|
|
set(:user) { namespace.owner }
|
2018-09-17 06:52:49 -04:00
|
|
|
let(:file) { fixture_file_upload('spec/fixtures/project_export.tar.gz', 'text/plain') }
|
2018-01-04 00:42:52 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'POST create' do
|
|
|
|
context 'with an invalid path' do
|
|
|
|
it 'redirects with an error' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :create, params: { namespace_id: namespace.id, path: '/test', file: file }
|
2018-01-04 00:42:52 -05:00
|
|
|
|
|
|
|
expect(flash[:alert]).to start_with('Project could not be imported')
|
|
|
|
expect(response).to have_gitlab_http_status(302)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects with an error when a relative path is used' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :create, params: { namespace_id: namespace.id, path: '../test', file: file }
|
2018-01-04 00:42:52 -05:00
|
|
|
|
|
|
|
expect(flash[:alert]).to start_with('Project could not be imported')
|
|
|
|
expect(response).to have_gitlab_http_status(302)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a valid path' do
|
|
|
|
it 'redirects to the new project path' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :create, params: { namespace_id: namespace.id, path: 'test', file: file }
|
2018-01-04 00:42:52 -05:00
|
|
|
|
|
|
|
expect(flash[:notice]).to include('is being imported')
|
|
|
|
expect(response).to have_gitlab_http_status(302)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|