From f8637ed61602bbaf19b57321d6d3402ddf36b152 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 5 Apr 2018 17:17:31 +1000 Subject: [PATCH] FIX: if a message is *partially* archived consider it not archived --- app/models/topic.rb | 34 +++++++++++++++++++++++----------- spec/models/topic_spec.rb | 9 +++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/models/topic.rb b/app/models/topic.rb index 7fbd711b3f1..abc0f5f2701 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1168,19 +1168,31 @@ SQL def message_archived?(user) return false unless user && user.id - sql = < 0 diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index a88441bb755..6a17b19bec7 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -1975,12 +1975,21 @@ describe Topic do expect(topic.message_archived?(user)).to eq(false) group = Fabricate(:group) + group2 = Fabricate(:group) + group.add(user) TopicAllowedGroup.create!(topic_id: topic.id, group_id: group.id) + TopicAllowedGroup.create!(topic_id: topic.id, group_id: group2.id) GroupArchivedMessage.create!(topic_id: topic.id, group_id: group.id) expect(topic.message_archived?(user)).to eq(true) + + # here is a pickle, we add another group, make the user a + # member of that new group... now this message is not properly archived + # for the user any more + group2.add(user) + expect(topic.message_archived?(user)).to eq(false) end it 'will trigger :topic_status_updated' do