Skip to content

Commit

Permalink
Fix multiple version definitions for path versioning
Browse files Browse the repository at this point in the history
Issue ruby-grape#1400

* New spec for this case

* Update CHANGELOG
  • Loading branch information
304 committed Jun 6, 2016
1 parent b9ba3d8 commit fae969a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [#1365](https://github.com/ruby-grape/grape/pull/1365): Fix finding exception handler in error middleware - [@ktimothy](https://github.com/ktimothy).
* [#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).
* [#1384](https://github.com/ruby-grape/grape/pull/1384): Fix parameter validation with an empty optional nested `Array` - [@ipkes](https://github.com/ipkes).
* [#1414](https://github.com/ruby-grape/grape/pull/1414): Fix multiple version definitions for path versioning - [@304](https://github.com/304).

0.16.2 (4/12/2016)
==================
Expand Down
1 change: 1 addition & 0 deletions lib/grape/dsl/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module ClassMethods
#
def version(*args, &block)
if args.any?
args.flatten!
options = args.extract_options!
options = options.reverse_merge(using: :path)

Expand Down
11 changes: 10 additions & 1 deletion spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ def subject.enable_root_route!
end

describe 'path versioned APIs' do
let(:version) { 'v1' }

before do
subject.version 'v1', using: :path
subject.version version, using: :path
subject.enable_root_route!
end

Expand All @@ -313,6 +315,13 @@ def subject.enable_root_route!
it 'with a format' do
get '/v1/.json'
end

context 'when array of versions provided' do
let(:version) { %w(v1 v2) }

it { versioned_get '/', 'v1', using: :path }
it { versioned_get '/', 'v2', using: :path }
end
end

it 'header versioned APIs' do
Expand Down

0 comments on commit fae969a

Please sign in to comment.