Skip to content

Commit

Permalink
Revert "Add params to DELETE" (#157)
Browse files Browse the repository at this point in the history
## What

Reverts #145

## Why

#145 unintentionally introduced an unintentional breaking
change for client sending parameters in the body on DELETE requests.
  • Loading branch information
balvig authored Apr 15, 2024
1 parent d3f2475 commit 955072a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/spyke/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def uri(uri_template = nil)

def send_request(method, path, params)
connection.send(method) do |request|
if [:get, :delete].include?(method)
if method == :get
path, params = merge_query_params(path, params)
request.url path, params
else
Expand Down
4 changes: 2 additions & 2 deletions lib/spyke/orm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def save
end
end

def destroy(params = {})
self.attributes = delete(params)
def destroy
self.attributes = delete
end

def update(new_attributes)
Expand Down
2 changes: 1 addition & 1 deletion lib/spyke/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Spyke
VERSION = '7.2.1'
VERSION = '7.2.2'
end
8 changes: 0 additions & 8 deletions test/orm_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ def test_to_params_with_custom_root
assert_equal({ 'foto' => { 'url' => 'bob.jpg' } }, Cookbook::Photo.new(url: 'bob.jpg').to_params)
end

def test_destroy_with_params
endpoint = stub_request(:delete, 'http://sushi.com/recipes/1?cascade=true').to_return_json(result: { id: 1, deleted: true })
recipe = Recipe.new(id: 1)
recipe.destroy(cascade: true)
assert recipe.deleted
assert_requested endpoint
end

def test_destroy
endpoint = stub_request(:delete, 'http://sushi.com/recipes/1').to_return_json(result: { id: 1, deleted: true })
recipe = Recipe.new(id: 1)
Expand Down

0 comments on commit 955072a

Please sign in to comment.