make all links open in new tab. fix #1984

This commit is contained in:
Dan Hansen 2011-10-02 22:24:05 -05:00
parent ae1fedc73b
commit 84ff366fef
2 changed files with 19 additions and 1 deletions

View file

@ -8,7 +8,7 @@ module Diaspora
include ActionView::Helpers::TagHelper include ActionView::Helpers::TagHelper
def autolink(link, type) def autolink(link, type)
auto_link(link, :link => :urls ) auto_link(link, :link => :urls, :html => { :target => "_blank" })
end end
end end
end end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe Diaspora::Markdownify::HTML do
describe '#autolink' do
before do
@html = Diaspora::Markdownify::HTML.new
end
it 'should make all of the links open in a new tab' do
markdownified = @html.autolink("http://joindiaspora.com", nil)
doc = Nokogiri.parse(markdownified)
link = doc.css("a")
link.attr("target").value.should == "_blank"
end
end
end