chore: self-assign conversation activity message (#1293)
This commit is contained in:
@@ -210,6 +210,7 @@ class Conversation < ApplicationRecord
|
|||||||
def create_assignee_change(user_name)
|
def create_assignee_change(user_name)
|
||||||
params = { assignee_name: assignee&.available_name, user_name: user_name }.compact
|
params = { assignee_name: assignee&.available_name, user_name: user_name }.compact
|
||||||
key = assignee_id ? 'assigned' : 'removed'
|
key = assignee_id ? 'assigned' : 'removed'
|
||||||
|
key = 'self_assigned' if self_assign? assignee_id
|
||||||
content = I18n.t("conversations.activity.assignee.#{key}", **params)
|
content = I18n.t("conversations.activity.assignee.#{key}", **params)
|
||||||
|
|
||||||
messages.create(activity_message_params(content))
|
messages.create(activity_message_params(content))
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ en:
|
|||||||
resolved: "Conversation was marked resolved by %{user_name}"
|
resolved: "Conversation was marked resolved by %{user_name}"
|
||||||
open: "Conversation was reopened by %{user_name}"
|
open: "Conversation was reopened by %{user_name}"
|
||||||
assignee:
|
assignee:
|
||||||
|
self_assigned: "%{user_name} self-assigned this conversation"
|
||||||
assigned: "Assigned to %{assignee_name} by %{user_name}"
|
assigned: "Assigned to %{assignee_name} by %{user_name}"
|
||||||
removed: "Conversation unassigned by %{user_name}"
|
removed: "Conversation unassigned by %{user_name}"
|
||||||
templates:
|
templates:
|
||||||
|
|||||||
@@ -182,6 +182,17 @@ RSpec.describe Conversation, type: :model do
|
|||||||
expect(update_assignee).to eq(true)
|
expect(update_assignee).to eq(true)
|
||||||
expect(agent.notifications.count).to eq(0)
|
expect(agent.notifications.count).to eq(0)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe '#toggle_status' do
|
describe '#toggle_status' do
|
||||||
|
|||||||
Reference in New Issue
Block a user