Make sure user has access to namespace in import tests.
This commit is contained in:
parent
9193b94ece
commit
80097606f5
|
|
@ -27,37 +27,5 @@ module Gitlab
|
||||||
repo_list.to_s.split(',').map(&:strip).reject(&:blank?)
|
repo_list.to_s.split(',').map(&:strip).reject(&:blank?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Repository = Struct.new(:full_name) do
|
|
||||||
def id
|
|
||||||
Digest::SHA1.hexdigest(full_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def namespace
|
|
||||||
segments.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def path
|
|
||||||
segments.last
|
|
||||||
end
|
|
||||||
|
|
||||||
def name
|
|
||||||
path.titleize
|
|
||||||
end
|
|
||||||
|
|
||||||
def description
|
|
||||||
""
|
|
||||||
end
|
|
||||||
|
|
||||||
def import_url
|
|
||||||
"#{GITORIOUS_HOST}/#{full_name}.git"
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def segments
|
|
||||||
full_name.split('/')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
module Gitlab
|
||||||
|
module GitoriousImport
|
||||||
|
GITORIOUS_HOST = "https://gitorious.org"
|
||||||
|
|
||||||
|
Repository = Struct.new(:full_name) do
|
||||||
|
def id
|
||||||
|
Digest::SHA1.hexdigest(full_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def namespace
|
||||||
|
segments.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def path
|
||||||
|
segments.last
|
||||||
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
path.titleize
|
||||||
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
|
def import_url
|
||||||
|
"#{GITORIOUS_HOST}/#{full_name}.git"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def segments
|
||||||
|
full_name.split('/')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -8,7 +8,11 @@ describe Gitlab::BitbucketImport::ProjectCreator do
|
||||||
is_private: true,
|
is_private: true,
|
||||||
owner: "asd"}.with_indifferent_access
|
owner: "asd"}.with_indifferent_access
|
||||||
}
|
}
|
||||||
let(:namespace){ create(:namespace) }
|
let(:namespace){ create(:group, owner: user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
namespace.add_owner(user)
|
||||||
|
end
|
||||||
|
|
||||||
it 'creates project' do
|
it 'creates project' do
|
||||||
allow_any_instance_of(Project).to receive(:add_import_job)
|
allow_any_instance_of(Project).to receive(:add_import_job)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@ describe Gitlab::GithubImport::ProjectCreator do
|
||||||
clone_url: "https://gitlab.com/asd/vim.git",
|
clone_url: "https://gitlab.com/asd/vim.git",
|
||||||
owner: OpenStruct.new(login: "john"))
|
owner: OpenStruct.new(login: "john"))
|
||||||
}
|
}
|
||||||
let(:namespace){ create(:namespace) }
|
let(:namespace){ create(:group, owner: user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
namespace.add_owner(user)
|
||||||
|
end
|
||||||
|
|
||||||
it 'creates project' do
|
it 'creates project' do
|
||||||
allow_any_instance_of(Project).to receive(:add_import_job)
|
allow_any_instance_of(Project).to receive(:add_import_job)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@ describe Gitlab::GitlabImport::ProjectCreator do
|
||||||
http_url_to_repo: "https://gitlab.com/asd/vim.git",
|
http_url_to_repo: "https://gitlab.com/asd/vim.git",
|
||||||
owner: {name: "john"}}.with_indifferent_access
|
owner: {name: "john"}}.with_indifferent_access
|
||||||
}
|
}
|
||||||
let(:namespace){ create(:namespace) }
|
let(:namespace){ create(:group, owner: user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
namespace.add_owner(user)
|
||||||
|
end
|
||||||
|
|
||||||
it 'creates project' do
|
it 'creates project' do
|
||||||
allow_any_instance_of(Project).to receive(:add_import_job)
|
allow_any_instance_of(Project).to receive(:add_import_job)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,11 @@ require 'spec_helper'
|
||||||
describe Gitlab::GitoriousImport::ProjectCreator do
|
describe Gitlab::GitoriousImport::ProjectCreator do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:repo) { Gitlab::GitoriousImport::Repository.new('foo/bar-baz-qux') }
|
let(:repo) { Gitlab::GitoriousImport::Repository.new('foo/bar-baz-qux') }
|
||||||
let(:namespace){ create(:namespace) }
|
let(:namespace){ create(:group, owner: user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
namespace.add_owner(user)
|
||||||
|
end
|
||||||
|
|
||||||
it 'creates project' do
|
it 'creates project' do
|
||||||
allow_any_instance_of(Project).to receive(:add_import_job)
|
allow_any_instance_of(Project).to receive(:add_import_job)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,11 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do
|
||||||
"repositoryUrls" => [ "https://vim.googlecode.com/git/" ]
|
"repositoryUrls" => [ "https://vim.googlecode.com/git/" ]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
let(:namespace) { create(:namespace) }
|
let(:namespace){ create(:group, owner: user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
namespace.add_owner(user)
|
||||||
|
end
|
||||||
|
|
||||||
it 'creates project' do
|
it 'creates project' do
|
||||||
allow_any_instance_of(Project).to receive(:add_import_job)
|
allow_any_instance_of(Project).to receive(:add_import_job)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue