aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2012-03-14 19:28:36 -0400
committerDavid Heinemeier Hansson <david@loudthinking.com>2012-03-14 19:28:36 -0400
commite50abbad4f4141642bf5c4c27ec77852803a3a72 (patch)
treeb3321bfaef0ba23d9987b18fdd11edff3a58bbfd /actionpack/test
parent16ee611fad37b6b271088eda4cdbe3d6be088af1 (diff)
downloadrails-e50abbad4f4141642bf5c4c27ec77852803a3a72.tar.gz
rails-e50abbad4f4141642bf5c4c27ec77852803a3a72.tar.bz2
rails-e50abbad4f4141642bf5c4c27ec77852803a3a72.zip
Allow you to force the authenticity_token to be rendered even on remote forms if you pass true
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index f4e7336834..37b9de350b 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -41,6 +41,10 @@ module RequestForgeryProtectionActions
render :inline => "<%= form_for(:some_resource, :remote => true ) {} %>"
end
+ def form_for_remote_with_token
+ render :inline => "<%= form_for(:some_resource, :remote => true, :authenticity_token => true ) {} %>"
+ end
+
def rescue_action(e) raise e end
end
@@ -114,6 +118,13 @@ module RequestForgeryProtectionTests
assert_no_match /authenticity_token/, response.body
end
+ def test_should_render_form_with_token_tag_if_remote_and_authenticity_token_requested
+ assert_not_blocked do
+ get :form_for_remote_with_token
+ end
+ assert_select 'form>div>input[name=?][value=?]', 'custom_authenticity_token', @token
+ end
+
def test_should_allow_get
assert_not_blocked { get :index }
end