Ticket #8794: link_to_with_blank_options_uses_first_arg_for_url.diff
| File link_to_with_blank_options_uses_first_arg_for_url.diff, 1.9 kB (added by gbuesing, 2 years ago) |
|---|
-
test/template/url_helper_test.rb
old new 14 14 url 15 15 end 16 16 end 17 18 def polymorphic_path(options) 19 @controller.url 20 end 21 17 22 @controller = @controller.new 18 23 @controller.url = "http://www.example.com" 19 24 end … … 98 103 def test_link_with_nil_html_options 99 104 assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", {:action => 'myaction'}, nil) 100 105 end 106 107 def test_link_tag_with_nil_options 108 @workshop, @session = Workshop.new('foo workshop', true), Session.new('foo session', true) 109 assert_dom_equal "<a href=\"http://www.example.com\">foo session</a>", link_to(@session) 110 assert_dom_equal "<a href=\"http://www.example.com\">foo session</a>", link_to([@workshop, @session]) 111 end 101 112 102 113 def test_link_tag_with_custom_onclick 103 114 assert_dom_equal "<a href=\"http://www.example.com\" onclick=\"alert('yay!')\">Hello</a>", link_to("Hello", "http://www.example.com", :onclick => "alert('yay!')") -
lib/action_view/helpers/url_helper.rb
old new 133 133 # var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); 134 134 # m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;">Delete Image</a> 135 135 def link_to(name, options = {}, html_options = nil) 136 options = options.blank? ? name : options 137 name = name.is_a?(Array) ? name.last : name 136 138 url = options.is_a?(String) ? options : self.url_for(options) 137 139 138 140 if html_options