debian-mirror-gitlab/spec/controllers/import/gitlab_projects_controller_spec.rb

43 lines
1.3 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
describe Import::GitlabProjectsController do
2019-12-21 20:55:43 +05:30
let_it_be(:namespace) { create(:namespace) }
let_it_be(:user) { namespace.owner }
2018-11-20 20:47:30 +05:30
let(:file) { fixture_file_upload('spec/fixtures/project_export.tar.gz', 'text/plain') }
2018-03-17 18:26:18 +05:30
before do
sign_in(user)
end
describe 'POST create' do
context 'with an invalid path' do
it 'redirects with an error' do
2019-02-15 15:39:39 +05:30
post :create, params: { namespace_id: namespace.id, path: '/test', file: file }
2018-03-17 18:26:18 +05:30
expect(flash[:alert]).to start_with('Project could not be imported')
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:found)
2018-03-17 18:26:18 +05:30
end
it 'redirects with an error when a relative path is used' do
2019-02-15 15:39:39 +05:30
post :create, params: { namespace_id: namespace.id, path: '../test', file: file }
2018-03-17 18:26:18 +05:30
expect(flash[:alert]).to start_with('Project could not be imported')
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:found)
2018-03-17 18:26:18 +05:30
end
end
context 'with a valid path' do
it 'redirects to the new project path' do
2019-02-15 15:39:39 +05:30
post :create, params: { namespace_id: namespace.id, path: 'test', file: file }
2018-03-17 18:26:18 +05:30
expect(flash[:notice]).to include('is being imported')
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:found)
2018-03-17 18:26:18 +05:30
end
end
2020-03-13 15:44:24 +05:30
it_behaves_like 'project import rate limiter'
2018-03-17 18:26:18 +05:30
end
end