diff --git a/rhodecode/apps/my_account/tests/test_my_account_notifications.py b/rhodecode/apps/my_account/tests/test_my_account_notifications.py --- a/rhodecode/apps/my_account/tests/test_my_account_notifications.py +++ b/rhodecode/apps/my_account/tests/test_my_account_notifications.py @@ -155,6 +155,7 @@ class TestNotificationsController(TestCo notification = NotificationModel().create( created_by=cur_user, notification_subject=subject, notification_body=notif_body, recipients=[cur_user, u1, u2]) + Session().commit() response = self.app.get( route_path('notifications_show', diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -3909,16 +3909,18 @@ class Notification(Base, BaseModel): notification.type_ = type_ notification.created_on = datetime.datetime.now() + # For each recipient link the created notification to his account for u in recipients: assoc = UserNotification() + assoc.user_id = u.user_id assoc.notification = notification # if created_by is inside recipients mark his notification # as read if u.user_id == created_by.user_id: assoc.read = True - - u.notifications.append(assoc) + Session().add(assoc) + Session().add(notification) return notification