jsonapi-resources 0.5.6 → 0.5.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab4c4a0d0d8f176e2085aee265a0d0678876c8bd
|
4
|
+
data.tar.gz: 04ea25473f89a0bf77df0778b2ebaa7d4dd3aa8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19b8f700405d1caf6d676a1d984d8d2e0a82aa3d0df31b140d26484f318e74fc94311b4744e40d16ca7bf900a64a27a86351fe588bdee413569da5bbc299c63
|
7
|
+
data.tar.gz: 09b9a7ac8901f2b3c6ff218b8680c8cc313d806cfbd472989623f94871d95466375b6929cbfb2d48105799598a2fdeeee67fd27915fc054e1f53ea191a469d55
|
data/lib/jsonapi/operation.rb
CHANGED
@@ -158,7 +158,7 @@ module JSONAPI
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def records
|
161
|
-
related_resource_records = source_resource.
|
161
|
+
related_resource_records = source_resource.public_send(@relationship_type)
|
162
162
|
@resource_klass.filter_records(@filters, @options, related_resource_records)
|
163
163
|
end
|
164
164
|
|
data/lib/jsonapi/resource.rb
CHANGED
@@ -111,8 +111,8 @@ module JSONAPI
|
|
111
111
|
|
112
112
|
# Override this on a resource to customize how the associated records
|
113
113
|
# are fetched for a model. Particularly helpful for authorization.
|
114
|
-
def records_for(
|
115
|
-
model.public_send
|
114
|
+
def records_for(relation_name, _options = {})
|
115
|
+
model.public_send relation_name
|
116
116
|
end
|
117
117
|
|
118
118
|
private
|
@@ -410,7 +410,7 @@ class RequestTest < ActionDispatch::IntegrationTest
|
|
410
410
|
get '/api/v2/books/1/book_comments?page[limit]=10'
|
411
411
|
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=0', json_response['links']['first']
|
412
412
|
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=10', json_response['links']['next']
|
413
|
-
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=
|
413
|
+
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=16', json_response['links']['last']
|
414
414
|
end
|
415
415
|
|
416
416
|
def test_pagination_related_resources_links_meta
|
@@ -418,10 +418,10 @@ class RequestTest < ActionDispatch::IntegrationTest
|
|
418
418
|
Api::V2::BookCommentResource.paginator :offset
|
419
419
|
JSONAPI.configuration.top_level_meta_include_record_count = true
|
420
420
|
get '/api/v2/books/1/book_comments?page[limit]=10'
|
421
|
-
assert_equal
|
421
|
+
assert_equal 26, json_response['meta']['record_count']
|
422
422
|
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=0', json_response['links']['first']
|
423
423
|
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=10', json_response['links']['next']
|
424
|
-
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=
|
424
|
+
assert_equal 'http://www.example.com/api/v2/books/1/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=16', json_response['links']['last']
|
425
425
|
ensure
|
426
426
|
JSONAPI.configuration.top_level_meta_include_record_count = false
|
427
427
|
end
|
@@ -436,6 +436,18 @@ class RequestTest < ActionDispatch::IntegrationTest
|
|
436
436
|
assert_equal 'http://www.example.com/api/v2/books/10/book_comments?page%5Blimit%5D=10&page%5Boffset%5D=0', json_response['links']['last']
|
437
437
|
end
|
438
438
|
|
439
|
+
def test_related_resource_alternate_relation_name_record_count
|
440
|
+
original_config = JSONAPI.configuration.dup
|
441
|
+
JSONAPI.configuration.default_paginator = :paged
|
442
|
+
JSONAPI.configuration.top_level_meta_include_record_count = true
|
443
|
+
|
444
|
+
get '/api/v2/books/1/aliased_comments'
|
445
|
+
assert_equal 200, status
|
446
|
+
assert_equal 26, json_response['meta']['record_count']
|
447
|
+
ensure
|
448
|
+
JSONAPI.configuration = original_config
|
449
|
+
end
|
450
|
+
|
439
451
|
def test_pagination_related_resources_data_includes
|
440
452
|
Api::V2::BookResource.paginator :offset
|
441
453
|
Api::V2::BookCommentResource.paginator :offset
|
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.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Gebhardt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-08-
|
12
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|