fix bug for default value as proc when there is given options values#779
Closed
ShPakvel wants to merge 1 commit intoruby-grape:masterfrom
Closed
fix bug for default value as proc when there is given options values#779ShPakvel wants to merge 1 commit intoruby-grape:masterfrom
ShPakvel wants to merge 1 commit intoruby-grape:masterfrom
Conversation
d507b2b to
d2e7949
Compare
Member
|
Can you please update CHANGELOG? For future googling purposes, also, what's 'crashes'? What's the specific error? |
d2e7949 to
960923d
Compare
Contributor
Author
|
Using grape you can meet error like params do
optional :type, values: ['valid-type1', 'valid-type2'], default: -> { ['valid-type1', 'valid-type2'].sample }
end
get '/default_lambda' do
{ type: params[:type] }
end
params do
optional :type, values: -> { ValuesModel.values }, default: -> { ValuesModel.values.sample }
end
get '/default_and_values_lambda' do
{ type: params[:type] }
endAnd this PR fixes this bug. The problem was about default option value is proc when used with values. There was not call in place which checks inclusion if default in values. |
Contributor
Author
|
@dblock I've added info to changelog and put some description of the problem here. |
Member
|
Merged via 00e745e, changed the language in the CHANGELOG a bit (and put back the your contribution here note). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When you have option
defaultas a proc and also any kind of optionvalues(as a proc or normal) the gem is crashed. This small change solves it.