aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2012-03-10 16:16:35 -0800
committerMichael Koziarski <michael@koziarski.com>2012-03-10 16:16:35 -0800
commit411a8265835971e48f79de9829c5e18e01837395 (patch)
tree2d4c987577d64c62107159d050372ce6cae92d84 /railties/test
parentd5d241cb2c696f13e2c16efca0d24565a6e1c0a5 (diff)
parent245941101b1ea00a9b1af613c20b0ee994a43946 (diff)
downloadrails-411a8265835971e48f79de9829c5e18e01837395.tar.gz
rails-411a8265835971e48f79de9829c5e18e01837395.tar.bz2
rails-411a8265835971e48f79de9829c5e18e01837395.zip
Merge pull request #5326 from lest/patch-2
configure how unverified request will be handled
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/configuration_test.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index c9310aff87..ac5ac2b93e 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -275,19 +275,23 @@ module ApplicationTests
require "#{app_path}/config/environment"
+ token = "cf50faa3fe97702ca1ae"
+ PostsController.any_instance.stubs(:form_authenticity_token).returns(token)
+ params = {:authenticity_token => token}
+
get "/posts/1"
assert_match /patch/, last_response.body
- patch "/posts/1"
+ patch "/posts/1", params
assert_match /update/, last_response.body
- patch "/posts/1"
+ patch "/posts/1", params
assert_equal 200, last_response.status
- put "/posts/1"
+ put "/posts/1", params
assert_match /update/, last_response.body
- put "/posts/1"
+ put "/posts/1", params
assert_equal 200, last_response.status
end
@@ -528,6 +532,12 @@ module ApplicationTests
end
RUBY
+ app_file 'app/controllers/application_controller.rb', <<-RUBY
+ class ApplicationController < ActionController::Base
+ protect_from_forgery :with => :reset_session # as we are testing API here
+ end
+ RUBY
+
app_file 'app/controllers/posts_controller.rb', <<-RUBY
class PostsController < ApplicationController
def create