aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-08 17:54:16 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-08 17:54:16 +0000
commit079d8f402893dae8607bb7e272a6a038b840b4d2 (patch)
tree6e64b8bf5e6b286cbe30e56ea2eb86c13ae835ef /actionpack
parent9053c4c83e4ff74e71b7e771a0b58a3cb45e53bc (diff)
downloadrails-079d8f402893dae8607bb7e272a6a038b840b4d2.tar.gz
rails-079d8f402893dae8607bb7e272a6a038b840b4d2.tar.bz2
rails-079d8f402893dae8607bb7e272a6a038b840b4d2.zip
Fixed that onclick would be overridden even when special features werent used
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2158 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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>",