project_creator.rb 840 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
require 'spec_helper'

describe Gitlab::GitlabImport::ProjectCreator do
  let(:user) { create(:user, gitlab_access_token: "asdffg") }
  let(:repo) {{
    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
  }
  let(:namespace){ create(:namespace) }

  it 'creates project' do
16
    allow_any_instance_of(Project).to receive(:add_import_job)
17 18 19 20 21
    
    project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user)
    project_creator.execute
    project = Project.last
    
22 23
    expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
    expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
24 25
  end
end