aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/http_mock.rb
diff options
context:
space:
mode:
authorDavid Lee <davidomundo@gmail.com>2011-05-06 14:03:55 -0700
committerDavid Lee <davidomundo@gmail.com>2012-02-22 08:47:10 -0800
commit002713c64568114f3754799acc0723ea0d442f7a (patch)
treebd01c3ded14a9a96b92fbb54b8e0da35a899e374 /activeresource/lib/active_resource/http_mock.rb
parent66b7eb19279820b6464ad2b9e3f2efadb08f2ff2 (diff)
downloadrails-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 'activeresource/lib/active_resource/http_mock.rb')
-rw-r--r--activeresource/lib/active_resource/http_mock.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activeresource/lib/active_resource/http_mock.rb b/activeresource/lib/active_resource/http_mock.rb
index 666b961f87..820b178d4b 100644
--- a/activeresource/lib/active_resource/http_mock.rb
+++ b/activeresource/lib/active_resource/http_mock.rb
@@ -15,7 +15,7 @@ module ActiveResource
#
# mock.http_method(path, request_headers = {}, body = nil, status = 200, response_headers = {})
#
- # * <tt>http_method</tt> - The HTTP method to listen for. This can be +get+, +post+, +put+, +delete+ or
+ # * <tt>http_method</tt> - The HTTP method to listen for. This can be +get+, +post+, +patch+, +put+, +delete+ or
# +head+.
# * <tt>path</tt> - A string, starting with a "/", defining the URI that is expected to be
# called.
@@ -55,7 +55,7 @@ module ActiveResource
@responses = responses
end
- [ :post, :put, :get, :delete, :head ].each do |method|
+ [ :post, :put, :patch, :get, :delete, :head ].each do |method|
# def post(path, request_headers = {}, body = nil, status = 200, response_headers = {})
# @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers)
# end
@@ -217,7 +217,7 @@ module ActiveResource
end
# body? methods
- { true => %w(post put),
+ { true => %w(post patch put),
false => %w(get delete head) }.each do |has_body, methods|
methods.each do |method|
# def post(path, body, headers)