# rubocop:disable all require 'test_helper' class AaaStringTest < ActiveSupport::TestCase test 'strip' do raw = ' test ' result = 'test' assert_equal(raw.strip, result) raw = "test\n" result = 'test' assert_equal(raw.strip, result) raw = " test \n test " result = "test \n test" assert_equal(raw.strip, result) raw = " \r\n test \u{200B} \n test\u{200B} \u{200B}" result = "test \u{200B} \n test" assert_equal(raw.strip, result) raw = "\xC2\xA92011 Z ".force_encoding('ASCII-8BIT') result = "\xC2\xA92011 Z".force_encoding('ASCII-8BIT') assert_equal(raw.strip, result) end test 'strip!' do raw = ' test ' result = 'test' raw.strip! assert_equal(raw, result) raw = "test\n" result = 'test' raw.strip! assert_equal(raw, result) raw = " test \n test " result = "test \n test" raw.strip! assert_equal(raw, result) raw = " \r\n test \u{200B} \n test\u{200B} \u{200B}" result = "test \u{200B} \n test" raw.strip! assert_equal(raw, result) raw = "\xC2\xA92011 Z ".force_encoding('ASCII-8BIT') result = "\xC2\xA92011 Z".force_encoding('ASCII-8BIT') raw.strip! assert_equal(raw, result) end test 'to_filename ref' do modul = 'test' result = 'test' modul.to_filename assert_equal(result, modul) modul = 'Some::File' result = 'Some::File' modul.to_filename assert_equal(result, modul) end test 'to_filename function' do modul = 'test' result = 'test' assert_equal(result, modul.to_filename) modul = 'Some::File' result = 'some/file' assert_equal(result, modul.to_filename) end test 'to_classname ref' do modul = 'test' result = 'test' modul.to_filename assert_equal(result, modul) modul = 'some/file' result = 'some/file' modul.to_filename assert_equal(result, modul) end test 'to_classname function' do modul = 'test' result = 'Test' assert_equal(result, modul.to_classname) modul = 'some/file' result = 'Some::File' assert_equal(result, modul.to_classname) modul = 'some/files' result = 'Some::Files' assert_equal(result, modul.to_classname) modul = 'some_test/files' result = 'SomeTest::Files' assert_equal(result, modul.to_classname) end test 'html2text ref' do html = 'test' result = 'test' html.html2text assert_equal(result, html) html = '
test\n\ntest" result = "test\ntest" assert_equal(result, html.html2text) html = "
test\n\ntest
"
result = "test\ntest"
assert_equal(result, html.html2text)
html = 'test | col |
test | 4711 |
Was\nsoll verbessert werden:
" result = 'Was soll verbessert werden:' assert_equal(result, html.html2text) html = "
Hello Martin, Hello Martin, '
html.html2html_strict
assert_equal(result, html.html2html_strict)
html = 'Hello Martin, Hello Martin, '
assert_equal(result, html.html2html_strict)
html = 'Hello Martin, \n "
assert_equal(result, html.html2html_strict)
html = ''
result = ''
assert_equal(result, html.html2html_strict)
html = 'Hello Martin, abc '
result = 'abc '
assert_equal(result, html.html2html_strict)
html = 'abc ' result = ' abc '
assert_equal(result, html.html2html_strict)
html = 'abc abc
' result = ' ' assert_equal(result, html.html2html_strict) html = '
' result = '' assert_equal(result, html.html2html_strict) html = ' lala '
result = "Hello Martin, lala "
html.html2html_strict
assert_equal(result, html.html2html_strict)
html = 'Hello Martin, Hello Martin, ' result = 'Hello Martin, ' assert_equal(result, html.html2html_strict) html = 'Guten Morgen, Frau ABC, vielen Dank für die Reservierung. Dabei allerdings die Sprache (Niederländisch) nicht erwähnt. Können Sie bitte dieses in Ihrer Reservierung vormerken? Nochmals vielen Dank und herzliche Grüße
Anna Smith art abc SEV GmbH art abc TRAV Marktstätte 123 123456 Dorten T: +49 (0) 12345/1234560-1 T: +49 (0) 12345/1234560-0 F: +49 (0) 12345/1234560-2 Geschäftsführer Vor Nach, VorUndZu Nach - Amtsgericht Dort HRB 12345 - Ein Unternehmer der ABC Gruppe \n "
assert_equal(result, html.html2html_strict)
html = 'Guten Morgen, Frau ABC,
vielen Dank für die Reservierung. Dabei allerdings die Sprache (Niederländisch) nicht erwähnt. Können Sie bitte dieses in Ihrer Reservierung vormerken?
Nochmals vielen Dank und herzliche Grüße
Anna Smith art abc SEV GmbH art abc TRAV Marktstätte 123 123456 Dorten T: +49 (0) 12345/1234560-1 T: +49 (0) 12345/1234560-0 F: +49 (0) 12345/1234560-2 annad@example.com Geschäftsführer Vor Nach, VorUndZu Nach - Amtsgericht Dort HRB 12345 - Ein Unternehmer der ABC Gruppe Von: Besucherbüro, MKuk [mailto:besucherbuero@example.com] Reservierungsbestätigung Führung Skulptur-Projekte 2017 am
Guten Morgen Frau Epalza,
Von: Besucherbüro, MKuk [besucherbuero@example.com]
Reservierungsbestätigung Führung Skulptur-Projekte 2017 am
Guten Morgen Frau Epalza, ' assert_equal(result, html.html2html_strict) html = 'Hello Martin, '
result = 'Hello Martin, '
assert_equal(result, html.html2html_strict)
html = 'john.smith@example.com'
result = 'john.smith@example.com'
assert_equal(result, html.html2html_strict)
html = 'john.smith@example.com'
result = 'john.smith@example.com'
assert_equal(result, html.html2html_strict)
html = 'john.smith@example.com'
#result = 'john.smith@example.com (mailto:john.smith2@example.com)'
result = 'john.smith2@example.com'
assert_equal(result, html.html2html_strict)
html = ''
result = ''
assert_equal(result, html.html2html_strict)
html = ''
result = ''
assert_equal(result, html.html2html_strict)
html = ''
result = ''
assert_equal(result, html.html2html_strict)
html = ''
result = ''
assert_equal(result, html.html2html_strict)
html = ''
result = ''
assert_equal(result, html.html2html_strict)
html = ''
result = ''
assert_equal(result, html.html2html_strict)
html = 'Wir brauchen also die Instanz example.zammad.com, kann die aber nicht mehr nutzen. Bitte um Freischaltung. '
result = ' "
assert_equal(result, source.signature_identify('text', true))
# de
source = "test 123 \n\n--no not match--\n\nBob Smith\nVon: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nGesendet: Donnerstag, 2. April 2015 10:00\nBetreff: lalala\n"
result = "test 123 \n\n--no not match--\n\nBob Smith\n#{marker_template}Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nGesendet: Donnerstag, 2. April 2015 10:00\nBetreff: lalala\n"
assert_equal(result, source.signature_identify('text', true))
# fr
source = "\ntest 123 \n\n--no not match--\n\nBob Smith\nDe : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nEnvoyé : mercredi 29 avril 2015 17:31\nObjet : lalala\n"
result = "\ntest 123 \n\n--no not match--\n\nBob Smith\n#{marker_template}De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nEnvoyé : mercredi 29 avril 2015 17:31\nObjet : lalala\n"
assert_equal(result, source.signature_identify('text', true))
marker_template = ''
html = "lalalaWir brauchen also die Instanz example.zammad.com, kann die aber nicht mehr nutzen. Bitte um Freischaltung. oh jeee … Zauberwort vergessen ;-) Können Sie mir
bitte noch meine Testphase verlängern? oh jeee … Zauberwort vergessen ;-) Können Sie mir bitte noch meine Testphase verlängern? ' assert_equal(result, html.html2html_strict) html = '' result = '' assert_equal(result, html.html2html_strict) html = '
20-29 200 -1 201 country Target (gross) Remaining Recruits Total Recruits
20-29 200 |
-1 |
201 |
|
|
country
Target (gross) Remaining Recruits Total Recruits Dear Bob:Mr/Mrs We are one of the leading manufacturer and supplier of conduits and cars since 3000. Could you inform me the specification you need? May I sent you our products catalogues for your reference? Best regards! Welcome to our booth B11/1 Hall 13 during SOMEWHERE\n9999. Bob Smith Exp. & Imp. Town Example Electric Co., Ltd. Tel: 0000-11-12345678 (Ext-220) Fax: 0000-11-12345678 Room1234, NO. 638, Smith Road, Town, 200000, Somewhere Web: www.example.com \n "
assert_equal(result, html.html2html_strict)
html = 'Dear Bob:Mr/Mrs We are one of the leading manufacturer and supplier of conduits and cars since 3000. Could you inform me the specification you need? May I sent you our products catalogues for your reference? Best regards! Welcome to our booth B11/1 Hall 13 during SOMEWHERE 9999. \n Bob Smith \n Exp. & Imp. Town Example Electric Co., Ltd. Tel: 0000-11-12345678 (Ext-220) Fax: 0000-11-12345678 Room1234, NO. 638, Smith Road, Town, 200000, Somewhere Web: www.example.com 123 \s+ "
result = "test 123 \n\n--no not match--\n\nBob Smith\n#{marker_template}From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nSent: Donnerstag, 2. April 2015 10:00\nlalala123<\/p>\s+\s+<\/div>/, body)
assert(2, attachments_inline.count)
assert_equal('image1.jpeg', attachments_inline[0][:filename])
assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
assert_equal('inline', attachments_inline[0][:preferences]['Content-Disposition'])
assert_equal('image2.jpeg', attachments_inline[1][:filename])
assert_equal('image/jpeg', attachments_inline[1][:preferences]['Content-Type'])
assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[1][:preferences]['Content-ID'])
assert_equal('inline', attachments_inline[1][:preferences]['Content-Disposition'])
end
test 'set dynamic image size' do
html = ''
body = HtmlSanitizer.dynamic_image_size(html)
assert_match(//, body)
html = ''
body = HtmlSanitizer.dynamic_image_size(html)
assert_match(//, body)
html = ''
body = HtmlSanitizer.dynamic_image_size(html)
assert_match(//, body)
html = ''
body = HtmlSanitizer.dynamic_image_size(html)
assert_match(//, body)
end
test 'signature_identify function' do
marker_template = '######SIGNATURE_MARKER######'
source = 'test'
result = 'test'
assert_equal(result, source.signature_identify('text', true))
source = "test\n--\nend"
result = "test\n#{marker_template}--\nend"
assert_equal(result, source.signature_identify('text', true))
source = "On 01/04/15 10:55, Bob Smith wrote:"
result = "#{marker_template}On 01/04/15 10:55, Bob Smith wrote:"
assert_equal(result, source.signature_identify('text', true))
source = "Am 03.04.2015 um 20:58 schrieb Martin Edenhofer -- Max Mix" result = "lalala#{marker_template} -- Max Mix" assert_equal(result, html.html2html_strict) marker_template = '' html = "lalala -- Max Mix" result = "lalala#{marker_template} -- Max Mix" assert_equal(result, html.html2html_strict) marker_template = '' html = "lalala -- Max Mix" result = "lalala#{marker_template} -- Max Mix" assert_equal(result, html.html2html_strict) marker_template = '' html = "lalala -- Max Mix" result = "lalala#{marker_template}-- Max Mix" assert_equal(result, html.html2html_strict) marker_template = '' html = "lalala__ Max Mix" result = "lalala#{marker_template} __ Max Mix" assert_equal(result, html.html2html_strict) html = "den. Von: Fritz Bauer [mailto:me@example.com] Gesendet: Donnerstag, 3. Mai 2012 11:51 An: John Smith Cc: Smith, John Marian; johnel.fratczak@example.com; ole.brei@example.com; Günther John | Example GmbH; bkopon@example.com; john.heisterhagen@team.example.com; sven.rocked@example.com; michael.house@example.com; tgutzeit@example.com Betreff: Re: OTRS::XXX Erweiterung - Anhänge an CI's Hello, ich versuche an den Punkten" result = "den. #{marker_template} Von: Fritz Bauer [mailto:me@example.com] Gesendet: Donnerstag, 3. Mai 2012 11:51 An: John Smith Cc: Smith, John Marian; johnel.fratczak@example.com; ole.brei@example.com; Günther John | Example GmbH; bkopon@example.com; john.heisterhagen@team.example.com; sven.rocked@example.com; michael.house@example.com; tgutzeit@example.com Betreff: Re: OTRS::XXX Erweiterung - Anhänge an CI's Hello, ich versuche an den Punkten" assert_equal(result, html.html2html_strict) html = ' Von: Martin Edenhofer via Zammad Helpdesk [mailto:support@zammad.com] Von: Martin Edenhofer via Zammad Helpdesk [mailto:support@example.com] Von:
Johanna Kiefer via Znuny Projects <projects@example.com> Von: Johanna Kiefer via Znuny Projects <projects@example.com> |