diff --git a/lib/fast_jsonapi/object_serializer.rb b/lib/fast_jsonapi/object_serializer.rb index 7d58e67..2cc1b35 100644 --- a/lib/fast_jsonapi/object_serializer.rb +++ b/lib/fast_jsonapi/object_serializer.rb @@ -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 diff --git a/spec/lib/object_serializer_inheritance_spec.rb b/spec/lib/object_serializer_inheritance_spec.rb index 8cf5b53..beb7487 100644 --- a/spec/lib/object_serializer_inheritance_spec.rb +++ b/spec/lib/object_serializer_inheritance_spec.rb @@ -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