Browse Source

Fixed a bug when deleting the latest topic in a forum

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

+ 3 - 0
flaskbb/forum/models.py

@@ -538,6 +538,9 @@ class Topic(db.Model):
             except IndexError:
                 self.forum.last_post_id = 0
 
+            # Commit the changes
+            db.session.commit()
+
         # These things needs to be stored in a variable before they are deleted
         forum = self.forum
 

+ 1 - 1
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 is None
+    assert forum.last_post_id == 0
 
 
 def test_topic_merge(topic):