chore: self-assign conversation activity message (#1293)

This commit is contained in:
Abhishek 2020-10-02 03:11:23 +08:00 committed by GitHub
parent b862817b29
commit 5cd08b3f98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View file

@ -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))

View file

@ -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:

View file

@ -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