You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The polymorphic test of the master branch leads me to a bit of confusion with the expected behavior of the returned serialization. Expected, from the example, I would think that imageable would identify the type and then there would be a lower association of 'employee' with the employee data
for our current test of 0.8.2, our test expected this behavior, and passed with a and 'asset' key, a 'type' attribute of 'transformed_image' and then a 'transformed_image' key of the subset of data.
it 'creates media specific JSON for a photo in a typical photo album' do
album = create(:album, :with_photos)
media = album.active_medias.first
parsed_json = ActiveModelSerializers::SerializableResource.new(media, {adapter: :json, include: '**', key_transform: true}).as_json
expect(parsed_json['id']).to eq media.id
expect(parsed_json['asset']['type']).to eq 'transformed_image'
expect(parsed_json['asset']['transformed_image']['id']).to eq media.asset.id
exp
when running with latest, all the transformed data is rolled up under asset, and really doesnt properly define the data.
Is this the expected data representation for polymorphs? There was an older thread/issue stating how an earlier version was improperly handing this, and that eventually got changed. I think that was for a pre 0.10 branch. Ill have to google fu a little more to find that thread. Any help on this would be much appreciated. Thanks!
The text was updated successfully, but these errors were encountered:
It appears that @marcgarreau has gotten the polymorphic relation to properly give the data (as Im desiring). Hoping this bat signal can bring him out for a little lend-of-hand to help me get my payload like that 👍
Conversed via @remear via Slack@help on this. It appears that this is the expected/intended behavior, but may not be the long term desire. He is looping back with @beauby on the direction/decisions of polymorphs. Ill dig in and try to make a PR for some type/nested handling
Expected behavior vs actual behavior
The polymorphic test of the master branch leads me to a bit of confusion with the expected behavior of the returned serialization. Expected, from the example, I would think that imageable would identify the type and then there would be a lower association of 'employee' with the employee data
active_model_serializers/test/adapter/polymorphic_test.rb
Line 31 in db87f8d
for our current test of 0.8.2, our test expected this behavior, and passed with a and 'asset' key, a 'type' attribute of 'transformed_image' and then a 'transformed_image' key of the subset of data.
when running with latest, all the transformed data is rolled up under asset, and really doesnt properly define the data.
Switching to json-api does provide a much closer representation
Is this the expected data representation for polymorphs? There was an older thread/issue stating how an earlier version was improperly handing this, and that eventually got changed. I think that was for a pre 0.10 branch. Ill have to google fu a little more to find that thread. Any help on this would be much appreciated. Thanks!
The text was updated successfully, but these errors were encountered: