Skip to content

Commit

Permalink
Fake Rails 3 ajax links with data-method attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mutle committed Sep 16, 2010
1 parent dcd17ac commit 83c5c25
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/webrat/core/elements/link.rb
Expand Up @@ -62,15 +62,17 @@ def onclick
end

def http_method
if !onclick.blank? && onclick.include?("f.submit()")
if @element["data-method"] && %w(get post put delete).include?(@element["data-method"])
@element["data-method"].to_sym
elsif !onclick.blank? && onclick.include?("f.submit()") || @element["data-method"]
http_method_from_js_form
else
:get
end
end

def http_method_from_js_form
if onclick.include?("m.setAttribute('name', '_method')")
if !onclick.blank? && onclick.include?("m.setAttribute('name', '_method')")
http_method_from_fake_method_param
else
:post
Expand Down

0 comments on commit 83c5c25

Please sign in to comment.