Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jsonapi_compliable/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def render_jsonapi(scope, opts = {})
opts = default_jsonapi_render_options.merge(opts)
opts = Util::RenderOptions.generate(scope, query_hash, opts)
opts[:expose][:context] = self
opts[:include] = deserialized_params.include_directive if force_includes?
opts[:include] ||= deserialized_params.include_directive if force_includes?
perform_render_jsonapi(opts)
end

Expand Down
10 changes: 10 additions & 0 deletions spec/jsonapi_compliable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,15 @@ def config(obj)
instance.render_jsonapi(Author.all, scope: false)
end
end
context 'when passing manual scope' do
it 'passes the manually included scope' do
author = Author.create!(first_name: 'Stephen', last_name: 'King')
author.books.create(title: "The Shining", genre: Genre.new(name: 'horror'))

expect(instance).to receive(:perform_render_jsonapi).with(hash_including(include: { foo: {}}))
instance.render_jsonapi(Author.all, { include: { foo: {} }, scope: false, meta: { foo: 'bar' } })
end
end

end
end