grape-route-helpers 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83b55766476f52f66e8ca85e84cbb3982cc30ffc
4
- data.tar.gz: 4e95656ec76aec7d9c61c09ed5f8d3ecf9d82992
3
+ metadata.gz: 2bdf855209f4731d0d522b8e0b8a6df50913e437
4
+ data.tar.gz: 410ff06bb630ce4f87fe41a97ff9c7c610236235
5
5
  SHA512:
6
- metadata.gz: b0e423a706e7c000da1c40203dfa482e38582189521917dfa271ba5f024c9e3c9efc67d66dbaeff1651e2b15ab7655534d99ae5bc4035f00cf294478844df0b5
7
- data.tar.gz: 87182c670bca69856919540aba66c97d965d2c17c2da71cc94763561bc881e4ded309a9cf5d13e2846c875d62d512ebf0f657950351786a8c807acfb8b78a219
6
+ metadata.gz: 731a34ae06496c10f3fcd1e55bc6fdbc155f3c08559cab2843e35c3e7efe7006d90ac4192eb724299a8e8f120654ca0c3c7102d9b90012b9941311c0f801ae1b
7
+ data.tar.gz: e7f775f3fb66a7f8b7bd58ff124b5973a9d6a3df5dca087edc1d407535d4451bc36800a49e2eff90e78e536a4389dbf0af76dbcfa1eb7c7d3c0ae6047ae5832b
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## December 17 2016
4
+
5
+ * Bump to 2.1.0
6
+ * Fix bug that caused POST routes to be ignored if more than one was defined
7
+ * Many thanks to @njd5475 for the bug report and pull request that helped me write this
8
+
3
9
  ## April 28 2016
4
10
 
5
11
  * Release 2.0.0
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-route-helpers (2.0.0)
4
+ grape-route-helpers (2.1.0)
5
5
  activesupport
6
- grape
6
+ grape (>= 0.16.0)
7
7
  rake
8
8
 
9
9
  GEM
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
12
12
  gem.homepage = 'https://github.com/reprah/grape-route-helpers'
13
13
 
14
- gem.add_runtime_dependency 'grape', '~> 0.16', '>= 0.16.0'
14
+ gem.add_runtime_dependency 'grape', '>= 0.16.0'
15
15
  gem.add_runtime_dependency 'activesupport'
16
16
  gem.add_runtime_dependency 'rake'
17
17
 
@@ -10,7 +10,7 @@ module GrapeRouteHelpers
10
10
 
11
11
  def all_routes
12
12
  routes = subclasses.flat_map { |s| s.send(:prepare_routes) }
13
- routes.uniq(&:options)
13
+ routes.uniq { |r| r.options.merge(path: r.path) }
14
14
  end
15
15
  end
16
16
  end
@@ -1,4 +1,4 @@
1
1
  # Gem version
2
2
  module GrapeRouteHelpers
3
- VERSION = '2.0.0'
3
+ VERSION = '2.1.0'
4
4
  end
@@ -12,7 +12,7 @@ describe GrapeRouteHelpers::AllRoutes do
12
12
 
13
13
  # A route is unique if no other route shares the same set of options
14
14
  all_route_options = Grape::API.all_routes.map do |r|
15
- r.instance_variable_get(:@options)
15
+ r.instance_variable_get(:@options).merge(path: r.path)
16
16
  end
17
17
 
18
18
  duplicates = all_route_options.select do |o|
@@ -20,7 +20,15 @@ describe GrapeRouteHelpers::AllRoutes do
20
20
  end
21
21
 
22
22
  expect(duplicates).to be_empty
23
- expect(all_route_options.size).to eq(7)
23
+ end
24
+ end
25
+
26
+ context 'when there are multiple POST routes with the same namespace in the same API' do
27
+ it 'returns all POST routes' do
28
+ expected_routes = Spec::Support::MultiplePostsAPI.routes.map(&:path)
29
+
30
+ all_routes = Grape::API.all_routes
31
+ expect(all_routes.map(&:path)).to include(*expected_routes)
24
32
  end
25
33
  end
26
34
  end
@@ -60,6 +60,14 @@ describe GrapeRouteHelpers::DecoratedRoute do
60
60
  end
61
61
  end
62
62
 
63
+ context 'when an API has multiple POST routes in a resource' do
64
+ let(:api) { Spec::Support::MultiplePostsAPI }
65
+
66
+ it 'it creates a helper for each POST route' do
67
+ expect(routes.size).to eq(2)
68
+ end
69
+ end
70
+
63
71
  context 'when an API has multiple versions' do
64
72
  let(:api) { Spec::Support::APIWithMultipleVersions }
65
73
 
@@ -54,5 +54,16 @@ module Spec
54
54
  'pong'
55
55
  end
56
56
  end
57
+
58
+ # API with multiple POST routes
59
+ class MultiplePostsAPI < Grape::API
60
+ resource :hamlet do
61
+ post 'to_be' do
62
+ end
63
+
64
+ post 'or_not_to_be' do
65
+ end
66
+ end
67
+ end
57
68
  end
58
69
  end
metadata CHANGED
@@ -1,22 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-route-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harper Henn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.16'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: 0.16.0
@@ -24,9 +21,6 @@ dependencies:
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '0.16'
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
26
  version: 0.16.0