Sha256: c93eeff7c578bfcc458cfba11d6333751de65e488fc480b18a555a8eddc27eaf

Contents?: true

Size: 1.88 KB

Versions: 7

Compression:

Stored size: 1.88 KB

Contents

# ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))

context "Wiki" do
  setup do
    @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"))
  end

  test "normalizes commit hash" do
    commit = {:message => 'abc'}
    name  = @wiki.repo.config['user.name']
    email = @wiki.repo.config['user.email']
    committer = Gollum::Committer.new(@wiki, commit)
    assert_equal name,  committer.actor.name
    assert_equal email, committer.actor.email

    commit[:name]  = 'bob'
    commit[:email] = ''
    committer = Gollum::Committer.new(@wiki, commit)
    assert_equal 'bob',  committer.actor.name
    assert_equal email, committer.actor.email

    commit[:email] = 'foo@bar.com'
    committer = Gollum::Committer.new(@wiki, commit)
    assert_equal 'bob',  committer.actor.name
    assert_equal 'foo@bar.com', committer.actor.email
  end

  test "yield after_commit callback" do
    @path = cloned_testpath('examples/lotr.git')
    yielded = nil
    begin
      wiki = Gollum::Wiki.new(@path)
      committer = Gollum::Committer.new(wiki)
      committer.after_commit do |index, sha1|
        yielded = sha1
        assert_equal committer, index
      end

      res = wiki.write_page("Gollum", :markdown, "# Gollum", 
        :committer => committer)

      assert_equal committer, res

      sha1 = committer.commit
      assert_equal sha1, yielded
    ensure
      FileUtils.rm_rf(@path)
    end
  end

  test "parents with default master ref" do
    ref = 'a8ad3c09dd842a3517085bfadd37718856dee813'
    committer = Gollum::Committer.new(@wiki)
    assert_equal ref,  committer.parents.first.sha
  end

  test "parents with custom ref" do
    ref = '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'
    @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), :ref => ref)
    committer = Gollum::Committer.new(@wiki)
    assert_equal ref,  committer.parents.first.sha
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
gollum-bibanon-1.4.4 test/test_committer.rb
gollum-bibanon-1.4.3 test/test_committer.rb
gollum-bibanon-1.4.2 test/test_committer.rb
gollum-bibanon-1.4.1 test/test_committer.rb
gollum-1.3.1 test/test_committer.rb
jugyo-gollum-1.3.1 test/test_committer.rb
gollum-1.3.0 test/test_committer.rb