2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe Gitlab::GitlabImport::ProjectCreator do
|
2015-09-25 12:07:36 +05:30
|
|
|
let(:user) { create(:user) }
|
2015-09-11 14:41:01 +05:30
|
|
|
let(:repo) do
|
|
|
|
{
|
|
|
|
name: 'vim',
|
|
|
|
path: 'vim',
|
|
|
|
visibility_level: Gitlab::VisibilityLevel::PRIVATE,
|
|
|
|
path_with_namespace: 'asd/vim',
|
|
|
|
http_url_to_repo: "https://gitlab.com/asd/vim.git",
|
|
|
|
owner: { name: "john" }
|
|
|
|
}.with_indifferent_access
|
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:namespace) { create(:group) }
|
2015-09-25 12:07:36 +05:30
|
|
|
let(:token) { "asdffg" }
|
|
|
|
let(:access_params) { { gitlab_access_token: token } }
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
namespace.add_owner(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates project' do
|
2018-11-08 19:23:39 +05:30
|
|
|
expect_next_instance_of(Project) do |project|
|
|
|
|
expect(project).to receive(:add_import_job)
|
|
|
|
end
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
project_creator = described_class.new(repo, namespace, user, access_params)
|
2015-04-26 12:48:37 +05:30
|
|
|
project = project_creator.execute
|
2015-09-11 14:41:01 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
|
|
|
|
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
|
|
|
|
end
|
|
|
|
end
|