Restructure omni services and add Chatwoot research snapshot

This commit is contained in:
Ruslan Bakiev
2026-02-21 11:11:27 +07:00
parent edea7a0034
commit b73babbbf6
7732 changed files with 978203 additions and 32 deletions

View File

@@ -0,0 +1,65 @@
require 'rails_helper'
RSpec.describe ConversationPolicy, type: :policy do
subject { described_class }
let(:account) { create(:account) }
let(:agent) { create(:user, account: account, role: :agent) }
let(:inbox) { create(:inbox, account: account) }
let(:agent_account_user) { agent.account_users.find_by(account: account) }
let(:context) { { user: agent, account: account, account_user: agent_account_user } }
before do
create(:inbox_member, user: agent, inbox: inbox)
end
permissions :show? do
context 'when role grants conversation_unassigned_manage' do
let(:custom_role) { create(:custom_role, account: account, permissions: ['conversation_unassigned_manage']) }
before do
agent_account_user.update!(role: :agent, custom_role: custom_role)
end
it 'allows access to conversations assigned to the agent' do
conversation = create(:conversation, account: account, inbox: inbox, assignee: agent)
expect(subject).to permit(context, conversation)
end
it 'denies access to conversations assigned to someone else' do
other_agent = create(:user, account: account, role: :agent)
conversation = create(:conversation, account: account, inbox: inbox, assignee: other_agent)
expect(subject).not_to permit(context, conversation)
end
end
context 'when role grants conversation_participating_manage' do
let(:custom_role) { create(:custom_role, account: account, permissions: ['conversation_participating_manage']) }
before do
agent_account_user.update!(role: :agent, custom_role: custom_role)
end
it 'allows access to conversations assigned to the agent' do
conversation = create(:conversation, account: account, inbox: inbox, assignee: agent)
expect(subject).to permit(context, conversation)
end
it 'allows access to conversations where the agent is a participant' do
conversation = create(:conversation, account: account, inbox: inbox, assignee: nil)
create(:conversation_participant, conversation: conversation, account: account, user: agent)
expect(subject).to permit(context, conversation)
end
it 'denies access to unrelated conversations' do
conversation = create(:conversation, account: account, inbox: inbox, assignee: nil)
expect(subject).not_to permit(context, conversation)
end
end
end
end