2017-07-26 08:21:53 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::CreateFromTemplateService do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project_params) do
|
|
|
|
{
|
2018-02-14 06:50:28 -05:00
|
|
|
path: user.to_param,
|
|
|
|
template_name: 'rails',
|
|
|
|
description: 'project description',
|
2018-04-19 11:24:32 -04:00
|
|
|
visibility_level: Gitlab::VisibilityLevel::PUBLIC
|
2017-07-26 08:21:53 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { described_class.new(user, project_params) }
|
|
|
|
|
|
|
|
it 'calls the importer service' do
|
2017-08-01 08:34:11 -04:00
|
|
|
expect_any_instance_of(Projects::GitlabProjectsImportService).to receive(:execute)
|
2017-07-26 08:21:53 -04:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the project thats created' do
|
|
|
|
project = subject.execute
|
|
|
|
|
|
|
|
expect(project).to be_saved
|
2018-05-02 09:35:04 -04:00
|
|
|
expect(project.import_scheduled?).to be(true)
|
2018-04-19 11:24:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'the result project' do
|
|
|
|
before do
|
|
|
|
Sidekiq::Testing.inline! do
|
|
|
|
@project = subject.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
@project.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'overrides template description' do
|
|
|
|
expect(@project.description).to match('project description')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'overrides template visibility_level' do
|
|
|
|
expect(@project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
|
|
|
|
end
|
2017-07-26 08:21:53 -04:00
|
|
|
end
|
|
|
|
end
|