@@ -60,7 +60,7 @@ def assert_reminder_not_created
6060
6161 expect ( topic . topic_allowed_users . pluck ( :user_id ) ) . to contain_exactly ( system . id , user . id )
6262
63- expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 3 ) )
63+ expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 2 ) )
6464
6565 expect ( post . raw ) . to include ( @post1 . topic . fancy_title )
6666 expect ( post . raw ) . to include ( @post2 . topic . fancy_title )
@@ -119,6 +119,41 @@ def assert_reminder_not_created
119119 expect ( reminders_count ) . to eq ( 2 )
120120 end
121121
122+ it "doesn't leak assigned topics that were moved to PM" do
123+ # we already add a fail to assign when the assigned user cannot view the pm
124+ # so we don't need to test that here
125+ # but if we move a topic to a PM that the user can't see, we should not
126+ # include it in the reminder
127+ post = Fabricate ( :post )
128+ Assigner . new ( post . topic , user ) . assign ( user )
129+ post . topic . update ( archetype : Archetype . private_message , category : nil )
130+ reminder . remind ( user )
131+
132+ post = Post . last
133+ topic = post . topic
134+ expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 2 ) )
135+ expect ( post . raw ) . to include ( @post1 . topic . fancy_title )
136+ expect ( post . raw ) . to include ( @post2 . topic . fancy_title )
137+
138+ expect ( post . raw ) . to_not include ( post . topic . fancy_title )
139+ end
140+
141+ it "reminds about PMs" do
142+ pm = Fabricate ( :private_message_topic , user : user )
143+ Fabricate ( :post , topic : pm )
144+
145+ Assigner . new ( pm , user ) . assign ( user )
146+ reminder . remind ( user )
147+
148+ post = Post . last
149+ topic = post . topic
150+
151+ expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 3 ) )
152+ expect ( post . raw ) . to include ( @post1 . topic . fancy_title )
153+ expect ( post . raw ) . to include ( @post2 . topic . fancy_title )
154+ expect ( post . raw ) . to include ( pm . fancy_title )
155+ end
156+
122157 it "closed topics aren't included as active assigns" do
123158 SiteSetting . unassign_on_close = true
124159
@@ -130,7 +165,7 @@ def assert_reminder_not_created
130165 post = Post . last
131166 topic = post . topic
132167
133- expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 4 ) )
168+ expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 3 ) )
134169
135170 @post5 . topic . update_status ( "closed" , true , Discourse . system_user )
136171 expect ( @post5 . topic . closed ) . to eq ( true )
@@ -140,7 +175,7 @@ def assert_reminder_not_created
140175 post = Post . last
141176 topic = post . topic
142177
143- expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 3 ) )
178+ expect ( topic . title ) . to eq ( I18n . t ( "pending_assigns_reminder.title" , pending_assignments : 2 ) )
144179 end
145180
146181 context "with assigns_reminder_assigned_topics_query modifier" do
@@ -162,7 +197,7 @@ def assert_reminder_not_created
162197 context "with assigned_count_for_user_query modifier" do
163198 let ( :modifier_block ) { Proc . new { |query , user | query . where . not ( assigned_to_id : user . id ) } }
164199 it "updates the query correctly" do
165- expect ( reminder . send ( :assigned_count_for , user ) ) . to eq ( 3 )
200+ expect ( reminder . send ( :assigned_count_for , user ) ) . to eq ( 2 )
166201
167202 plugin_instance = Plugin ::Instance . new
168203 plugin_instance . register_modifier ( :assigned_count_for_user_query , &modifier_block )
0 commit comments