Skip to content

Commit e2bf541

Browse files
Erolshishirmk
authored andcommitted
Set the record type for inherited serializers
1 parent ab652c4 commit e2bf541

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

lib/fast_jsonapi/object_serializer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def inherited(subclass)
119119
subclass.race_condition_ttl = race_condition_ttl
120120
subclass.data_links = data_links
121121
subclass.cached = cached
122+
subclass.set_type(subclass.reflected_record_type) if subclass.reflected_record_type
122123
end
123124

124125
def reflected_record_type

spec/lib/object_serializer_inheritance_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ class EmployeeSerializer < UserSerializer
9595
has_one :account
9696
end
9797

98+
it 'sets the correct record type' do
99+
expect(EmployeeSerializer.reflected_record_type).to eq :employee
100+
expect(EmployeeSerializer.record_type).to eq :employee
101+
end
102+
98103
context 'when testing inheritance of attributes' do
99104

100105
it 'includes parent attributes' do

0 commit comments

Comments
 (0)