Skip to content

Commit

Permalink
fix for wiki pages that don't have any history
Browse files Browse the repository at this point in the history
  • Loading branch information
brondsem committed Jan 2, 2025
1 parent 500e749 commit e50160c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions ForgeWiki/forgewiki/tests/functional/test_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import json

import PIL

from forgewiki.model import Page
from ming.odm.odmsession import ThreadLocalODMSession
from mock import patch
from tg import config
Expand Down Expand Up @@ -262,6 +264,20 @@ def test_page_history(self):
response.mustcontain('text1')
response.mustcontain(no='text2')

def test_page_history_missing(self):
self.app.get(h.urlquote('/wiki/tést/'))
self.app.post(
h.urlquote('/wiki/tést/update'),
params={
'title': 'tést'.encode(),
'text': 'text1',
'labels': '',
})
for snapshot in Page.query.get(title='tést').history():
snapshot.delete()
r = self.app.get(h.urlquote('/wiki/tést/'))
r.mustcontain(no='There is a newer version')

def test_page_diff(self):
self.app.post(
h.urlquote('/wiki/tést/update'),
Expand Down
2 changes: 1 addition & 1 deletion ForgeWiki/forgewiki/wiki_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def index(self, version=None, page=0, limit=None, **kw):
hide_left_bar = not (c.app.show_left_bar)
subscribed_to_page = M.Mailbox.subscribed(artifact=self.page)
latest_version = self.page.history().limit(1).first()
is_latest_version = cur == latest_version.version
is_latest_version = not latest_version or cur == latest_version.version
return dict(
page=page,
cur=cur, prev=prev, next=next,
Expand Down

0 comments on commit e50160c

Please sign in to comment.