Merge commit 'MarkMenard/master'
This commit is contained in:
commit
644478f6f0
@ -81,6 +81,8 @@ module Webrat
|
||||
:delete
|
||||
elsif onclick.include?("m.setAttribute('value', 'put')")
|
||||
:put
|
||||
elsif onclick.include?("m.setAttribute('value', 'post')")
|
||||
:post
|
||||
else
|
||||
raise Webrat::WebratError.new("No HTTP method for _method param in #{onclick.inspect}")
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ module Webrat #:nodoc:
|
||||
end
|
||||
|
||||
def mechanize
|
||||
@mechanize = WWW::Mechanize.new
|
||||
@mechanize ||= WWW::Mechanize.new
|
||||
end
|
||||
|
||||
def_delegators :mechanize, :basic_auth
|
||||
|
@ -176,6 +176,27 @@ describe "click_link" do
|
||||
click_link "Posts", :javascript => false
|
||||
end
|
||||
|
||||
it "should click rails javascript post links" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<a href="/posts" onclick="var f = document.createElement('form');
|
||||
f.style.display = 'none';
|
||||
this.parentNode.appendChild(f);
|
||||
f.method = 'POST';
|
||||
f.action = this.href;
|
||||
var m = document.createElement('input');
|
||||
m.setAttribute('type', 'hidden');
|
||||
m.setAttribute('name', '_method');
|
||||
m.setAttribute('value', 'post');
|
||||
f.appendChild(m);
|
||||
f.submit();
|
||||
return false;">Post</a></h2>
|
||||
</html>
|
||||
HTML
|
||||
webrat_session.should_receive(:post).with("/posts", {})
|
||||
click_link "Post"
|
||||
end
|
||||
|
||||
it "should click rails javascript put links" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
|
Loading…
Reference in New Issue
Block a user