aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb2
-rw-r--r--actionpack/test/template/url_helper_test.rb4
2 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 7ca1d0cd0b..2901d4f642 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -254,6 +254,8 @@ module ActionView
"#{post_javascript_function}return false;"
when popup
popup_javascript_function(popup) + 'return false;'
+ else
+ html_options["onclick"]
end
end
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index 17eacce207..f71a5e94c6 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -47,6 +47,10 @@ class UrlHelperTest < Test::Unit::TestCase
assert_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com")
end
+ def test_link_tag_with_custom_onclick
+ assert_equal "<a href=\"http://www.example.com\" onclick=\"alert('yay!')\">Hello</a>", link_to("Hello", "http://www.example.com", :onclick => "alert('yay!')")
+ end
+
def test_link_tag_with_javascript_confirm
assert_equal(
"<a href=\"http://www.example.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>",