Set the record type for inherited serializers

This commit is contained in:
Erol 2018-07-17 11:54:48 +08:00 committed by Shishir Kakaraddi
parent 5aa5dc511c
commit 77c7af2a5e
2 changed files with 6 additions and 0 deletions

View File

@ -119,6 +119,7 @@ module FastJsonapi
subclass.race_condition_ttl = race_condition_ttl
subclass.data_links = data_links
subclass.cached = cached
subclass.set_type(subclass.reflected_record_type) if subclass.reflected_record_type
end
def reflected_record_type

View File

@ -95,6 +95,11 @@ describe FastJsonapi::ObjectSerializer do
has_one :account
end
it 'sets the correct record type' do
expect(EmployeeSerializer.reflected_record_type).to eq :employee
expect(EmployeeSerializer.record_type).to eq :employee
end
context 'when testing inheritance of attributes' do
it 'includes parent attributes' do