Skip to content

Commit

Permalink
Add an spec for ensuring the fix for filtering unpublished resources …
Browse files Browse the repository at this point in the history
…on array is working
  • Loading branch information
Gonzalo Muñoz committed Sep 12, 2019
1 parent 80c6fa2 commit b8b277d
Show file tree
Hide file tree
Showing 2 changed files with 341 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/array_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,31 @@ class CustomClass < Contentful::Entry; end
expect(dehydrated.first.inspect).to eq "<CustomClass[parent] id='5aV3O0l5jU0cwQ2OkyYsyU'>"
}
end

it 'filters out unpublished resources after rehydration' do
vcr('array/marshal_unpublished') {
parent = create_client(
space: 'z3eix6mwjid2',
access_token: '9047c4394a2130dff8e9dc544a7a3ec299703fdac8e52575eb5a6678be06c468',
dynamic_entries: :auto
).entries('sys.id': '5Etc0jWzIWwMeSu4W0SCi8')

rehydrated = Marshal.load(Marshal.dump(parent))

expect(rehydrated.first.children).to be_empty

preview_parent = create_client(
space: 'z3eix6mwjid2',
access_token: '38153b942011a70b5482fda61c6a3a9d22f5e8a512662dac00fcf7eb344b75f4',
dynamic_entries: :auto,
api_url: 'preview.contentful.com'
).entries('sys.id': '5Etc0jWzIWwMeSu4W0SCi8')

preview_rehydrated = Marshal.load(Marshal.dump(preview_parent))

expect(preview_rehydrated.first.children).not_to be_empty
expect(preview_rehydrated.first.children.first.title).to eq 'Child'
}
end
end
end
315 changes: 315 additions & 0 deletions spec/fixtures/vcr_cassettes/array/marshal_unpublished.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b8b277d

Please sign in to comment.