test/parser_test.rb in trac-wiki-0.3.36 vs test/parser_test.rb in trac-wiki-0.3.37

- old
+ new

@@ -11,10 +11,20 @@ parser = TracWiki.parser(options) parser.at_callback = Proc.new { |k,env| k == 'MEOW' ? 'WUF' : nil } html.should.equal parser.to_html(wiki) end + def tc_mailto(html, wiki, options = {}) + options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' }, + } + options[:allowed_schemes] = %w(http https ftp ftps mailto) + options[:template_handler] = self.method(:template_handler) + + parser = TracWiki.parser(options) + parser.at_callback = Proc.new { |k,env| k == 'MEOW' ? 'WUF' : nil } + html.should.equal parser.to_html(wiki) + end def env(wiki, var, val,options = {}) options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' }, } options[:template_handler] = self.method(:template_handler) parser = TracWiki.parser(options) parser.at_callback = Proc.new { |k,env| k == 'MEOW' ? 'HAF' : nil } @@ -181,11 +191,11 @@ "||This is ''italic''||") # table with div_around_table tc("<div class=\"table-div\"><table><tr><td>This is <em>italic</em></td>\n</tr>\n</table>\n</div>\n", - "||This is ''italic''||", div_around_table: true + "||This is ''italic''||", div_around_table: true) # Links can appear inside italic text: tc("<p>A italic link: <em><a href=\"http://example.org/\">http://example.org/</a> nice! </em></p>\n", "A italic link: ''http://example.org/ nice! ''") @@ -1329,8 +1339,15 @@ tc "<p>(ahojte:FuVx_SBpN3croY9zm4j14xVw19yIHsyZIzErSffwPpY=)</p>\n", "{{digesttest ahojte}}" tc "<p>(bhojte:iwqSnWkQXpGogNtIXpDr8TYIcwJFQTKOLQgG7b9VFVg=)</p>\n", "{{digesttest bhojte}}" tc "<p>(bhojte|ahoj=qhoj:6o2F88ZwLtQadp-8O6ArYIPcePy8_h_rg_2Fsa0EUv0=)</p>\n", "{{digesttest bhojte|ahoj=qhoj}}" tc "<p>(bhojte|ahoj=dhoj:m8afmveEhG78gsv5Pt-gJ56idfKCR10JNPr-G72Fttc=)</p>\n", "{{digesttest bhojte|ahoj=dhoj}}" tc "<p><tt>ah!@\#$%^&amp;*()[]oj</tt></p>\n", "{{!tt ah!@\#$%^&*()[]oj}}" + end + it 'should parse mailto' do + tc_mailto "<p><a href=\"mailto:vitas@matfyz.cz\">mailto:vitas@matfyz.cz</a></p>\n", "[[mailto:vitas@matfyz.cz]]\n" + tc_mailto "<p><a href=\"mailto:vitas@matfyz.cz\">vitas</a></p>\n", "[[mailto:vitas@matfyz.cz | vitas]]\n" + tc_mailto "<p><a href=\"mailto:vitas@matfyz.cz?subject=napis\">vitas</a></p>\n", "[[mailto:vitas@matfyz.cz?subject=napis | vitas]]\n" + tc_mailto "<p><a href=\"mailto:vitas@matfyz.cz?body=odpovez\">vitas</a></p>\n", "[[mailto:vitas@matfyz.cz?body=odpovez | vitas]]\n" + tc "<p><a href=\"mailto%3Avitas%40matfyz.cz\">vitas</a></p>\n", "[[mailto:vitas@matfyz.cz | vitas]]\n" end end # vim: tw=0