From 60dbe9d0a7583b876123c9d5442166d874b9780d Mon Sep 17 00:00:00 2001 From: "Jeong, Heon" Date: Sun, 20 May 2012 11:56:15 +0900 Subject: [PATCH] Proper last edit info but it can be slow if page modified so many times --- lib/gollum/frontend/views/page.rb | 8 ++++---- test/test_app.rb | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/gollum/frontend/views/page.rb b/lib/gollum/frontend/views/page.rb index 2fe2ab0f..401e8db8 100644 --- a/lib/gollum/frontend/views/page.rb +++ b/lib/gollum/frontend/views/page.rb @@ -14,13 +14,13 @@ module Precious end def author - return DEFAULT_AUTHOR unless @page.version - @page.version.author.name + return DEFAULT_AUTHOR if @page.versions.empty? + @page.versions[0].author.name end def date - return Time.now.strftime(DATE_FORMAT) unless @page.version - @page.version.authored_date.strftime(DATE_FORMAT) + return Time.now.strftime(DATE_FORMAT) if @page.versions.empty? + @page.versions[0].authored_date.strftime(DATE_FORMAT) end def editable diff --git a/test/test_app.rb b/test/test_app.rb index f83f9922..cba11929 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -15,7 +15,23 @@ context "Frontend" do FileUtils.rm_rf(@path) end - test "edits page" do + test "committer remains same if page didn't modified" do + @wiki.write_page('CC', :markdown, 'asdf', + { :name => "asdf", :email => "news@nomail.com" }); + + get '/CC' + assert_match /Last edited by asdf/, last_response.body + + @wiki.write_page('DD', :markdown, 'asdf', + { :name => "news", :email => "asdf@nomail.com" }); + + get '/DD' + assert_match /Last edited by news/, last_response.body + get '/CC' + assert_match /Last edited by asdf/, last_response.body + end + + test "edits page" do page_1 = @wiki.page('A') post "/edit/A", :content => 'abc', :format => page_1.format, :message => 'def'