fix: Apply filter for inbox when the user is an admin (#11197)

Optimization #11183 missed a condition where the inbox_id filter is
manually passed. Due to the previous change, the inbox filter was being
discarded for admins, although it continued to work correctly for
agents.

This PR includes a fix for that specific case and adds a spec to
explicitly test it.
This commit is contained in:
Pranav
2025-03-27 17:05:48 -07:00
committed by GitHub
parent 4b4d9f8f7c
commit 5951c4b985
2 changed files with 16 additions and 2 deletions

View File

@@ -57,6 +57,16 @@ describe ConversationFinder do
expect(result[:conversations].map(&:id)).not_to include(restricted_conversation.id)
end
it 'returns only the conversations from the inbox if inbox_id filter is passed' do
conversation = create(:conversation, account: account, inbox_id: inbox.id)
params = { inbox_id: restricted_inbox.id }
result = described_class.new(admin, params).perform
conversation_ids = result[:conversations].map(&:id)
expect(conversation_ids).not_to include(conversation.id)
expect(conversation_ids).to include(restricted_conversation.id)
end
end
context 'with assignee_type all' do