Skip to content

Commit 020bc2e

Browse files
timothysuLeFnord
authored andcommitted
Fix Proc with arity one in param values (ruby-grape#613)
1 parent 86341b5 commit 020bc2e

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#### Features
44

55
* Your contribution here.
6+
* [#613](https://github.com/ruby-grape/grape-swagger/pull/613): Fix Proc with arity one in param values - [@timothysu](https://github.com/timothysu).
67

78
#### Fixes
89

lib/grape-swagger/doc_methods/parse_params.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def param_type(value_type)
101101
def parse_enum_or_range_values(values)
102102
case values
103103
when Proc
104-
parse_enum_or_range_values(values.call)
104+
parse_enum_or_range_values(values.call) if values.parameters.empty?
105105
when Range
106106
parse_range_values(values) if values.first.is_a?(Integer)
107107
else

spec/lib/parse_params_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
expect(parsed_range).to eql(enum: %w[a b c])
4848
end
4949
end
50+
51+
describe 'with arity one' do
52+
let(:values) { proc { |v| v < 25 } }
53+
specify do
54+
parsed_range = subject.send(:parse_enum_or_range_values, values)
55+
expect(parsed_range).to be_nil
56+
end
57+
end
5058
end
5159

5260
describe 'values as Array -> enums' do

0 commit comments

Comments
 (0)