diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 5243bbbd9..27bc79996 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -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? diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 0a04cd73b..f01806863 100644 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -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