From 396ed5d9f47fdcbf13ab5d4c4cbd31517dc00ec7 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Fri, 7 May 2021 14:25:31 +0000 Subject: [PATCH] Fixes #2769 - Wrong Variable-Reference for Tags (Trigger, Scheduler). --- lib/notification_factory/renderer.rb | 2 ++ spec/models/trigger_spec.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/notification_factory/renderer.rb b/lib/notification_factory/renderer.rb index 893696402..6c7086fcc 100644 --- a/lib/notification_factory/renderer.rb +++ b/lib/notification_factory/renderer.rb @@ -47,6 +47,7 @@ examples how to use # aliases map = { 'article.body' => 'article.body_as_text_with_quote.text2html', + 'ticket.tags' => 'ticket.tag_list', } if map[key] key = map[key] @@ -176,6 +177,7 @@ examples how to use end def escaping(key, escape) + return escaping(key.join(', '), escape) if key.respond_to?(:join) return key if escape == false return key if escape.nil? && !@escape diff --git a/spec/models/trigger_spec.rb b/spec/models/trigger_spec.rb index ae8ebbf67..cf0bc1eb9 100644 --- a/spec/models/trigger_spec.rb +++ b/spec/models/trigger_spec.rb @@ -66,6 +66,34 @@ RSpec.describe Trigger, type: :model do end end + context 'when ticket has tags' do + let(:tag1) { create(:'tag/item', name: 't1') } + let(:tag2) { create(:'tag/item', name: 't2') } + let(:tag3) { create(:'tag/item', name: 't3') } + let!(:ticket) do + ticket = create(:ticket) + create(:tag, o: ticket, tag_item: tag1) + create(:tag, o: ticket, tag_item: tag2) + create(:tag, o: ticket, tag_item: tag3) + ticket + end + + let(:perform) do + { + 'notification.email' => { + 'recipient' => 'ticket_customer', + 'subject' => 'foo', + 'body' => 'some body with #{ticket.tags}', # rubocop:disable Lint/InterpolationCheck + } + } + end + + it 'fires body with replaced tags' do + Observer::Transaction.commit + expect(Ticket::Article.last.body).to eq('some body with t1, t2, t3') + end + end + context 'when ticket is created via Channel::EmailParser.process' do before { create(:email_address, groups: [Group.first]) }