Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix marshal load of array for drafted/deleted child entries #207

Closed
wants to merge 2 commits into from

Conversation

HQ063
Copy link

@HQ063 HQ063 commented Sep 12, 2019

The current behaviour for deleted/drafted entries it's different for retrieved and unserialized arrays.

Let's suppose I have a model with some reference array field. And let's suppose I have a published entry with some unpublished entries on that referenced on that field.
This is the current behaviour for requested arrays:

entries = client.entries(some_query)
# => <Contentful::Array total=1 skip=0 limit=100>
entries.first.raw['fields']['children']
# => [{"sys"=>{"type"=>"Link", "linkType"=>"Entry", "id"=>"6ZEkh78aryxwWinQhB2MNq"}}]
entries.first.children
# => []

That is the right and expected behaviour, ignoring drafted entries. However, if we do the same after serializing and unserializing the array:

Marshal.load(Marshal.dump(entries)).first.children
# => [<Contentful::Link id='6ZEkh78aryxwWinQhB2MNq'>]

This fix should solve that issue by sending the errors to the ResourceBuilder

HQ063 and others added 2 commits September 12, 2019 12:07
The current behaviour for deleted/drafted entries it's different for retrieved and unserialized arrays.

Let's suppose I have a model with some reference array field. And let's suppose I have a published entry with some unpublished entries on that referenced on that field.
This is the current behaviour for requested arrays:
```ruby
entries = client.entries(some_query)
entries.first.raw['fields']['children']
entries.first.children
```
That is the right and expected behaviour, ignoring drafted entries. However, if we do the same after serializing and unserializing the array:
```ruby
Marshal.load(Marshal.dump(entries)).first.children
```

This fix should solve that issue by sending the errors to the ResourceBuilder
@dlitvakb
Copy link
Contributor

Will merge tomorrow!

Gracias!

PS: @HQ063 can you revoke that access token? Given that you're also providing a Preview token, it's not advisable to make Preview tokens public. Once you revoke it, it should no longer be valid again, but the recording file for the specs will still keep working.

@HQ063
Copy link
Author

HQ063 commented Sep 12, 2019

I took the tokens and entries from another existing spec, they're not from a space I own. https://github.com/contentful/contentful.rb/blob/master/spec/entry_spec.rb#L196

@dlitvakb
Copy link
Contributor

Hey @HQ063,

Just merged it through a different PR,

Thanks for fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants