diff options
author | Rémy Coutable <remy@rymai.me> | 2017-05-10 17:19:48 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-05-18 13:04:50 +0200 |
commit | 628cc84891228895daa19d7b1300fc032cb26910 (patch) | |
tree | 09a4017fb8d14cbbeeaa970357f0d2bb46aea5d6 /spec | |
parent | a67bb1f0ede51acab88dc3a11928a6d07bd189e7 (diff) | |
download | gitlab-ce-628cc84891228895daa19d7b1300fc032cb26910.tar.gz |
Factorize TestEvent#copy_repo
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/projects.rb | 2 | ||||
-rw-r--r-- | spec/support/test_env.rb | 15 |
2 files changed, 4 insertions, 13 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 3580752a805..357ea6b3f7f 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -172,7 +172,7 @@ FactoryGirl.define do path { 'forked-gitlabhq' } after :create do |project| - TestEnv.copy_forked_repo_with_submodules(project) + TestEnv.copy_repo(project, copy_fork: true) end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 9bf9dc5d4b2..f319c9634e3 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -170,13 +170,13 @@ module TestEnv end end - def copy_repo(project) - base_repo_path = File.expand_path(factory_repo_path_bare) + def copy_repo(project, copy_fork: false) + base_repo_path = File.expand_path(copy_fork ? forked_repo_path_bare : factory_repo_path_bare) target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git") FileUtils.mkdir_p(target_repo_path) FileUtils.cp_r("#{base_repo_path}/.", target_repo_path) FileUtils.chmod_R 0755, target_repo_path - set_repo_refs(target_repo_path, BRANCH_SHA) + set_repo_refs(target_repo_path, copy_fork ? FORKED_BRANCH_SHA : BRANCH_SHA) end def repos_path @@ -191,15 +191,6 @@ module TestEnv Gitlab.config.pages.path end - def copy_forked_repo_with_submodules(project) - base_repo_path = File.expand_path(forked_repo_path_bare) - target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git") - FileUtils.mkdir_p(target_repo_path) - FileUtils.cp_r("#{base_repo_path}/.", target_repo_path) - FileUtils.chmod_R 0755, target_repo_path - set_repo_refs(target_repo_path, FORKED_BRANCH_SHA) - end - # When no cached assets exist, manually hit the root path to create them # # Otherwise they'd be created by the first test, often timing out and |