add support for Rails 2.3.4 form authenticity tokens
This commit is contained in:
parent
cbb07306d4
commit
ea4a52ccf1
@ -53,7 +53,7 @@ module Webrat
|
|||||||
|
|
||||||
def authenticity_token
|
def authenticity_token
|
||||||
return unless onclick && onclick.include?("s.setAttribute('name', 'authenticity_token');") &&
|
return unless onclick && onclick.include?("s.setAttribute('name', 'authenticity_token');") &&
|
||||||
onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/
|
( onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/ || onclick =~ /s\.setAttribute\('value', '(.{44})'\);/ )
|
||||||
$LAST_MATCH_INFO.captures.first
|
$LAST_MATCH_INFO.captures.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,6 +144,27 @@ describe "click_link" do
|
|||||||
click_link "Posts"
|
click_link "Posts"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should click rails 2.3.4 javascript links with authenticity tokens" 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 s = document.createElement('input');
|
||||||
|
s.setAttribute('type', 'hidden');
|
||||||
|
s.setAttribute('name', 'authenticity_token');
|
||||||
|
s.setAttribute('value', 'aa79cb354597a60a3786e7e291ed4f74d77d3a62=/$a');
|
||||||
|
f.appendChild(s);
|
||||||
|
f.submit();
|
||||||
|
return false;">Posts</a>
|
||||||
|
</html>
|
||||||
|
HTML
|
||||||
|
webrat_session.should_receive(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62=/$a")
|
||||||
|
click_link "Posts"
|
||||||
|
end
|
||||||
|
|
||||||
it "should click rails javascript delete links" do
|
it "should click rails javascript delete links" do
|
||||||
with_html <<-HTML
|
with_html <<-HTML
|
||||||
<html>
|
<html>
|
||||||
|
Loading…
Reference in New Issue
Block a user