Skip to content

Commit

Permalink
Fixes missing context on show_related_resources
Browse files Browse the repository at this point in the history
Fixes #763
  • Loading branch information
lgebhardt committed Aug 10, 2016
1 parent 747028b commit 5ecac75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jsonapi/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def show_related_resources
source_resource ||= source_klass.find_by_key(source_id, context: context, fields: fields)

related_resources = source_resource.public_send(relationship_type,
context: context,
filters: filters,
sort_criteria: sort_criteria,
paginator: paginator,
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,21 @@ class BreedsController < JSONAPI::ResourceController
end

class PlanetsController < JSONAPI::ResourceController
def context
{current_user: $test_user}
end
end

class PlanetTypesController < JSONAPI::ResourceController
def context
{current_user: $test_user}
end
end

class MoonsController < JSONAPI::ResourceController
def context
{current_user: $test_user}
end
end

class CratersController < JSONAPI::ResourceController
Expand Down

0 comments on commit 5ecac75

Please sign in to comment.