Skip to content

Commit

Permalink
Fix #1578 and #1572 (#1579)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericproulx authored and dblock committed Feb 19, 2017
1 parent 7a56fe9 commit 3959a01
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
16 changes: 8 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-02-02 01:40:01 +0900 using RuboCop version 0.47.0.
# on 2017-02-19 15:40:46 -0500 using RuboCop version 0.47.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 44
# Offense count: 43
Metrics/AbcSize:
Max: 44

# Offense count: 266
# Offense count: 265
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 3104
Expand All @@ -23,19 +23,19 @@ Metrics/BlockNesting:
# Offense count: 8
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 280
Max: 281

# Offense count: 27
# Offense count: 26
Metrics/CyclomaticComplexity:
Max: 14

# Offense count: 983
# Offense count: 993
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 215

# Offense count: 55
# Offense count: 56
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 33
Expand All @@ -45,7 +45,7 @@ Metrics/MethodLength:
Metrics/ModuleLength:
Max: 212

# Offense count: 18
# Offense count: 16
Metrics/PerceivedComplexity:
Max: 14

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### Fixes

* [#1570](https://github.com/ruby-grape/grape/pull/1570): Make versioner consider the mount destination path - [@namusyaka](https://github.com/namusyaka).
* [#1579](https://github.com/ruby-grape/grape/pull/1579): Fix delete status with a return value - [@eproulx-petalmd](https://github.com/eproulx-petalmd).
* Your contribution here.

#### Features
Expand Down
7 changes: 5 additions & 2 deletions lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ def run
run_filters afters, :after
cookies.write(header)

# The Body commonly is an Array of Strings, the application instance itself, or a File-like object.
response_object = file || [body || response_object]
# status verifies body presence when DELETE
@body ||= response_object

# The Body commonly is an Array of Strings, the application instance itself, or a File-like object
response_object = file || [body]
[status, header, response_object]
end
end
Expand Down
27 changes: 27 additions & 0 deletions spec/grape/endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,33 @@ def memoized
end
end

describe 'delete 200, with a return value (no explicit body)' do
it 'responds to /example delete method' do
subject.delete(:example) { 'deleted' }
delete '/example'
expect(last_response.status).to eql 200
expect(last_response.body).not_to be_empty
end
end

describe 'delete 204, with nil has return value (no explicit body)' do
it 'responds to /example delete method' do
subject.delete(:example) { nil }
delete '/example'
expect(last_response.status).to eql 204
expect(last_response.body).to be_empty
end
end

describe 'delete 204, with empty array has return value (no explicit body)' do
it 'responds to /example delete method' do
subject.delete(:example) { '' }
delete '/example'
expect(last_response.status).to eql 204
expect(last_response.body).to be_empty
end
end

describe 'all other' do
%w(post get head put options patch).each do |verb|
it "allows for the anchoring option with a #{verb.upcase} method" do
Expand Down

0 comments on commit 3959a01

Please sign in to comment.