chore: self-assign conversation activity message (#1293)
This commit is contained in:
parent
b862817b29
commit
5cd08b3f98
3 changed files with 13 additions and 0 deletions
|
@ -210,6 +210,7 @@ class Conversation < ApplicationRecord
|
|||
def create_assignee_change(user_name)
|
||||
params = { assignee_name: assignee&.available_name, user_name: user_name }.compact
|
||||
key = assignee_id ? 'assigned' : 'removed'
|
||||
key = 'self_assigned' if self_assign? assignee_id
|
||||
content = I18n.t("conversations.activity.assignee.#{key}", **params)
|
||||
|
||||
messages.create(activity_message_params(content))
|
||||
|
|
|
@ -48,6 +48,7 @@ en:
|
|||
resolved: "Conversation was marked resolved by %{user_name}"
|
||||
open: "Conversation was reopened by %{user_name}"
|
||||
assignee:
|
||||
self_assigned: "%{user_name} self-assigned this conversation"
|
||||
assigned: "Assigned to %{assignee_name} by %{user_name}"
|
||||
removed: "Conversation unassigned by %{user_name}"
|
||||
templates:
|
||||
|
|
|
@ -182,6 +182,17 @@ RSpec.describe Conversation, type: :model do
|
|||
expect(update_assignee).to eq(true)
|
||||
expect(agent.notifications.count).to eq(0)
|
||||
end
|
||||
|
||||
context 'when agent is current user' do
|
||||
before do
|
||||
Current.user = agent
|
||||
end
|
||||
|
||||
it 'creates self-assigned message activity' do
|
||||
expect(update_assignee).to eq(true)
|
||||
expect(conversation.messages.pluck(:content)).to include("#{agent.available_name} self-assigned this conversation")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#toggle_status' do
|
||||
|
|
Loading…
Reference in a new issue