Permalink
Browse files

Merge pull request #30 from jgarber/patch-verb

Add patch verb
  • Loading branch information...
2 parents 394e9e0 + 8598c0e commit 2ac634779e473dd4642ace0488ed84e3f373f10c @fredwu committed Oct 29, 2012
Showing with 16 additions and 1 deletion.
  1. +4 −0 lib/api_taster/mapper.rb
  2. +12 −1 spec/mapper_spec.rb
View
@@ -15,6 +15,10 @@ def put(path, params = {}, metadata = {})
map_method(:put, path, params, metadata)
end
+ def patch(path, params = {}, metadata = {})
+ map_method(:patch, path, params, metadata)
+ end
+
def delete(path, params = {}, metadata = {})
map_method(:delete, path, params, metadata)
end
View
@@ -23,7 +23,11 @@ module ApiTaster
end
before(:all) do
- Rails.application.routes.draw { resources :dummy_users }
+ Rails.application.routes.draw do
+ resources :dummy_users do
+ member { map_method :patch, :update }
+ end
+ end
end
context "#global_params" do
@@ -52,6 +56,7 @@ module ApiTaster
post '/dummy_users', { :hello => 'world' }, { :meta => 'data' }
put '/dummy_users/:id', :id => 2
delete '/dummy_users/:id', :id => 3
+ patch '/dummy_users/:id', :id => 4
end
Route.map_routes
@@ -75,6 +80,12 @@ module ApiTaster
Route.supplied_params[route[:id]].should == [{ :id => 2 }]
end
+ it "edits a user via PATCH" do
+ route = Route.find_by_verb_and_path(:patch, '/dummy_users/:id')
+
+ Route.supplied_params[route[:id]].should == [{ :id => 4 }]
+ end
+
it "deletes a user" do
route = Route.find_by_verb_and_path(:delete, '/dummy_users/:id')

0 comments on commit 2ac6347

Please sign in to comment.