Skip to content

Commit 746dbfb

Browse files
committed
Merge pull request ruby-grape#217 from lestercsp/master
Tests and fix for issue#209 : params block validating on the wrong endpoint
2 parents 8d15724 + 0ff858a commit 746dbfb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/grape/api.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def nest(*blocks, &block)
386386
instance_eval &block if block_given?
387387
blocks.each{|b| instance_eval &b}
388388
settings.pop # when finished, we pop the context
389+
reset_validations!
389390
else
390391
instance_eval &block
391392
end

spec/grape/validations/presence_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module ValidationsSpec
66
module PresenceValidatorSpec
77
class API < Grape::API
88
default_format :json
9-
9+
10+
resource :bacons do
11+
get do
12+
"All the bacon"
13+
end
14+
end
15+
1016
params do
1117
requires :id, :regexp => /^[0-9]+$/
1218
end
@@ -27,6 +33,12 @@ class API < Grape::API
2733
def app
2834
ValidationsSpec::PresenceValidatorSpec::API
2935
end
36+
37+
it "does not validate for any params" do
38+
get("/bacons")
39+
last_response.status.should == 200
40+
last_response.body.should == "All the bacon"
41+
end
3042

3143
it 'validates id' do
3244
post('/')

0 commit comments

Comments
 (0)