Modified spec (doesn't check Youtube handling due to disabled net::http)
This commit is contained in:
parent
f2af56f4b2
commit
1d9aa4c43d
2 changed files with 19 additions and 4 deletions
|
|
@ -19,8 +19,8 @@ module StatusMessagesHelper
|
|||
# next line is important due to XSS! (h is rail's make_html_safe-function)
|
||||
message = h(message).html_safe
|
||||
message.gsub!(/( |^)(www\.[^ ]+\.[^ ])/, '\1http://\2')
|
||||
message.gsub!(/( |^)http:\/\/www\.youtube\.com\/watch[^ ]*v=([A-Za-z0-9_]+)/, '\1youtube.com::\2')
|
||||
message.gsub!(/(http|ftp):\/\/([^ ]+)/, '<a target="_blank" href="\1://\2">\2</a>')
|
||||
message.gsub!(/( |^)http:\/\/www\.youtube\.com\/watch[^ ]*v=([A-Za-z0-9_]+)(&[^ ]*|)/, '\1youtube.com::\2')
|
||||
message.gsub!(/(https|http|ftp):\/\/([^ ]+)/, '<a target="_blank" href="\1://\2">\2</a>')
|
||||
|
||||
while youtube = message.match(/youtube\.com::([A-Za-z0-9_]+)/)
|
||||
videoid = youtube[1]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ describe StatusMessagesHelper do
|
|||
|
||||
it "should recognize basic http links (2/3)" do
|
||||
proto="http"
|
||||
url="www.youtube.com/watch?v=b15yaPYNDRU"
|
||||
url="webmail.example.com?~()!*/"
|
||||
make_links(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||
end
|
||||
|
||||
|
|
@ -26,7 +26,22 @@ describe StatusMessagesHelper do
|
|||
url="127.0.0.1:3000/users/sign_in"
|
||||
make_links(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||
end
|
||||
|
||||
|
||||
it "should recognize secure https links" do
|
||||
proto="https"
|
||||
url="127.0.0.1:3000/users/sign_in"
|
||||
make_links(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||
end
|
||||
|
||||
# this will not work because the make_links requires an internet connection, which is disabled for the test :(
|
||||
# it "should recognize youtube links" do
|
||||
# proto="http"
|
||||
# url="www.youtube.com/watch?v=UNgOJDL9iyQ&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
|
||||
# res = make_links(proto+"://"+url, true)
|
||||
# puts "RES: " + res
|
||||
# res.should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||
# end
|
||||
|
||||
it "should recognize basic ftp links" do
|
||||
proto="ftp"
|
||||
url="ftp.uni-kl.de/CCC/26C3/mp4/26c3-3540-en-a_hackers_utopia.mp4"
|
||||
|
|
|
|||
Loading…
Reference in a new issue