Open
Description
When rendering document with conditional relationship which is not be rendered it is still rendered in included
documents.
require 'spec_helper'
describe JSONAPI::Serializable::Renderer, '#render_relationship' do
let(:posts) { [Post.new(id: 1), Post.new(id: 2)] }
let(:user) do
User.new(id: 'foo', name: 'Lucas', address: '22 Ruby drive', posts: posts)
end
it 'does not render included conditional relationship' do
klass = Class.new(JSONAPI::Serializable::Resource) do
extend JSONAPI::Serializable::Resource::ConditionalFields
type 'users'
has_many :posts, if: -> { false }
end
hash = subject.render(user,
include: [:posts],
class: { User: klass, Post: SerializablePost })
expect(hash).not_to have_key(:included)
end
end