diff options
author | Andy Waite <github.aw@andywaite.com> | 2013-05-05 12:32:00 +0100 |
---|---|---|
committer | Andy Waite <github.aw@andywaite.com> | 2013-09-18 19:56:46 +0100 |
commit | e6e0579defcfcf94ef1c4c1c7659f374a5335cdb (patch) | |
tree | d2d0b091287c7bb9f1bdcb9dd76b8d1ab1e93e3f /actionview/test | |
parent | 539180cf8edaa405928162644dc617b4c179edff (diff) | |
download | rails-e6e0579defcfcf94ef1c4c1c7659f374a5335cdb.tar.gz rails-e6e0579defcfcf94ef1c4c1c7659f374a5335cdb.tar.bz2 rails-e6e0579defcfcf94ef1c4c1c7659f374a5335cdb.zip |
Add params option for button_to
The parameters are rendered as hidden form fields within the generated
form. This is useful for when a record has multiple buttons associated
with it, each of which target the same controller method, but which
need to submit different attributes.
Diffstat (limited to 'actionview/test')
-rw-r--r-- | actionview/test/template/url_helper_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index d512fa9913..850b8a62e9 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -160,6 +160,13 @@ class UrlHelperTest < ActiveSupport::TestCase ) end + def test_button_to_with_params + assert_dom_equal( + %{<form action="http://www.example.com" class="button_to" method="post"><div><input type="submit" value="Hello" /><input type="hidden" name="foo" value="bar" /><input type="hidden" name="baz" value="quux" /></div></form>}, + button_to("Hello", "http://www.example.com", params: {foo: :bar, baz: "quux"}) + ) + end + def test_link_tag_with_straight_url assert_dom_equal %{<a href="http://www.example.com">Hello</a>}, link_to("Hello", "http://www.example.com") end |