From 4b4db54e6b48813b24c807b0156eb58bc4694cd9 Mon Sep 17 00:00:00 2001 From: Attila Domokos Date: Sun, 2 Feb 2014 10:27:18 -0600 Subject: Adding an documentation example and a test to button_to with path I did not see in the docs that `button_to` supports not only URLs but paths as well. I documented this functionality with a unit tests and added an example to the docs as well. --- actionview/lib/action_view/helpers/url_helper.rb | 5 +++++ actionview/test/template/url_helper_test.rb | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 56dd7a4390..3ccace1274 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -232,6 +232,11 @@ module ActionView # #
# # " # + # <%= button_to "New", new_articles_path %> + # # => "
+ # #
+ # #
" + # # <%= button_to [:make_happy, @user] do %> # Make happy <%= @user.name %> # <% end %> diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index deba33510a..7e978e15d2 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -56,6 +56,13 @@ class UrlHelperTest < ActiveSupport::TestCase assert_dom_equal %{
}, button_to("Hello", "http://www.example.com") end + def test_button_to_with_path + assert_dom_equal( + %{
}, + button_to("Hello", article_path("Hello".html_safe)) + ) + end + def test_button_to_with_straight_url_and_request_forgery self.request_forgery = true -- cgit v1.2.3