add target="_blank" for generated links

This causes the links to be opened in a new window/tab.
Existing (rendered) notes are not affected by this.

Fixes #1747
This commit is contained in:
Carsten Otto 2016-01-23 19:19:53 +01:00
parent d1a9e2746b
commit 3327966af1
2 changed files with 22 additions and 8 deletions

View file

@ -842,11 +842,22 @@ class TodosControllerTest < ActionController::TestCase
# See http://blog.swivel.com/code/2009/06/rails-auto_link-and-certain-query-strings.html
login_as(:admin_user)
todo = users(:admin_user).todos.first
url = "http://example.com/foo?bar=/baz"
url = 'http://example.com/foo?bar=/baz'
todo.notes = "foo #{url} bar"
todo.save!
get :index
assert_select("a[href=#{url}]")
assert_select "a[href=#{url}]"
end
def test_link_opened_in_new_window
# issue #1747
login_as(:admin_user)
todo = users(:admin_user).todos.first
url = 'http://example.com/'
todo.notes = "foo #{url} bar"
todo.save!
get :index
assert_select "a[target='_blank']"
end
def test_format_note_normal