gitlabhq/spec/support/stubbed_repository.rb
2013-02-04 18:18:36 +02:00

60 lines
896 B
Ruby

require "repository"
require "project"
require "shell"
# Stubs out all Git repository access done by models so that specs can run
# against fake repositories without Grit complaining that they don't exist.
class Project
def repository
if path == "empty" || !path
nil
else
GitLabTestRepo.new(path_with_namespace)
end
end
def satellite
FakeSatellite.new
end
class FakeSatellite
def exists?
true
end
def destroy
true
end
def create
true
end
end
end
class GitLabTestRepo < Repository
def repo
@repo ||= Grit::Repo.new(Rails.root.join('tmp', 'repositories', 'gitlabhq'))
end
end
module Gitlab
class Shell
def add_repository name
true
end
def remove_repository name
true
end
def add_key name, key
true
end
def remove_key key
true
end
end
end