Route /filename/[commit-sha] will display specific revision of a file. Resolves #892.

This commit is contained in:
Dawa Ometto
2014-11-06 19:41:04 +01:00
parent 0965269ee9
commit 2c80db6678
3 changed files with 37 additions and 6 deletions
+11
View File
@@ -87,3 +87,14 @@ def context(*args, &block)
end
$contexts = []
# Commit file to wiki, overwriting previous versions of that file
def commit_test_file(wiki, dir, filename, ext, content)
committer = Gollum::Committer.new(wiki, :message => "Added testfile", :parent => wiki.repo.head.commit)
committer.add_to_index(dir, filename, ext, content, true)
committer.after_commit do |committer, sha|
wiki.clear_cache
committer.update_working_dir(dir, filename, ext)
end
committer.commit
end
+13
View File
@@ -542,6 +542,19 @@ context "Frontend" do
assert_match /meta name="robots" content="noindex, nofollow"/, last_response.body
end
test "show revision of specific file" do
shas = {}
["First revision of testfile", "Second revision of testfile"].each do |content|
new_commit = commit_test_file(@wiki, "revisions", "testfile", "log", content)
shas[new_commit] = content
end
shas.each do |sha, content|
get "revisions/testfile.log/#{sha}"
assert last_response.ok?
assert_match /#{content}/, last_response.body
end
end
def app
Precious::App
end