Add support for Rails javascript post links.
This commit is contained in:
parent
73f4c441c1
commit
0c2261d869
@ -81,6 +81,8 @@ module Webrat
|
|||||||
:delete
|
:delete
|
||||||
elsif onclick.include?("m.setAttribute('value', 'put')")
|
elsif onclick.include?("m.setAttribute('value', 'put')")
|
||||||
:put
|
:put
|
||||||
|
elsif onclick.include?("m.setAttribute('value', 'post')")
|
||||||
|
:post
|
||||||
else
|
else
|
||||||
raise Webrat::WebratError.new("No HTTP method for _method param in #{onclick.inspect}")
|
raise Webrat::WebratError.new("No HTTP method for _method param in #{onclick.inspect}")
|
||||||
end
|
end
|
||||||
|
@ -176,6 +176,27 @@ describe "click_link" do
|
|||||||
click_link "Posts", :javascript => false
|
click_link "Posts", :javascript => false
|
||||||
end
|
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
|
it "should click rails javascript put links" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<html>
|
<html>
|
||||||
|
Loading…
Reference in New Issue
Block a user