aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorMislav Marohnić <mislav.marohnic@gmail.com>2010-04-17 05:13:40 +0200
committerMislav Marohnić <mislav.marohnic@gmail.com>2010-05-24 11:25:24 +0200
commit133ada6ab0f0cb7bef2bd40dbc18f2d5bc6b964e (patch)
tree06bb2e121beabbc72f377f39848c164c32c592fb /actionpack/test
parent69a9669d9d51fae8f591cd7a0108b6fc4b47070c (diff)
downloadrails-133ada6ab0f0cb7bef2bd40dbc18f2d5bc6b964e.tar.gz
rails-133ada6ab0f0cb7bef2bd40dbc18f2d5bc6b964e.tar.bz2
rails-133ada6ab0f0cb7bef2bd40dbc18f2d5bc6b964e.zip
auto_link: support arbitrary URI schemes like "ftp:" and "file:"
recognizes all URI scheme allowed characters, such as colon and period. [#3494 state:resolved]
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/text_helper_test.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index 8b6c107a21..13f55cacb6 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -376,17 +376,16 @@ class TextHelperTest < ActionView::TestCase
end
def test_auto_link_other_protocols
- silence_warnings do
- begin
- old_re_value = ActionView::Helpers::TextHelper::AUTO_LINK_RE
- ActionView::Helpers::TextHelper.const_set :AUTO_LINK_RE, %r{(ftp://)[^\s<]+}
- link_raw = 'ftp://example.com/file.txt'
- link_result = generate_result(link_raw)
- assert_equal %(Download #{link_result}), auto_link("Download #{link_raw}")
- ensure
- ActionView::Helpers::TextHelper.const_set :AUTO_LINK_RE, old_re_value
- end
- end
+ 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'
+ view_source = 'view-source:http://en.wikipedia.org/wiki/URI_scheme'
+ assert_equal generate_result(z39_scheme), auto_link(z39_scheme)
+ assert_equal generate_result(chrome_scheme), auto_link(chrome_scheme)
+ assert_equal generate_result(view_source), auto_link(view_source)
end
def test_auto_link_already_linked