Skip to content

Commit 3e6d302

Browse files
committed
Merge pull request rails#13924 from adomokos/adding_path_examples_to_button_to_tests
Adding a documentation example and a test to button_to with path
2 parents 4ac1144 + 4b4db54 commit 3e6d302

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

actionview/lib/action_view/helpers/url_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ def link_to(name = nil, options = nil, html_options = nil, &block)
232232
# # <div><input value="New" type="submit" /></div>
233233
# # </form>"
234234
#
235+
# <%= button_to "New", new_articles_path %>
236+
# # => "<form method="post" action="/articles/new" class="button_to">
237+
# # <div><input value="New" type="submit" /></div>
238+
# # </form>"
239+
#
235240
# <%= button_to [:make_happy, @user] do %>
236241
# Make happy <strong><%= @user.name %></strong>
237242
# <% end %>

actionview/test/template/url_helper_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def test_button_to_with_straight_url
5656
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")
5757
end
5858

59+
def test_button_to_with_path
60+
assert_dom_equal(
61+
%{<form method="post" action="/article/Hello" class="button_to"><div><input type="submit" value="Hello" /></div></form>},
62+
button_to("Hello", article_path("Hello".html_safe))
63+
)
64+
end
65+
5966
def test_button_to_with_straight_url_and_request_forgery
6067
self.request_forgery = true
6168

0 commit comments

Comments
 (0)