implement Page#versions

This commit is contained in:
Tom Preston-Werner
2010-04-11 12:17:32 -06:00
parent e3772b1879
commit 61076b38b4
3 changed files with 17 additions and 2 deletions
+2 -2
View File
@@ -250,9 +250,9 @@ Get the latest version of the given human or canonical page name:
vsn.id
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
Get a list of versions for a given canonical page name:
Get a list of versions for a given page:
vsns = gollum.page_versions('page-name')
vsns = gollum.page('page-name').versions
# => [<Gollum::Version, <Gollum::Version, <Gollum::Version>]
vsns.first.id
+9
View File
@@ -74,6 +74,15 @@ module Gollum
end
end
# All of the versions that have touched this Page.
#
# Returns an Array of Gollum::Version.
def versions
@wiki.repo.log('master', self.path).map do |v|
Version.new(v)
end
end
# Find a page in the given Gollum repo.
#
# name - The human or canonical String page name to find.
+6
View File
@@ -26,6 +26,12 @@ context "Page" do
assert_equal 'Mordor/Eye-Of-Sauron.md', page.path
end
test "page versions" do
page = @wiki.page('Bilbo Baggins')
assert_equal ['5bc1aaec6149e854078f1d0f8b71933bbc6c2e43'],
page.versions.map { |v| v.id }
end
test "no page match" do
assert_nil @wiki.page('I do not exist')
end