diff --git a/lib/webrat/core/elements/link.rb b/lib/webrat/core/elements/link.rb index 5dfe504..0dadc6a 100644 --- a/lib/webrat/core/elements/link.rb +++ b/lib/webrat/core/elements/link.rb @@ -53,7 +53,7 @@ module Webrat def 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 end diff --git a/spec/public/click_link_spec.rb b/spec/public/click_link_spec.rb index 549c70b..b2fa116 100644 --- a/spec/public/click_link_spec.rb +++ b/spec/public/click_link_spec.rb @@ -143,6 +143,27 @@ describe "click_link" do webrat_session.should_receive(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62") click_link "Posts" end + + it "should click rails 2.3.4 javascript links with authenticity tokens" do + with_html <<-HTML + + Posts + + HTML + webrat_session.should_receive(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62=/$a") + click_link "Posts" + end it "should click rails javascript delete links" do with_html <<-HTML