notification_factory_template_test.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # encoding: utf-8
  2. require 'test_helper'
  3. class NotificationFactoryTemplateTest < ActiveSupport::TestCase
  4. # RSpec incoming!
  5. def described_class
  6. NotificationFactory::Template
  7. end
  8. test 'regular browser html' do
  9. # ensures https://github.com/zammad/zammad/issues/385
  10. template_before = '<%= d "#{<a href="http://ticket.id" title="http://ticket.id" target="_blank">ticket.id</a>}" %>'
  11. template_after = '<%= d "ticket.id" %>'
  12. result = described_class.new(template_before).to_s
  13. assert_equal(template_after, result)
  14. end
  15. test 'spaced browser html' do
  16. # ensures https://github.com/zammad/zammad/issues/385
  17. template_before = '<%= d "#{ <a href="http://ticket.id" title="http://ticket.id" target="_blank">ticket.id </a>} " %>'
  18. template_after = '<%= d "ticket.id " %>'
  19. result = described_class.new(template_before).to_s
  20. assert_equal(template_after, result)
  21. end
  22. test 'broken browser html' do
  23. # ensures https://github.com/zammad/zammad/issues/385
  24. template_before = '<%= d "#{<a href="http://ticket.id" title="http://ticket.id" target="_blank">ticket.id }" %>'
  25. template_after = '<%= d "ticket.id " %>'
  26. result = described_class.new(template_before).to_s
  27. assert_equal(template_after, result)
  28. end
  29. test 'empty tag' do
  30. template_before = '<%= d "#{}" %>'
  31. template_after = '<%= d "#{}" %>'
  32. result = described_class.new(template_before).to_s
  33. assert_equal(template_after, result)
  34. end
  35. test 'empty tag with space' do
  36. template_before = '<%= d "#{ }" %>'
  37. template_after = '<%= d "#{ }" %>'
  38. result = described_class.new(template_before).to_s
  39. assert_equal(template_after, result)
  40. end
  41. end