Fixed issue #883 - Placeholder in triggers with created_by & updated_by / > in article.body.

This commit is contained in:
Martin Edenhofer 2017-03-31 08:54:05 +02:00
parent 8c1846d7fb
commit 72c4de570e
2 changed files with 34 additions and 2 deletions

View file

@ -139,7 +139,7 @@ examples how to use
end
def data_key_valid?(key)
return false if key =~ /`|\.(|\s*)(save|destroy|delete|remove|drop|update|create|new|all|where|find)/i && key !~ /(update|create)d_at/i
return false if key =~ /`|\.(|\s*)(save|destroy|delete|remove|drop|update|create|new|all|where|find|raise|dump|rollback|freeze)/i && key !~ /(update|create)d_(at|by)/i
true
end

View file

@ -9,7 +9,7 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
end
group = Group.new(name: 'Users')
owner = User.new(firstname: 'Notification<b>xxx</b>', lastname: 'Agent1<b>yyy</b>')
owner = User.new(firstname: 'Owner<b>xxx</b>', lastname: 'Agent1<b>yyy</b>')
current_user = User.new(firstname: 'CurrentUser<b>xxx</b>', lastname: 'Agent2<b>yyy</b>')
recipient = User.new(firstname: 'Recipient<b>xxx</b>', lastname: 'Customer1<b>yyy</b>')
state = Ticket::State.new(name: 'new')
@ -19,6 +19,8 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
group: group,
owner: owner,
state: state,
created_by: current_user,
updated_by: current_user,
created_at: Time.zone.parse('2016-11-12 12:00:00 UTC'),
updated_at: Time.zone.parse('2016-11-12 14:00:00 UTC'),
)
@ -56,6 +58,16 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(ticket.created_at.to_s, result)
template = "\#{ticket.created_by.firstname}"
result = described_class.new(
{
ticket: ticket,
},
'en-us',
template,
).render
assert_equal('CurrentUser&lt;b&gt;xxx&lt;/b&gt;', result)
template = "\#{ticket.updated_at}"
result = described_class.new(
{
@ -66,6 +78,26 @@ class NotificationFactoryRendererTest < ActiveSupport::TestCase
).render
assert_equal(ticket.updated_at.to_s, result)
template = "\#{ticket.updated_by.firstname}"
result = described_class.new(
{
ticket: ticket,
},
'en-us',
template,
).render
assert_equal('CurrentUser&lt;b&gt;xxx&lt;/b&gt;', result)
template = "\#{ticket.owner.firstname}"
result = described_class.new(
{
ticket: ticket,
},
'en-us',
template,
).render
assert_equal('Owner&lt;b&gt;xxx&lt;/b&gt;', result)
template = "\#{ticket. title}"
result = described_class.new(
{