chore: Use full name in activity message, fix specs (#1339)

This commit is contained in:
Pranav Raj S 2020-10-14 00:16:35 +05:30 committed by GitHub
parent 4a2a309d18
commit 0bea0217b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View file

@ -41,7 +41,7 @@
size="16px" size="16px"
/> />
<div class="sender--available-name"> <div class="sender--available-name">
{{ sender.available_name || sender.name }} {{ sender.name }}
</div> </div>
</div> </div>
</div> </div>
@ -121,7 +121,7 @@ export default {
return this.data.message_type === 1 && !this.isHovered && sender return this.data.message_type === 1 && !this.isHovered && sender
? { ? {
content: `Sent by: ${sender.available_name || sender.name}`, content: `Sent by: ${sender.name}`,
classes: 'top', classes: 'top',
} }
: false; : false;

View file

@ -214,7 +214,7 @@ class Conversation < ApplicationRecord
end end
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.name, user_name: user_name }.compact
key = assignee_id ? 'assigned' : 'removed' key = assignee_id ? 'assigned' : 'removed'
key = 'self_assigned' if self_assign? assignee_id key = 'self_assigned' if self_assign? assignee_id
content = I18n.t("conversations.activity.assignee.#{key}", **params) content = I18n.t("conversations.activity.assignee.#{key}", **params)

View file

@ -90,9 +90,9 @@ RSpec.describe Conversation, type: :model do
it 'creates conversation activities' do it 'creates conversation activities' do
# create_activity # create_activity
expect(conversation.messages.pluck(:content)).to include("Conversation was marked resolved by #{old_assignee.available_name}") expect(conversation.messages.pluck(:content)).to include("Conversation was marked resolved by #{old_assignee.name}")
expect(conversation.messages.pluck(:content)).to include("Assigned to #{new_assignee.available_name} by #{old_assignee.available_name}") expect(conversation.messages.pluck(:content)).to include("Assigned to #{new_assignee.name} by #{old_assignee.name}")
expect(conversation.messages.pluck(:content)).to include("#{old_assignee.available_name} added #{label.title}") expect(conversation.messages.pluck(:content)).to include("#{old_assignee.name} added #{label.title}")
end end
end end
@ -193,7 +193,7 @@ RSpec.describe Conversation, type: :model do
it 'creates self-assigned message activity' do it 'creates self-assigned message activity' do
expect(update_assignee).to eq(true) expect(update_assignee).to eq(true)
expect(conversation.messages.pluck(:content)).to include("#{agent.available_name} self-assigned this conversation") expect(conversation.messages.pluck(:content)).to include("#{agent.name} self-assigned this conversation")
end end
end end
end end
@ -223,20 +223,20 @@ RSpec.describe Conversation, type: :model do
labels = [first_label].map(&:title) labels = [first_label].map(&:title)
expect(conversation.update_labels(labels)).to eq(true) expect(conversation.update_labels(labels)).to eq(true)
expect(conversation.label_list).to match_array(labels) expect(conversation.label_list).to match_array(labels)
expect(conversation.messages.pluck(:content)).to include("#{agent.available_name} added #{labels.join(', ')}") expect(conversation.messages.pluck(:content)).to include("#{agent.name} added #{labels.join(', ')}")
end end
it 'adds and removes previously added labels' do it 'adds and removes previously added labels' do
labels = [first_label, fourth_label].map(&:title) labels = [first_label, fourth_label].map(&:title)
expect(conversation.update_labels(labels)).to eq(true) expect(conversation.update_labels(labels)).to eq(true)
expect(conversation.label_list).to match_array(labels) expect(conversation.label_list).to match_array(labels)
expect(conversation.messages.pluck(:content)).to include("#{agent.available_name} added #{labels.join(', ')}") expect(conversation.messages.pluck(:content)).to include("#{agent.name} added #{labels.join(', ')}")
updated_labels = [second_label, third_label].map(&:title) updated_labels = [second_label, third_label].map(&:title)
expect(conversation.update_labels(updated_labels)).to eq(true) expect(conversation.update_labels(updated_labels)).to eq(true)
expect(conversation.label_list).to match_array(updated_labels) expect(conversation.label_list).to match_array(updated_labels)
expect(conversation.messages.pluck(:content)).to include("#{agent.available_name} added #{updated_labels.join(', ')}") expect(conversation.messages.pluck(:content)).to include("#{agent.name} added #{updated_labels.join(', ')}")
expect(conversation.messages.pluck(:content)).to include("#{agent.available_name} removed #{labels.join(', ')}") expect(conversation.messages.pluck(:content)).to include("#{agent.name} removed #{labels.join(', ')}")
end end
end end