fix regression in visible notification detection
This commit is contained in:
parent
4c4b20574d
commit
9f88d6e252
|
@ -9,7 +9,8 @@ class Notification < ActiveRecord::Base
|
|||
|
||||
scope :unread, lambda { where(read: false) }
|
||||
scope :recent, lambda { |n=nil| n ||= 10; order('notifications.created_at desc').limit(n) }
|
||||
scope :visible , lambda { joins('LEFT JOIN topics ON notifications.topic_id = topics.id AND topics.deleted_at IS NULL') }
|
||||
scope :visible , lambda { joins('LEFT JOIN topics ON notifications.topic_id = topics.id')
|
||||
.where('topics.id IS NULL OR topics.deleted_at IS NULL') }
|
||||
|
||||
after_save :refresh_notification_count
|
||||
after_destroy :refresh_notification_count
|
||||
|
|
|
@ -277,6 +277,13 @@ describe Notification do
|
|||
fab(Notification.types[:liked], true)
|
||||
end
|
||||
|
||||
it 'correctly finds visible notifications' do
|
||||
pm
|
||||
expect(Notification.visible.count).to eq(1)
|
||||
post.topic.trash!
|
||||
expect(Notification.visible.count).to eq(0)
|
||||
end
|
||||
|
||||
it 'orders stuff correctly' do
|
||||
a = unread_pm
|
||||
regular
|
||||
|
|
Loading…
Reference in New Issue