Fixes #2769 - Wrong Variable-Reference for Tags (Trigger, Scheduler).

This commit is contained in:
Rolf Schmidt 2021-05-07 14:25:31 +00:00 committed by Thorsten Eckel
parent 37d7528221
commit 396ed5d9f4
2 changed files with 30 additions and 0 deletions

View file

@ -47,6 +47,7 @@ examples how to use
# aliases # aliases
map = { map = {
'article.body' => 'article.body_as_text_with_quote.text2html', 'article.body' => 'article.body_as_text_with_quote.text2html',
'ticket.tags' => 'ticket.tag_list',
} }
if map[key] if map[key]
key = map[key] key = map[key]
@ -176,6 +177,7 @@ examples how to use
end end
def escaping(key, escape) def escaping(key, escape)
return escaping(key.join(', '), escape) if key.respond_to?(:join)
return key if escape == false return key if escape == false
return key if escape.nil? && !@escape return key if escape.nil? && !@escape

View file

@ -66,6 +66,34 @@ RSpec.describe Trigger, type: :model do
end end
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 context 'when ticket is created via Channel::EmailParser.process' do
before { create(:email_address, groups: [Group.first]) } before { create(:email_address, groups: [Group.first]) }