Merge pull request #3925 from tgxworld/improve_notification_count
FIX: Update all does not trigger callbacks.
This commit is contained in:
commit
f2c58d08c5
|
@ -36,6 +36,7 @@ class Notification < ActiveRecord::Base
|
|||
|
||||
def self.mark_posts_read(user, topic_id, post_numbers)
|
||||
Notification.where(user_id: user.id, topic_id: topic_id, post_number: post_numbers, read: false).update_all "read = 't'"
|
||||
user.publish_notifications_state
|
||||
end
|
||||
|
||||
def self.interesting_after(min_date)
|
||||
|
|
|
@ -222,7 +222,7 @@ describe Notification do
|
|||
end
|
||||
Notification.create!(read: true, user_id: user.id, topic_id: 2, post_number: 4, data: '{}', notification_type: 1)
|
||||
|
||||
expect(Notification.mark_posts_read(user,2,[1,2,3,4])).to eq(3)
|
||||
expect { Notification.mark_posts_read(user,2,[1,2,3,4]) }.to change { Notification.where(read: true).count }.by(3)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue