Improved App.Utils.replaceTags() - undefined and null values.

This commit is contained in:
Martin Edenhofer 2016-05-06 12:34:04 +02:00
parent dc8d8b9786
commit 41f97d6f50
3 changed files with 35 additions and 2 deletions

View file

@ -464,7 +464,7 @@ class App.Utils
break
if typeof dataRef is 'function'
value = dataRef()
else if dataRef.toString
else if dataRef isnt undefined && dataRef isnt null && dataRef.toString
value = dataRef.toString()
else
value = ''

View file

@ -898,6 +898,39 @@ test("check replace tags", function() {
verify = App.Utils.replaceTags(message, data)
equal(verify, result)
message = "<div>#{user.firstname} #{not.existing.test}</div>"
result = '<div>Bob -</div>'
data = {
user: {
firstname: 'Bob',
},
}
verify = App.Utils.replaceTags(message, data)
equal(verify, result)
message = "<div>#{user.firstname} #{not.existing.test}</div>"
result = '<div>Bob -</div>'
data = {
user: {
firstname: 'Bob',
not: null,
},
}
verify = App.Utils.replaceTags(message, data)
equal(verify, result)
message = "<div>#{user.firstname} #{not.existing.test}</div>"
result = '<div>Bob -</div>'
data = {
user: {
firstname: 'Bob',
not: {},
},
}
verify = App.Utils.replaceTags(message, data)
equal(verify, result)
});
// check if last line is a empty line

View file

@ -140,7 +140,7 @@ class AgentTicketActionLevel0Test < TestCase
watch_for(
browser: browser2,
css: '.active div[data-name=body]',
value: 'some content ' + random,
value: 'some content -' + random,
)
ticket_customer_select(