BigW Consortium Gitlab

project_creator_spec.rb 979 Bytes
Newer Older
1 2
require 'spec_helper'

Douwe Maan committed
3
describe Gitlab::GitlabImport::ProjectCreator, lib: true do
4
  let(:user) { create(:user) }
5 6 7 8 9 10 11 12 13 14
  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
15
  let(:namespace){ create(:group, owner: user) }
16 17
  let(:token) { "asdffg" }
  let(:access_params) { { gitlab_access_token: token } }
18 19 20 21

  before do
    namespace.add_owner(user)
  end
22 23

  it 'creates project' do
24
    allow_any_instance_of(Project).to receive(:add_import_job)
25

26
    project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user, access_params)
Douwe Maan committed
27
    project = project_creator.execute
28

29 30
    expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
    expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
31 32
  end
end