diff options
Diffstat (limited to 'actionpack/test/template/text_helper_test.rb')
-rw-r--r-- | actionpack/test/template/text_helper_test.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index d22b9fe406..d0d4286393 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -1,4 +1,4 @@ -# encoding: us-ascii +# encoding: utf-8 require 'abstract_unit' require 'testing_sandbox' @@ -99,7 +99,7 @@ class TextHelperTest < ActionView::TestCase def test_highlight_should_be_html_safe assert highlight("This is a beautiful morning", "beautiful").html_safe? end - + def test_highlight assert_equal( "This is a <strong class=\"highlight\">beautiful</strong> morning", @@ -415,6 +415,12 @@ class TextHelperTest < ActionView::TestCase link10_raw = 'http://www.mail-archive.com/ruby-talk@ruby-lang.org/' link10_result = generate_result(link10_raw) assert_equal %(<p>#{link10_result} Link</p>), auto_link("<p>#{link10_raw} Link</p>") + + link11_raw = 'http://asakusa.rubyist.net/' + link11_result = generate_result(link11_raw) + with_kcode 'u' do + assert_equal %(浅草.rbの公式サイトはこちら#{link11_result}), auto_link("浅草.rbの公式サイトはこちら#{link11_raw}") + end end def test_auto_link_should_sanitize_input_when_sanitize_option_is_not_false @@ -430,7 +436,7 @@ class TextHelperTest < ActionView::TestCase def test_auto_link_other_protocols ftp_raw = 'ftp://example.com/file.txt' assert_equal %(Download #{generate_result(ftp_raw)}), auto_link("Download #{ftp_raw}") - + file_scheme = 'file:///home/username/RomeoAndJuliet.pdf' z39_scheme = 'z39.50r://host:696/db' chrome_scheme = 'chrome://package/section/path' @@ -452,7 +458,7 @@ class TextHelperTest < ActionView::TestCase assert_equal linked3, auto_link(linked3) assert_equal linked4, auto_link(linked4) assert_equal linked5, auto_link(linked5) - + linked_email = %Q(<a href="mailto:david@loudthinking.com">Mail me</a>) assert_equal linked_email, auto_link(linked_email) end @@ -491,13 +497,13 @@ class TextHelperTest < ActionView::TestCase url = "http://api.rubyonrails.com/Foo.html" email = "fantabulous@shiznadel.ic" - assert_equal %(<p><a href="#{url}">#{url[0...7]}...</a><br /><a href="mailto:#{email}">#{email[0...7]}...</a><br /></p>), auto_link("<p>#{url}<br />#{email}<br /></p>") { |url| truncate(url, :length => 10) } + assert_equal %(<p><a href="#{url}">#{url[0...7]}...</a><br /><a href="mailto:#{email}">#{email[0...7]}...</a><br /></p>), auto_link("<p>#{url}<br />#{email}<br /></p>") { |_url| truncate(_url, :length => 10) } end - + def test_auto_link_with_block_with_html pic = "http://example.com/pic.png" url = "http://example.com/album?a&b=c" - + assert_equal %(My pic: <a href="#{pic}"><img src="#{pic}" width="160px"></a> -- full album here #{generate_result(url)}), auto_link("My pic: #{pic} -- full album here #{url}") { |link| if link =~ /\.(jpg|gif|png|bmp|tif)$/i raw %(<img src="#{link}" width="160px">) @@ -512,7 +518,7 @@ class TextHelperTest < ActionView::TestCase auto_link("Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com.", :link => :all, :html => { :class => "menu", :target => "_blank" }) end - + def test_auto_link_with_multiple_trailing_punctuations url = "http://youtube.com" url_result = generate_result(url) |