Skip to content

PR for issue #1578 #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 19, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ 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.
# 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 || response_object]
Copy link
Member

@dblock dblock Feb 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe body here is the same as @body, so this should be file || body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the same. I forgot to remove it. On it 👍
Thanks

[status, header, response_object]
end
Expand Down
33 changes: 33 additions & 0 deletions spec/grape/endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,39 @@ def memoized
end
end

describe 'delete 200, with a return value (no explicit body)' do
it 'responds to /example delete method' do
subject.send(:delete, '/example', anchor: false) do
Copy link
Member

@dblock dblock Feb 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to send these, delete is public, so subject.delete .... I could be wrong.

'deleted'
end
send(:delete, '/example/')
Copy link
Member

@dblock dblock Feb 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, just delete '/example', these are rack helpers. This one I am pretty sure can be done without a send.

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.send(:delete, '/example', anchor: false) do
nil
end
send(: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.send(:delete, '/example', anchor: false) do
''
end
send(: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