mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 02:32:29 +00:00
fix: Update the label name to use .strip to avoid unnecessary whitespace characters (#8541)
- The cache stores the labels as label1, label2. Without removing the whitespace, the output of cached_label_list_array would be [label1, [whitespace]label2], which doesn't match with the existing labels. This list is returned with proper label names.
This commit is contained in:
@@ -183,7 +183,7 @@ class Conversation < ApplicationRecord
|
||||
end
|
||||
|
||||
def cached_label_list_array
|
||||
(cached_label_list || '').split(',')
|
||||
(cached_label_list || '').split(',').map(&:strip)
|
||||
end
|
||||
|
||||
def notifiable_assignee_change?
|
||||
|
||||
@@ -831,4 +831,14 @@ RSpec.describe Conversation do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'cached_label_list_array' do
|
||||
let(:conversation) { create(:conversation) }
|
||||
|
||||
it 'returns the correct list of labels' do
|
||||
conversation.update(label_list: %w[customer-support enterprise paid-customer])
|
||||
|
||||
expect(conversation.cached_label_list_array).to eq %w[customer-support enterprise paid-customer]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user