aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2009-04-23 13:25:33 +0000
committerfrancis <francis>2009-04-23 13:25:33 +0000
commit56e35fc775f6fefd706d74d325f2800172fe4c3c (patch)
treeb09bc50c0c7a9b18429d5b7a9ee8338a06b7ea11
parent9b3d6ddc404615b409853c86473df5e1c3a11138 (diff)
Format (some) links in angle brackets that have newlines in them
-rw-r--r--spec/libs/format_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/libs/format_spec.rb b/spec/libs/format_spec.rb
new file mode 100644
index 000000000..f483605a4
--- /dev/null
+++ b/spec/libs/format_spec.rb
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe "when making clickable" do
+
+ it "should make URLs into links" do
+ text = "Hello http://www.flourish.org goodbye"
+ text = CGI.escapeHTML(text)
+ formatted = MySociety::Format.make_clickable(text)
+ formatted.should == "Hello <a href='http://www.flourish.org'>http://www.flourish.org</a> goodbye"
+ end
+
+ it "should make wrapped URLs in angle brackets clickable" do
+ text = """<http://www.flourish.org/bl
+og>"""
+ text = CGI.escapeHTML(text)
+
+ formatted = MySociety::Format.make_clickable(text)
+
+ formatted.should == "&lt;<a href='http://www.flourish.org/blog'>http://www.flourish.org/blog</a>&gt;"
+ end
+
+end