Sha256: cacbfc21614059375fe698ba9f304f9e5efc8b06e6211fb497ad8b37a1c6b607

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'
require 'fakefs/spec_helpers'

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.pre.devel spec/gitolite_admin_spec.rb