-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use records for joined resources for 0.10 (#1381)
Add tracking of join options for jsonapi-authorization gem Merge related `records` in `apply_join` Add `use_related_resource_records_for_joins` to configuration and relationships
- Loading branch information
Showing
8 changed files
with
176 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require File.expand_path('../../test_helper', __FILE__) | ||
|
||
class BookAuthorizationTest < ActionDispatch::IntegrationTest | ||
def setup | ||
DatabaseCleaner.start | ||
JSONAPI.configuration.json_key_format = :underscored_key | ||
JSONAPI.configuration.route_format = :underscored_route | ||
Api::V2::BookResource.paginator :offset | ||
end | ||
|
||
def test_restricted_records_primary | ||
Api::V2::BookResource.paginator :none | ||
|
||
# Not a book admin | ||
$test_user = Person.find(1001) | ||
assert_cacheable_jsonapi_get '/api/v2/books?filter[title]=Book%206' | ||
assert_equal 12, json_response['data'].size | ||
|
||
# book_admin | ||
$test_user = Person.find(1005) | ||
assert_cacheable_jsonapi_get '/api/v2/books?filter[title]=Book%206' | ||
assert_equal 111, json_response['data'].size | ||
end | ||
|
||
def test_restricted_records_related | ||
Api::V2::BookResource.paginator :none | ||
|
||
# Not a book admin | ||
$test_user = Person.find(1001) | ||
assert_cacheable_jsonapi_get '/api/v2/authors/1002/books' | ||
assert_equal 1, json_response['data'].size | ||
|
||
# book_admin | ||
$test_user = Person.find(1005) | ||
assert_cacheable_jsonapi_get '/api/v2/authors/1002/books' | ||
assert_equal 2, json_response['data'].size | ||
end | ||
end |
Oops, something went wrong.