BigW Consortium Gitlab

stubbed_repository.rb 798 Bytes
Newer Older
1 2 3
# 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
4
  def path_to_repo
5 6 7
    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.
8
      Rails.root.join('tmp', 'repositories', path)
9 10 11
    else
      # For everything else, just give it the path to one of our real seeded
      # repos.
12
      Rails.root.join('tmp', 'repositories', 'gitlabhq')
13 14 15
    end
  end

16
  def satellite
17 18 19 20 21 22 23 24 25 26 27 28 29 30
    FakeSatellite.new
  end

  class FakeSatellite
    def exists?
      true
    end

    def create
      true
    end
  end
end

31
Project.send(:include, StubbedRepository)