Skip to content

Commit

Permalink
Fix route requirements bug
Browse files Browse the repository at this point in the history
This was a bug introduced by commit 9f4ba67. The commit
replaces `options[:route_options].clone.merge(...)` with
`options[:route_options].clone.reverse_merge(...)`.
That causes disappear of the requirements in namespace.
  • Loading branch information
darren987469 committed Sep 6, 2018
1 parent f68a385 commit c701d48
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Your contribution here.
* [#1776](https://github.com/ruby-grape/grape/pull/1776): Validate response returned by the exception handler - [@darren987469](https://github.com/darren987469).
* [#1787](https://github.com/ruby-grape/grape/pull/1787): Add documented but not implemented ability to `.insert` a middleware in the stack - [@michaellennox](https://github.com/michaellennox).
* [#1788](https://github.com/ruby-grape/grape/pull/1788): Fix route requirements bug - [@darren987469](https://github.com/darren987469), [@darrellnash](https://github.com/darrellnash).

### 1.1.0 (8/4/2018)

Expand Down
2 changes: 1 addition & 1 deletion lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def prepare_version
end

def merge_route_options(**default)
options[:route_options].clone.reverse_merge(**default)
options[:route_options].clone.merge(**default)
end

def map_routes
Expand Down
2 changes: 1 addition & 1 deletion spec/grape/api/routes_with_requirements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def app

it 'routes to a path with multiple params with dots' do
subject.get ':id_with_dots/:another_id_with_dots', requirements: { id_with_dots: %r{[^\/]+},
another_id_with_dots: %r{[^\/]+} } do
another_id_with_dots: %r{[^\/]+} } do
"#{params[:id_with_dots]}/#{params[:another_id_with_dots]}"
end

Expand Down

0 comments on commit c701d48

Please sign in to comment.