mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Added :popup option to UrlHelper#link_to #1996 [gabriel.gironda@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2129 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -62,6 +62,32 @@ class UrlHelperTest < Test::Unit::TestCase
|
||||
)
|
||||
end
|
||||
|
||||
def test_link_tag_with_popup
|
||||
assert_equal(
|
||||
"<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>",
|
||||
link_to("Hello", "http://www.example.com", :popup => true)
|
||||
)
|
||||
assert_equal(
|
||||
"<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>",
|
||||
link_to("Hello", "http://www.example.com", :popup => 'true')
|
||||
)
|
||||
assert_equal(
|
||||
"<a href=\"http://www.example.com\" onclick=\"window.open(this.href,'window_name','width=300,height=300');return false;\">Hello</a>",
|
||||
link_to("Hello", "http://www.example.com", :popup => ['window_name', 'width=300,height=300'])
|
||||
)
|
||||
end
|
||||
|
||||
def test_link_tag_with_popup_and_javascript_confirm
|
||||
assert_equal(
|
||||
"<a href=\"http://www.example.com\" onclick=\"if (confirm('Fo\\' sho\\'?')) { window.open(this.href); };return false;\">Hello</a>",
|
||||
link_to("Hello", "http://www.example.com", { :popup => true, :confirm => "Fo' sho'?" })
|
||||
)
|
||||
assert_equal(
|
||||
"<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { window.open(this.href,'window_name','width=300,height=300'); };return false;\">Hello</a>",
|
||||
link_to("Hello", "http://www.example.com", { :popup => ['window_name', 'width=300,height=300'], :confirm => "Are you serious?" })
|
||||
)
|
||||
end
|
||||
|
||||
def test_link_to_unless
|
||||
assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog")
|
||||
assert "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog")
|
||||
|
||||
Reference in New Issue
Block a user