define TestEnv and keep all global stubs in one place

This commit is contained in:
Dmitriy Zaporozhets 2013-04-01 14:39:19 +03:00
parent 7bb71bb088
commit 22817398e6
5 changed files with 72 additions and 87 deletions

View file

@ -14,7 +14,7 @@ require 'spinach/capybara'
require 'sidekiq/testing/inline'
%w(stubbed_repository valid_commit select2_helper).each do |f|
%w(valid_commit select2_helper test_env).each do |f|
require Rails.root.join('spec', 'support', f)
end
@ -35,13 +35,8 @@ Capybara.default_wait_time = 10
DatabaseCleaner.strategy = :truncation
Spinach.hooks.before_scenario do
# Use tmp dir for FS manipulations
Gitlab.config.gitlab_shell.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path'))
Gitlab::Shell.any_instance.stub(:add_repository) do |path|
create_temp_repo("#{Rails.root}/tmp/test-git-base-path/#{path}.git")
end
FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
TestEnv.init
DatabaseCleaner.start
end
@ -54,9 +49,3 @@ Spinach.hooks.before_run do
include FactoryGirl::Syntax::Methods
end
def create_temp_repo(path)
FileUtils.mkdir_p path
command = "git init --quiet --bare #{path};"
system(command)
end