From d24cf7c8e138f2b81a31e398929fabbf57e4730b Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Sun, 14 Aug 2005 23:09:10 +0000 Subject: [PATCH] Fixed continuous revision check --- app/models/page.rb | 2 +- app/models/revision.rb | 5 ++++- test/watir/e2e.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index 97f11879..ca9c8644 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -19,7 +19,7 @@ class Page < ActiveRecord::Base # Not to record every such iteration as a new revision, if the previous revision was done # by the same author, not more than 30 minutes ago, then update the last revision instead of # creating a new one - if (revisions_size > 1) && continous_revision?(time, author) + if (revisions_size > 0) && continous_revision?(time, author) current_revision.update_attributes(:content => content, :revised_at => time) else Revision.create(:page => self, :content => content, :author => author, :revised_at => time) diff --git a/app/models/revision.rb b/app/models/revision.rb index 9eecbcf1..d02a50ca 100644 --- a/app/models/revision.rb +++ b/app/models/revision.rb @@ -9,7 +9,10 @@ class Revision < ActiveRecord::Base # TODO this method belongs in the view helpers (only views use it) def pretty_created_on - revised_on.to_date.strftime "%B %e, %Y %H:%M:%S" + # Must use DateTime because Time doesn't support %e on at least some platforms + DateTime.new( + revised_at.year, revised_at.mon, revised_at.day, revised_at.hour, revised_at.min, revised_at.sec + ).strftime "%B %e, %Y %H:%M:%S" end # Returns an array of all the WikiIncludes present in the content of this revision. diff --git a/test/watir/e2e.rb b/test/watir/e2e.rb index 0ed26e4f..e4e0a9f9 100644 --- a/test/watir/e2e.rb +++ b/test/watir/e2e.rb @@ -80,7 +80,7 @@ class E2EInstikiTest < Test::Unit::TestCase def test_00030_edit_page enter_markup('TestEditPage', 'Test Edit Page, revision 1') assert_match /Test Edit Page, revision 1/, ie.text - + # subsequent revision by the anonymous author enter_markup('TestEditPage', 'Test Edit Page, revision 1, altered') assert_match /Test Edit Page, revision 1, altered/, ie.text