jsonapi-resources 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1484af26137219f05b85088a8ffcdf07c7bfd4d3
4
- data.tar.gz: 3b8441b43cab89ec1701343027d9308d8a9c523d
3
+ metadata.gz: ef3f720982dbbec9843218ac90131071c97bfb9c
4
+ data.tar.gz: 52fd35cd6696dfebf7b9fc69c8d22f09cffce8df
5
5
  SHA512:
6
- metadata.gz: a900be54a2ba2b6d3d4bba35e845960f50f4fae790a7b89168100419d1bb3451437acfd2700f5cbc309c52432e4980f059fc72eef628e9cbeaa19af7c66d8885
7
- data.tar.gz: 9698bf894815ee7b0a261bb7985c0cdf93a33083a1b640728cdbf7ad4850d1daca2ec3d5cfca2abe7635888a3a58e7e4c375f3c58877179ef2a07b6961c85a6d
6
+ metadata.gz: 6fec7c3f9bf100b0d4fd92fa4401285907529344e24eaa8d66fc82f5026911006102b1d72e4b39c688b83d4604ebbe66049f17c11487579f176c78b3165ec78c
7
+ data.tar.gz: 607f360e9517e3f80341426d1126875a798b969e7740f371804be072e7b47142c3d26181d1534f25b011fb260b8135b67e29f2622650b947b90733c32bc14fb1
@@ -77,7 +77,7 @@ module JSONAPI
77
77
 
78
78
  def engine_resource_path_name_from_source(source)
79
79
  scopes = module_scopes_from_class(source.class)[1..-1]
80
- base_path_name = scopes.map { |scope| scope.downcase }.join("_")
80
+ base_path_name = scopes.map { |scope| scope.underscore }.join("_")
81
81
  end_path_name = source.class._type.to_s.singularize
82
82
  "#{ base_path_name }_#{ end_path_name }_path"
83
83
  end
@@ -88,7 +88,7 @@ module JSONAPI
88
88
 
89
89
  def engine_resources_path_name_from_class(klass)
90
90
  scopes = module_scopes_from_class(klass)[1..-1]
91
- base_path_name = scopes.map { |scope| scope.downcase }.join("_")
91
+ base_path_name = scopes.map { |scope| scope.underscore }.join("_")
92
92
  end_path_name = klass._type.to_s
93
93
  "#{ base_path_name }_#{ end_path_name }_path"
94
94
  end
@@ -101,7 +101,7 @@ module JSONAPI
101
101
  scopes = module_scopes_from_class(klass)
102
102
 
103
103
  unless scopes.empty?
104
- "/#{ scopes.map(&:downcase).join('/') }/"
104
+ "/#{ scopes.map(&:underscore).join('/') }/"
105
105
  else
106
106
  "/"
107
107
  end
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Resources
3
- VERSION = '0.5.3'
3
+ VERSION = '0.5.4'
4
4
  end
5
5
  end
@@ -1233,6 +1233,13 @@ module Api
1233
1233
  end
1234
1234
  end
1235
1235
 
1236
+ module AdminApi
1237
+ module V1
1238
+ class PersonResource < JSONAPI::Resource
1239
+ end
1240
+ end
1241
+ end
1242
+
1236
1243
  module MyEngine
1237
1244
  module Api
1238
1245
  module V1
@@ -1240,6 +1247,13 @@ module MyEngine
1240
1247
  end
1241
1248
  end
1242
1249
  end
1250
+
1251
+ module AdminApi
1252
+ module V1
1253
+ class PersonResource < JSONAPI::Resource
1254
+ end
1255
+ end
1256
+ end
1243
1257
  end
1244
1258
 
1245
1259
  warn 'start testing Name Collisions'
data/test/test_helper.rb CHANGED
@@ -208,6 +208,12 @@ TestApp.routes.draw do
208
208
  end
209
209
  end
210
210
 
211
+ namespace :admin_api do
212
+ namespace :v1 do
213
+ jsonapi_resources :people
214
+ end
215
+ end
216
+
211
217
  mount MyEngine::Engine => "/boomshaka", as: :my_engine
212
218
  end
213
219
 
@@ -217,6 +223,12 @@ MyEngine::Engine.routes.draw do
217
223
  jsonapi_resources :people
218
224
  end
219
225
  end
226
+
227
+ namespace :admin_api do
228
+ namespace :v1 do
229
+ jsonapi_resources :people
230
+ end
231
+ end
220
232
  end
221
233
 
222
234
  # Ensure backward compatibility with Minitest 4
@@ -63,6 +63,22 @@ class LinkBuilderTest < ActionDispatch::IntegrationTest
63
63
  assert_equal expected_link, builder.self_link(source)
64
64
  end
65
65
 
66
+ def test_self_link_with_engine_app_and_camel_case_scope
67
+ primary_resource_klass = MyEngine::AdminApi::V1::PersonResource
68
+
69
+ config = {
70
+ base_url: @base_url,
71
+ route_formatter: @route_formatter,
72
+ primary_resource_klass: primary_resource_klass,
73
+ }
74
+
75
+ builder = JSONAPI::LinkBuilder.new(config)
76
+ source = primary_resource_klass.new(@steve)
77
+ expected_link = "#{ @base_url }/boomshaka/admin_api/v1/people/#{ source.id }"
78
+
79
+ assert_equal expected_link, builder.self_link(source)
80
+ end
81
+
66
82
  def test_primary_resources_url_for_regular_app
67
83
  config = {
68
84
  base_url: @base_url,
@@ -167,6 +183,20 @@ class LinkBuilderTest < ActionDispatch::IntegrationTest
167
183
  assert_equal expected_link, builder.query_link(query)
168
184
  end
169
185
 
186
+ def test_query_link_for_regular_app_with_camel_case_scope
187
+ config = {
188
+ base_url: @base_url,
189
+ route_formatter: @route_formatter,
190
+ primary_resource_klass: AdminApi::V1::PersonResource
191
+ }
192
+
193
+ query = { page: { offset: 0, limit: 12 } }
194
+ builder = JSONAPI::LinkBuilder.new(config)
195
+ expected_link = "#{ @base_url }/admin_api/v1/people?page%5Blimit%5D=12&page%5Boffset%5D=0"
196
+
197
+ assert_equal expected_link, builder.query_link(query)
198
+ end
199
+
170
200
  def test_query_link_for_engine
171
201
  config = {
172
202
  base_url: @base_url,
@@ -180,4 +210,18 @@ class LinkBuilderTest < ActionDispatch::IntegrationTest
180
210
 
181
211
  assert_equal expected_link, builder.query_link(query)
182
212
  end
213
+
214
+ def test_query_link_for_engine_with_camel_case_scope
215
+ config = {
216
+ base_url: @base_url,
217
+ route_formatter: @route_formatter,
218
+ primary_resource_klass: MyEngine::AdminApi::V1::PersonResource
219
+ }
220
+
221
+ query = { page: { offset: 0, limit: 12 } }
222
+ builder = JSONAPI::LinkBuilder.new(config)
223
+ expected_link = "#{ @base_url }/boomshaka/admin_api/v1/people?page%5Blimit%5D=12&page%5Boffset%5D=0"
224
+
225
+ assert_equal expected_link, builder.query_link(query)
226
+ end
183
227
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gebhardt