summaryrefslogtreecommitdiff
path: root/spec/support/stubbed_repository.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/stubbed_repository.rb')
-rw-r--r--spec/support/stubbed_repository.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/spec/support/stubbed_repository.rb b/spec/support/stubbed_repository.rb
index 5bf3ea46099..e6e194d70f5 100644
--- a/spec/support/stubbed_repository.rb
+++ b/spec/support/stubbed_repository.rb
@@ -1,15 +1,14 @@
+require "repository"
+require "project"
+
# 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.
- Rails.root.join('tmp', 'repositories', path)
+class Project
+ def repository
+ if path == "empty" || !path
+ nil
else
- # For everything else, just give it the path to one of our real seeded
- # repos.
- Rails.root.join('tmp', 'repositories', 'gitlabhq')
+ GitLabTestRepo.new(path_with_namespace)
end
end
@@ -28,4 +27,8 @@ module StubbedRepository
end
end
-Project.send(:include, StubbedRepository)
+class GitLabTestRepo < Repository
+ def repo
+ @repo ||= Grit::Repo.new(Rails.root.join('tmp', 'repositories', 'gitlabhq'))
+ end
+end