Permalink
Browse files

Merge pull request #13924 from adomokos/adding_path_examples_to_butto…

…n_to_tests

Adding a documentation example and a test to button_to with path
  • Loading branch information...
2 parents 4ac1144 + 4b4db54 commit 3e6d302ccc0b3bbb1527dbb83ea1834bd85b44a0 @rafaelfranca rafaelfranca committed Feb 2, 2014
Showing with 12 additions and 0 deletions.
  1. +5 −0 actionview/lib/action_view/helpers/url_helper.rb
  2. +7 −0 actionview/test/template/url_helper_test.rb
@@ -232,6 +232,11 @@ def link_to(name = nil, options = nil, html_options = nil, &block)
# # <div><input value="New" type="submit" /></div>
# # </form>"
#
+ # <%= button_to "New", new_articles_path %>
+ # # => "<form method="post" action="/articles/new" class="button_to">
+ # # <div><input value="New" type="submit" /></div>
+ # # </form>"
+ #
# <%= button_to [:make_happy, @user] do %>
# Make happy <strong><%= @user.name %></strong>
# <% end %>
@@ -56,6 +56,13 @@ def test_button_to_with_straight_url
assert_dom_equal %{<form method="post" action="http://www.example.com" class="button_to"><div><input type="submit" value="Hello" /></div></form>}, button_to("Hello", "http://www.example.com")
end
+ def test_button_to_with_path
+ assert_dom_equal(
+ %{<form method="post" action="/article/Hello" class="button_to"><div><input type="submit" value="Hello" /></div></form>},
+ button_to("Hello", article_path("Hello".html_safe))
+ )
+ end
+
def test_button_to_with_straight_url_and_request_forgery
self.request_forgery = true

0 comments on commit 3e6d302

Please sign in to comment.