Skip to content
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

Don't fail even if invalid type value is provided #1249

Merged
merged 1 commit into from
Jan 19, 2016

Conversation

namusyaka
Copy link
Contributor

This fixes #1245

@@ -14,6 +14,7 @@

* [#1216](https://github.com/ruby-grape/grape/pull/1142): Fix JSON error response when calling `error!` with non-Strings - [@jrforrest](https://github.com/jrforrest).
* [#1225](https://github.com/ruby-grape/grape/pull/1225): Fix `given` with nested params not returning correct declared params - [@JanStevens](https://github.com/JanStevens).
* [#1249](https://github.com/ruby-grape/grape/pull/1249): Don't fail even if invalid type value is provided - [@namusyaka](https://github.com/namusyaka).

Copy link
Member

Choose a reason for hiding this comment

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

We should specify the scope, it's only related to the params with default validator :bowtie:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@namusyaka
Copy link
Contributor Author

Force pushed. @dm1try How about this?

end
subject.post '/optional_hash_without_default_outer_params' do
{ zone: params[:phone][:zone] }
end
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove this declarition and put the expectations to this context

      it 'does not fail even if invalid params are provided' do
        expect { post '/optional_hash_without_default', optional_hash_without_default: '5678' }.not_to raise_error
        expect(last_response.status).to eq(400)
        expect(last_response.body).to eq({ error: 'optional_hash_without_default is invalid' }.to_json)
      end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow, thanks!! Fixed.

@dm1try
Copy link
Member

dm1try commented Jan 19, 2016

@namusyaka looks good to me,
Take a look to the last comment and I'll merge this. Thanks!

dm1try added a commit that referenced this pull request Jan 19, 2016
Don't fail even if invalid type value is provided
@dm1try dm1try merged commit 6505486 into ruby-grape:master Jan 19, 2016
@namusyaka namusyaka deleted the fix-1245 branch January 19, 2016 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default value error in nested parameters
2 participants