Skip to content

Commit c701d48

Browse files
committed
Fix route requirements bug
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.
1 parent f68a385 commit c701d48

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Your contribution here.
1010
* [#1776](https://github.com/ruby-grape/grape/pull/1776): Validate response returned by the exception handler - [@darren987469](https://github.com/darren987469).
1111
* [#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).
12+
* [#1788](https://github.com/ruby-grape/grape/pull/1788): Fix route requirements bug - [@darren987469](https://github.com/darren987469), [@darrellnash](https://github.com/darrellnash).
1213

1314
### 1.1.0 (8/4/2018)
1415

lib/grape/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def prepare_version
200200
end
201201

202202
def merge_route_options(**default)
203-
options[:route_options].clone.reverse_merge(**default)
203+
options[:route_options].clone.merge(**default)
204204
end
205205

206206
def map_routes

spec/grape/api/routes_with_requirements_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def app
2222

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

0 commit comments

Comments
 (0)