File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 1515* [ #1365 ] ( https://github.com/ruby-grape/grape/pull/1365 ) : Fix finding exception handler in error middleware - [ @ktimothy ] ( https://github.com/ktimothy ) .
1616* [ #1380 ] ( https://github.com/ruby-grape/grape/pull/1380 ) : Fix ` allow_blank: false ` for ` Time ` attributes with valid values causes ` NoMethodError ` - [ @ipkes ] ( https://github.com/ipkes ) .
1717* [ #1384 ] ( https://github.com/ruby-grape/grape/pull/1384 ) : Fix parameter validation with an empty optional nested ` Array ` - [ @ipkes ] ( https://github.com/ipkes ) .
18+ * [ #1414 ] ( https://github.com/ruby-grape/grape/pull/1414 ) : Fix multiple version definitions for path versioning - [ @304 ] ( https://github.com/304 ) .
1819
19200.16.2 (4/12/2016)
2021==================
Original file line number Diff line number Diff line change @@ -30,20 +30,21 @@ def version(*args, &block)
3030 if args . any?
3131 options = args . extract_options!
3232 options = options . reverse_merge ( using : :path )
33+ requested_versions = args . flatten
3334
3435 raise Grape ::Exceptions ::MissingVendorOption . new if options [ :using ] == :header && !options . key? ( :vendor )
3536
36- @versions = versions | args
37+ @versions = versions | requested_versions
3738
3839 if block_given?
3940 within_namespace do
40- namespace_inheritable ( :version , args )
41+ namespace_inheritable ( :version , requested_versions )
4142 namespace_inheritable ( :version_options , options )
4243
4344 instance_eval ( &block )
4445 end
4546 else
46- namespace_inheritable ( :version , args )
47+ namespace_inheritable ( :version , requested_versions )
4748 namespace_inheritable ( :version_options , options )
4849 end
4950 end
Original file line number Diff line number Diff line change @@ -302,16 +302,27 @@ def subject.enable_root_route!
302302
303303 describe 'path versioned APIs' do
304304 before do
305- subject . version 'v1' , using : :path
305+ subject . version version , using : :path
306306 subject . enable_root_route!
307307 end
308308
309- it 'without a format' do
310- versioned_get '/' , 'v1' , using : :path
309+ context 'when a single version provided' do
310+ let ( :version ) { 'v1' }
311+
312+ it 'without a format' do
313+ versioned_get '/' , 'v1' , using : :path
314+ end
315+
316+ it 'with a format' do
317+ get '/v1/.json'
318+ end
311319 end
312320
313- it 'with a format' do
314- get '/v1/.json'
321+ context 'when array of versions provided' do
322+ let ( :version ) { %w( v1 v2 ) }
323+
324+ it { versioned_get '/' , 'v1' , using : :path }
325+ it { versioned_get '/' , 'v2' , using : :path }
315326 end
316327 end
317328
You can’t perform that action at this time.
0 commit comments