File tree 2 files changed +16
-1
lines changed 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ def after_save_post(post)
51
51
end
52
52
53
53
def unread_posts ( user , topic )
54
- Post . where ( 'post_number > COALESCE((
54
+ Post . secured ( Guardian . new ( user ) )
55
+ . where ( 'post_number > COALESCE((
55
56
SELECT last_read_post_number FROM topic_users tu
56
57
WHERE tu.user_id = ? AND tu.topic_id = ? ),0)' ,
57
58
user . id , topic . id )
Original file line number Diff line number Diff line change @@ -9,6 +9,20 @@ def create_post_with_alerts(args={})
9
9
PostAlerter . post_created ( post )
10
10
end
11
11
12
+ context "unread" do
13
+ it "does not return whispers as unread posts" do
14
+ op = Fabricate ( :post )
15
+ whisper = Fabricate ( :post , raw : 'this is a whisper post' ,
16
+ user : Fabricate ( :admin ) ,
17
+ topic : op . topic ,
18
+ reply_to_post_number : op . post_number ,
19
+ post_type : Post . types [ :whisper ] )
20
+
21
+
22
+ expect ( PostAlerter . new . first_unread_post ( op . user , op . topic ) ) . to be_blank
23
+ end
24
+ end
25
+
12
26
context 'likes' do
13
27
it 'does not double notify users on likes' do
14
28
ActiveRecord ::Base . observers . enable :all
You can’t perform that action at this time.
0 commit comments