restore ref_map and tree_map tests
This commit is contained in:
@@ -39,7 +39,11 @@ module Gollum
|
||||
end
|
||||
|
||||
def ref_to_sha(ref)
|
||||
@ref_map[ref] ||= ref_to_sha!(ref)
|
||||
if ref =~ /^[0-9a-f]{40}$/
|
||||
ref
|
||||
else
|
||||
@ref_map[ref] ||= ref_to_sha!(ref)
|
||||
end
|
||||
end
|
||||
|
||||
def tree(ref)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
require File.join(File.dirname(__FILE__), *%w[helper])
|
||||
|
||||
context "GitAccess" do
|
||||
setup do
|
||||
@access = Gollum::GitAccess.new(testpath("examples/lotr.git"))
|
||||
end
|
||||
|
||||
test "#tree_map_for caches ref and tree" do
|
||||
assert @access.ref_map.empty?
|
||||
assert @access.tree_map.empty?
|
||||
@access.tree 'master'
|
||||
assert_equal({"master"=>"60f12f4254f58801b9ee7db7bca5fa8aeefaa56b"}, @access.ref_map)
|
||||
|
||||
map = @access.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b']
|
||||
assert_equal 'Bilbo-Baggins.md', map[0].path
|
||||
assert_equal '', map[0].dir
|
||||
assert_equal map[0].path, map[0].name
|
||||
assert_equal 'Mordor/Eye-Of-Sauron.md', map[3].path
|
||||
assert_equal '/Mordor', map[3].dir
|
||||
assert_equal 'Eye-Of-Sauron.md', map[3].name
|
||||
end
|
||||
|
||||
test "#tree_map_for only caches tree for commit" do
|
||||
assert @access.tree_map.empty?
|
||||
@access.tree '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'
|
||||
assert @access.ref_map.empty?
|
||||
|
||||
entry = @access.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'][0]
|
||||
assert_equal 'Bilbo-Baggins.md', entry.path
|
||||
end
|
||||
end
|
||||
+1
-26
@@ -2,8 +2,7 @@ require File.join(File.dirname(__FILE__), *%w[helper])
|
||||
|
||||
context "Wiki" do
|
||||
setup do
|
||||
@access = Gollum::GitAccess.new(testpath("examples/lotr.git"))
|
||||
@wiki = Gollum::Wiki.new(@access)
|
||||
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"))
|
||||
end
|
||||
|
||||
test "repo path" do
|
||||
@@ -60,30 +59,6 @@ context "Wiki" do
|
||||
assert_equal({:message => 'abc', :name => 'bob', :email => 'foo@bar.com'},
|
||||
@wiki.normalize_commit(commit.dup))
|
||||
end
|
||||
|
||||
#test "#tree_map_for caches ref and tree" do
|
||||
# assert @wiki.ref_map.empty?
|
||||
# assert @wiki.tree_map.empty?
|
||||
# @wiki.tree_map_for 'master'
|
||||
# assert_equal({"master"=>"60f12f4254f58801b9ee7db7bca5fa8aeefaa56b"}, @wiki.ref_map)
|
||||
#
|
||||
# map = @wiki.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b']
|
||||
# assert_equal 'Bilbo-Baggins.md', map[0].path
|
||||
# assert_equal '', map[0].dir
|
||||
# assert_equal map[0].path, map[0].name
|
||||
# assert_equal 'Mordor/Eye-Of-Sauron.md', map[3].path
|
||||
# assert_equal '/Mordor', map[3].dir
|
||||
# assert_equal 'Eye-Of-Sauron.md', map[3].name
|
||||
#end
|
||||
#
|
||||
#test "#tree_map_for only caches tree for commit" do
|
||||
# assert @access.tree_map.empty?
|
||||
# @access.tree '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'
|
||||
# assert @access.ref_map.empty?
|
||||
#
|
||||
# entry = @access.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'][0]
|
||||
# assert_equal 'Bilbo-Baggins.md', entry.path
|
||||
#end
|
||||
end
|
||||
|
||||
context "Wiki page previewing" do
|
||||
|
||||
Reference in New Issue
Block a user