Sha256: 5ca954facf9c082409006ca705e8a250ac473c7a175b7da66c1b0b612a00b40f

Contents?: true

Size: 1.84 KB

Versions: 6

Compression:

Stored size: 1.84 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

module Gritano::Core
  describe Repository do
    
    before(:each) do
      Grit::Repo.stub(:init_bare)
    end

    it "should be invalid without a name" do
      Repository.new(path: 'path/to/some/folder').should be_invalid
    end

    it "should be invalid without a path" do
      Repository.new(name: 'my_repo.git').should be_invalid
    end

    it "should have a unique name" do
      Repository.create(name: 'my_repo.git', path: 'path/to/some/folder')
      Repository.new(name: 'my_repo.git', path: 'path/to/some/folder').should be_invalid
    end

    it "should have a name that ends with '.git'" do
      Repository.new(name: 'my_repo', path: 'path/to/some/folder').should be_invalid
    end

    it "can have users" do
      repo = Repository.create(name: 'my_repo.git', path: 'path/to/some/folder')

      contributor1 = User.create(login: 'jessicaeto')
      contributor2 = User.create(login: 'arybonadio')
      repo.permissions.create(user_id: contributor1.id, access: 0)
      repo.permissions.create(user_id: contributor2.id, access: 0)
      repo.users.count.should be == 2
    end

    it "should return its full path" do
      repo = Repository.create(name: 'my_repo.git', path: 'path/to/some/folder')
      repo.full_path.should be == "path/to/some/folder/my_repo.git"
    end

    it "should create a bare repo when it is created" do
      Grit::Repo.should_receive(:init_bare).with('path/to/some/folder/my_repo.git')
      Repository.create(name: 'my_repo.git', path: 'path/to/some/folder')
    end

    it "should remove the bare repo when it is destroyed" do
      repo = Repository.create(name: 'my_repo.git', path: 'path/to/some/folder')
      FileUtils.should_receive(:rm_r).with('path/to/some/folder/my_repo.git', force: true)
      repo.destroy.should be_true
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gritano-core-2.0.2 spec/repository_spec.rb
gritano-core-2.0.1 spec/repository_spec.rb
gritano-core-2.0.0 spec/repository_spec.rb
gritano-core-1.1.2 spec/repository_spec.rb
gritano-core-1.1.1 spec/repository_spec.rb
gritano-core-1.1.0 spec/repository_spec.rb