gitlabhq/spec/support/stubbed_repository.rb

38 lines
857 B
Ruby
Raw Normal View History

# 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.
module StubbedRepository
def path_to_repo
if new_record? || path == 'newproject'
# There are a couple Project specs and features that expect the Project's
# path to be in the returned path, so let's patronize them.
2012-09-26 20:52:01 +02:00
Rails.root.join('tmp', 'repositories', path)
else
# For everything else, just give it the path to one of our real seeded
# repos.
2012-09-26 20:52:01 +02:00
Rails.root.join('tmp', 'repositories', 'gitlabhq')
end
end
def satellite
FakeSatellite.new
end
class FakeSatellite
def exists?
true
end
def create
true
end
end
end
2012-11-23 20:31:09 +01:00
class Namespace
def ensure_dir_exist
true
end
end
Project.send(:include, StubbedRepository)