Skip to content

Commit

Permalink
Merge pull request #2 from sparklemotion/master
Browse files Browse the repository at this point in the history
Latest
  • Loading branch information
weshatheleopard committed Dec 15, 2014
2 parents ef68df7 + 66a4c01 commit 2c458c2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Expand Up @@ -14,7 +14,7 @@ a history.
== Dependencies

* ruby 1.9.2 or newer
* nokogiri[http://nokogiri.rubyforge.org]
* nokogiri[https://github.com/sparklemotion/nokogiri]

== Support:

Expand Down
7 changes: 7 additions & 0 deletions lib/mechanize/form.rb
Expand Up @@ -330,6 +330,13 @@ def add_button_to_query(button)
@clicked_buttons << button
end

# This method allows the same form to be submitted second time
# with the different submit button being clicked.
def reset
# In the future, should add more functionality here to reset the form values to their defaults.
@clicked_buttons = []
end

# This method calculates the request data to be sent back to the server
# for this form, depending on if this is a regular post, get, or a
# multi-part post,
Expand Down
2 changes: 1 addition & 1 deletion lib/mechanize/version.rb
@@ -1,3 +1,3 @@
class Mechanize
VERSION = "2.7.4.beta2"
VERSION = "2.7.4.beta3"
end
19 changes: 19 additions & 0 deletions test/test_mechanize_form.rb
Expand Up @@ -651,6 +651,25 @@ def test_get
"Image button missing")
end

def test_reset
page = @mech.get("http://localhost/form_test.html")
get_form = page.forms.find { |f| f.name == "get_form1" }

image_button = get_form.buttons.first
submit_button = get_form.submits.first

new_page = @mech.submit(get_form, submit_button)
assert_equal "http://localhost/form_post?first_name=", new_page.uri.to_s

new_page = @mech.submit(get_form, image_button)
assert_equal "http://localhost/form_post?first_name=&button.x=0&button.y=0", new_page.uri.to_s

get_form.reset

new_page = @mech.submit(get_form, submit_button)
assert_equal "http://localhost/form_post?first_name=", new_page.uri.to_s
end

def test_post_with_space_in_action
page = @mech.get("http://localhost/form_test.html")
post_form = page.forms.find { |f| f.name == "post_form2" }
Expand Down

0 comments on commit 2c458c2

Please sign in to comment.