Changeset - ac54aa4200e8
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 14 years ago 2011-11-26 22:40:41
marcin@python-works.com
fixed bug with eager deletes in notifications
- added relevant tests for that
2 files changed with 22 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/db.py
Show inline comments
 
@@ -1227,8 +1227,7 @@ class UserNotification(Base, BaseModel):
 

	
 
    user = relationship('User', lazy="joined")
 
    notification = relationship('Notification', lazy="joined",
 
                                order_by=lambda:Notification.created_on.desc(),
 
                                cascade='all')
 
                            order_by=lambda:Notification.created_on.desc(),)
 

	
 
    def mark_as_read(self):
 
        self.read = True
rhodecode/tests/test_models.py
Show inline comments
 
@@ -267,6 +267,7 @@ class TestNotifications(unittest.TestCas
 
        self.assertEqual(un, [])
 

	
 
        self._clean_notifications()
 

	
 
    def test_delete_association(self):
 

	
 
        self.assertEqual([], Notification.query().all())
 
@@ -289,13 +290,31 @@ class TestNotifications(unittest.TestCas
 
                                   notification.notification_id)
 
        Session().commit()
 

	
 
        unotification = UserNotification.query()\
 
        u3notification = UserNotification.query()\
 
                            .filter(UserNotification.notification ==
 
                                    notification)\
 
                            .filter(UserNotification.user_id == self.u3)\
 
                            .scalar()
 

	
 
        self.assertEqual(unotification, None)
 
        self.assertEqual(u3notification, None)
 

	
 
        # notification object is still there
 
        self.assertEqual(Notification.query().all(), [notification])
 

	
 
        #u1 and u2 still have assignments
 
        u1notification = UserNotification.query()\
 
                            .filter(UserNotification.notification ==
 
                                    notification)\
 
                            .filter(UserNotification.user_id == self.u1)\
 
                            .scalar()
 
        self.assertNotEqual(u1notification, None)
 
        u2notification = UserNotification.query()\
 
                            .filter(UserNotification.notification ==
 
                                    notification)\
 
                            .filter(UserNotification.user_id == self.u2)\
 
                            .scalar()
 
        self.assertNotEqual(u2notification, None)
 

	
 
        self._clean_notifications()
 

	
 
    def test_notification_counter(self):
0 comments (0 inline, 0 general)