2015-04-03 12:13:21 +01:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class RenderingHelperTest < ActionView::TestCase
|
|
|
|
include RenderingHelper
|
|
|
|
|
2017-03-05 15:10:51 +01:00
|
|
|
test "textile markup" do
|
|
|
|
actual = render_text("This is *strong*.")
|
|
|
|
assert_equal("<p>This is <strong>strong</strong>.</p>", actual)
|
|
|
|
end
|
2015-04-03 12:13:21 +01:00
|
|
|
|
2017-03-05 15:10:51 +01:00
|
|
|
test "onenote link" do
|
|
|
|
url = 'onenote:///E:\OneNote\dir\notes.one#PAGE§ion-id={FD597D3A-3793-495F-8345-23D34A00DD3B}&page-id={1C95A1C7-6408-4804-B3B5-96C28426022B}&end'
|
|
|
|
actual = render_text(url)
|
|
|
|
expected = '<p>onenote:///E:\OneNote\dir\notes.one#<span class="caps">PAGE</span>&section-id={FD597D3A-3793-495F-8345-23D34A00DD3B}&page-id={1C95A1C7-6408-4804-B3B5-96C28426022B}&end</p>'
|
|
|
|
assert_equal(expected, actual)
|
2015-04-03 12:13:21 +01:00
|
|
|
end
|
|
|
|
|
2017-03-05 15:10:51 +01:00
|
|
|
test "textile onenote link" do
|
|
|
|
url = '"link me to onenote":onenote://foo/bar'
|
|
|
|
actual = render_text(url)
|
|
|
|
expected = '<p><a href="onenote://foo/bar">link me to onenote</a></p>'
|
|
|
|
assert_equal(expected, actual)
|
2015-04-03 12:13:21 +01:00
|
|
|
end
|
|
|
|
|
2017-03-05 15:10:51 +01:00
|
|
|
test "tagged onenote link" do
|
|
|
|
actual = render_text('Link to onenote <a href="onenote://foobar">here</a>.')
|
|
|
|
assert_equal('<p>Link to onenote <a href="onenote://foobar">here</a>.</p>', actual)
|
|
|
|
end
|
2015-04-03 12:13:21 +01:00
|
|
|
|
2017-03-05 15:10:51 +01:00
|
|
|
test "message link" do
|
2022-01-03 22:12:45 +02:00
|
|
|
expected = '<p>Call <a href="message://<123>">message://<123></a>.</p>'
|
2017-03-05 15:10:51 +01:00
|
|
|
actual = render_text("Call message://<123>.")
|
2019-05-13 18:59:39 +02:00
|
|
|
assert_equal(expected, actual)
|
2017-03-05 15:10:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
test "tagged message link" do
|
2019-05-13 18:59:39 +02:00
|
|
|
expected = '<p>This message is already tagged: <a href="message://%3C12345%3E">Call bob</a>.</p>'
|
2017-03-05 15:10:51 +01:00
|
|
|
actual = render_text(expected)
|
|
|
|
assert_equal(expected, actual)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "http link (in new window)" do
|
|
|
|
actual = render_text("A link to http://github.com/.")
|
|
|
|
expected = '<p>A link to <a target="_blank" href="http://github.com/">http://github.com/</a>.</p>'
|
|
|
|
assert_equal(expected, actual)
|
|
|
|
end
|
|
|
|
|
2017-03-05 15:18:46 +01:00
|
|
|
test "http link (with double hyphens)" do
|
2017-03-19 14:13:26 -04:00
|
|
|
skip("see issue #2056")
|
|
|
|
|
|
|
|
actual = render_text("http://foo.bar/foo--bar")
|
|
|
|
expected = '<p><a target="_blank" href="http://foo.bar/foo--bar">http://foo.bar/foo--bar</a></p>'
|
|
|
|
assert_equal(expected, actual)
|
2017-03-05 15:18:46 +01:00
|
|
|
end
|
|
|
|
|
2017-03-05 15:10:51 +01:00
|
|
|
test "textile http link" do
|
|
|
|
actual = render_text('A link to "GitHub":http://github.com/.')
|
|
|
|
expected = '<p>A link to <a href="http://github.com/">GitHub</a>.</p>'
|
|
|
|
assert_equal(expected, actual)
|
|
|
|
end
|
2015-04-03 12:13:21 +01:00
|
|
|
|
2017-03-05 15:18:46 +01:00
|
|
|
test "textile http link (in new window)" do
|
2017-03-19 14:13:26 -04:00
|
|
|
skip("see issue #2066")
|
|
|
|
|
|
|
|
actual = render_text('A link to "GitHub":http://github.com/.')
|
|
|
|
expected = '<p>A link to <a target="_blank" href="http://github.com/">GitHub</a>.</p>'
|
|
|
|
assert_equal(expected, actual)
|
2017-03-05 15:18:46 +01:00
|
|
|
end
|
|
|
|
|
2017-03-05 15:10:51 +01:00
|
|
|
test "url with slash in query string" do
|
|
|
|
# See http://blog.swivel.com/code/2009/06/rails-auto_link-and-certain-query-strings.html
|
|
|
|
actual = render_text("foo http://example.com/foo?bar=/baz bar")
|
|
|
|
expected = '<p>foo <a target="_blank" href="http://example.com/foo?bar=/baz">http://example.com/foo?bar=/baz</a> bar</p>'
|
|
|
|
assert_equal(expected, actual)
|
2015-04-03 12:13:21 +01:00
|
|
|
end
|
|
|
|
end
|