FIX: correctly exclude muted channels from thread unreads (#25339)

This commit is contained in:
Joffrey JAFFEUX
2024-01-19 22:05:41 +01:00
committed by GitHub
parent a840c295d8
commit ccb5fa1a5a
3 changed files with 16 additions and 0 deletions

View File

@ -64,6 +64,14 @@ describe Chat::ThreadUnreadsQuery do
)
end
it "does not count messages in muted channels" do
channel_1.membership_for(current_user).update!(muted: true)
expect(query.map(&:to_h).find { |tracking| tracking[:thread_id] == thread_1.id }).to eq(
{ channel_id: channel_1.id, mention_count: 0, thread_id: thread_1.id, unread_count: 0 },
)
end
it "does not messages in threads where threading_enabled is false on the channel" do
channel_1.update!(threading_enabled: false)
expect(query.map(&:to_h).find { |tracking| tracking[:thread_id] == thread_1.id }).to eq(

View File

@ -33,6 +33,11 @@ RSpec.describe Chat::TrackingStateReportQuery do
fab!(:channel_2) { Fabricate(:category_channel) }
let(:channel_ids) { [channel_1.id, channel_2.id] }
before do
channel_1.add(current_user)
channel_2.add(current_user)
end
it "calls the channel unreads query with the corect params" do
Chat::ChannelUnreadsQuery
.expects(:call)