diff options
author | David Lee <davidomundo@gmail.com> | 2011-05-06 14:03:55 -0700 |
---|---|---|
committer | David Lee <davidomundo@gmail.com> | 2012-02-22 08:47:10 -0800 |
commit | 002713c64568114f3754799acc0723ea0d442f7a (patch) | |
tree | bd01c3ded14a9a96b92fbb54b8e0da35a899e374 /railties/guides/source/testing.textile | |
parent | 66b7eb19279820b6464ad2b9e3f2efadb08f2ff2 (diff) | |
download | rails-002713c64568114f3754799acc0723ea0d442f7a.tar.gz rails-002713c64568114f3754799acc0723ea0d442f7a.tar.bz2 rails-002713c64568114f3754799acc0723ea0d442f7a.zip |
Add config.default_method_for_update to support PATCH
PATCH is the correct HTML verb to map to the #update action. The
semantics for PATCH allows for partial updates, whereas PUT requires a
complete replacement.
Changes:
* adds config.default_method_for_update you can set to :patch
* optionally use PATCH instead of PUT in resource routes and forms
* adds the #patch verb to routes to detect PATCH requests
* adds #patch? to Request
* changes documentation and comments to indicate support for PATCH
This change maintains complete backwards compatibility by keeping :put
as the default for config.default_method_for_update.
Diffstat (limited to 'railties/guides/source/testing.textile')
-rw-r--r-- | railties/guides/source/testing.textile | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index 1e6b92f45c..c367f532ae 100644 --- a/railties/guides/source/testing.textile +++ b/railties/guides/source/testing.textile @@ -483,10 +483,11 @@ Now you can try running all the tests and they should pass. h4. Available Request Types for Functional Tests -If you're familiar with the HTTP protocol, you'll know that +get+ is a type of request. There are 5 request types supported in Rails functional tests: +If you're familiar with the HTTP protocol, you'll know that +get+ is a type of request. There are 6 request types supported in Rails functional tests: * +get+ * +post+ +* +patch+ * +put+ * +head+ * +delete+ @@ -638,6 +639,7 @@ In addition to the standard testing helpers, there are some additional helpers a |+request_via_redirect(http_method, path, [parameters], [headers])+ |Allows you to make an HTTP request and follow any subsequent redirects.| |+post_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP POST request and follow any subsequent redirects.| |+get_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP GET request and follow any subsequent redirects.| +|+patch_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP PATCH request and follow any subsequent redirects.| |+put_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP PUT request and follow any subsequent redirects.| |+delete_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP DELETE request and follow any subsequent redirects.| |+open_session+ |Opens a new session instance.| @@ -810,7 +812,7 @@ class PostsControllerTest < ActionController::TestCase end test "should update post" do - put :update, :id => @post.id, :post => { } + patch :update, :id => @post.id, :post => { } assert_redirected_to post_path(assigns(:post)) end |