Sha256: 1ec10773939c2d9ac82f34aef7b9fc0b8d90e47dec9beed06a54de15a4d10c39

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe Gitolite::GitoliteAdmin do
  conf_dir   = File.join(File.dirname(__FILE__), 'fixtures', 'configs')
  repo_dir   = File.join(File.dirname(__FILE__), 'fixtures', 'gitolite-admin')

  # Rugged doesn't complain when giving nil keys for testing
  settings = {private_key: nil, public_key: nil}

  describe '#is_gitolite_admin_repo?' do
    it 'should detect a non gitolite-admin repository' do
      expect(GitoliteAdmin.is_gitolite_admin_repo?('/tmp')).to be false
    end
  end

  describe '#save' do
    it 'should commit file to gitolite-admin repository' do
      Dir.mktmpdir('gitolite-rugged-admin-repo') do |dir|

        tmp_repo = File.join(dir, "gitolite-admin")
        FileUtils.cp_r(repo_dir, tmp_repo)
        FileUtils.mv(File.join(tmp_repo, ".gitted"), File.join(tmp_repo, '.git'))

        gl_admin = GitoliteAdmin.new(tmp_repo, settings)

        c = Gitolite::Config.new(File.join(conf_dir, 'complicated.conf'))
        c.filename = 'gitolite.conf'

        gl_admin.config = c
        gl_admin.save

        new_file = File.join(tmp_repo, 'conf', c.filename)
        expect(File.file?(new_file)).to be true
        expect(IO.read(new_file)).to eq IO.read(File.join(conf_dir, 'complicated-output.conf'))
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitolite-rugged-1.2.1.pre.devel spec/gitolite_admin_spec.rb