Added request form
This commit is contained in:
parent
10f99214e4
commit
9bd0e00986
@ -10,6 +10,23 @@ module Facebooker2
|
|||||||
options = fb_stringify_vals({:showborder=>false,:actiontext=>message,:max=>20}.merge(options.dup))
|
options = fb_stringify_vals({:showborder=>false,:actiontext=>message,:max=>20}.merge(options.dup))
|
||||||
tag("fb:multi-friend-selector",options)
|
tag("fb:multi-friend-selector",options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fb_request_form(type,url,message,options={},&block)
|
||||||
|
content = capture(&block)
|
||||||
|
concat(content_tag("fb:request-form", content.to_s + fb_forgery_protection_token_tag,
|
||||||
|
{:action=>url,:method=>"post",:invite=>true,:type=>type,:content=>message}.merge(options)))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def fb_forgery_protection_token_tag
|
||||||
|
unless protect_against_forgery?
|
||||||
|
''
|
||||||
|
else
|
||||||
|
tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,4 +18,31 @@ describe Facebooker2::Rails::Helpers::RequestForms, :type=>:helper do
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "request form" do
|
||||||
|
it "includes the name, url, and a message" do
|
||||||
|
fb_request_form "Title","URL","message" do
|
||||||
|
end
|
||||||
|
@output_buffer.should == "<fb:request-form action=\"URL\" content=\"message\" invite=\"true\" method=\"post\" type=\"Title\"></fb:request-form>"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders the yielded content" do
|
||||||
|
fb_request_form "Title","URL","message" do
|
||||||
|
"yielded"
|
||||||
|
end
|
||||||
|
@output_buffer.should =~ /yielded/
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows you to override params" do
|
||||||
|
fb_request_form "Title","URL","message",:invite=>false do
|
||||||
|
end
|
||||||
|
@output_buffer.should =~ /invite="false"/
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user