Browse Source

last_post_id should be null if there is no last post

sh4nks 11 years ago
parent
commit
f5fc344fdc
2 changed files with 4 additions and 4 deletions
  1. 2 2
      flaskbb/forum/models.py
  2. 2 2
      tests/unit/test_forum_models.py

+ 2 - 2
flaskbb/forum/models.py

@@ -536,7 +536,7 @@ class Topic(db.Model):
             # Catch an IndexError when you delete the last topic in the forum
             # There is no second last post
             except IndexError:
-                self.forum.last_post_id = 0
+                self.forum.last_post_id = None
 
             # Commit the changes
             db.session.commit()
@@ -637,7 +637,7 @@ class Forum(db.Model):
 
         # No post found..
         else:
-            self.last_post_id = 0
+            self.last_post_id = None
 
         db.session.commit()
 

+ 2 - 2
tests/unit/test_forum_models.py

@@ -335,7 +335,7 @@ def test_topic_delete(topic):
     assert user.post_count == 0
     assert forum.topic_count == 0
     assert forum.post_count == 0
-    assert forum.last_post_id == 0
+    assert forum.last_post_id is None
 
 
 def test_topic_merge(topic):
@@ -380,7 +380,7 @@ def test_topic_move(topic):
     assert topic.move(forum_other)
 
     assert forum_old.topics == []
-    assert forum_old.last_post_id == 0
+    assert forum_old.last_post_id is None
 
     assert forum_old.topic_count == 0
     assert forum_old.post_count == 0