gitlabhq/spec/support/stubbed_repository.rb

72 lines
1 KiB
Ruby
Raw Normal View History

2013-01-04 20:45:30 +01:00
require "repository"
require "project"
require "merge_request"
2013-02-04 17:18:36 +01:00
require "shell"
2013-01-04 20:45:30 +01:00
# 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.
2013-01-02 23:01:08 +01:00
class Project
2013-01-04 20:45:30 +01:00
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 MergeRequest
2013-02-21 11:27:52 +01:00
def check_if_can_be_merged
true
end
end
2013-01-04 20:45:30 +01:00
class GitLabTestRepo < Repository
def repo
@repo ||= Grit::Repo.new(Rails.root.join('tmp', 'repositories', 'gitlabhq'))
end
2013-03-07 10:45:44 +01:00
# patch repo size (in mb)
def size
12.45
end
end
2013-02-04 17:18:36 +01:00
module Gitlab
class Shell
def add_repository name
true
end
def remove_repository name
true
end
def add_key id, key
2013-02-04 17:18:36 +01:00
true
end
def remove_key id, key
2013-02-04 17:18:36 +01:00
true
end
end
end