contentful 2.16.0 → 2.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/lib/contentful/version.rb +1 -1
  4. metadata +3 -370
  5. data/.gitignore +0 -7
  6. data/.rspec +0 -1
  7. data/.rubocop.yml +0 -31
  8. data/.rubocop_todo.yml +0 -35
  9. data/.travis.yml +0 -15
  10. data/.yardopts +0 -4
  11. data/Gemfile +0 -9
  12. data/Guardfile +0 -24
  13. data/RELEASE.md +0 -8
  14. data/Rakefile +0 -33
  15. data/contentful.gemspec +0 -44
  16. data/examples/custom_classes.rb +0 -39
  17. data/examples/example_queries.rb +0 -26
  18. data/examples/raise_errors.rb +0 -20
  19. data/examples/raw_mode.rb +0 -14
  20. data/spec/array_spec.rb +0 -187
  21. data/spec/asset_spec.rb +0 -220
  22. data/spec/auto_includes_spec.rb +0 -12
  23. data/spec/client_class_spec.rb +0 -86
  24. data/spec/client_configuration_spec.rb +0 -394
  25. data/spec/content_type_spec.rb +0 -49
  26. data/spec/deleted_asset_spec.rb +0 -38
  27. data/spec/deleted_entry_spec.rb +0 -38
  28. data/spec/entry_spec.rb +0 -815
  29. data/spec/error_class_spec.rb +0 -327
  30. data/spec/error_requests_spec.rb +0 -87
  31. data/spec/field_spec.rb +0 -95
  32. data/spec/file_spec.rb +0 -33
  33. data/spec/fixtures/json_responses/400_details_errors_object.json +0 -14
  34. data/spec/fixtures/json_responses/400_details_errors_string.json +0 -12
  35. data/spec/fixtures/json_responses/400_details_string.json +0 -8
  36. data/spec/fixtures/json_responses/403_reasons.json +0 -13
  37. data/spec/fixtures/json_responses/404_details_string.json +0 -8
  38. data/spec/fixtures/json_responses/404_id.json +0 -11
  39. data/spec/fixtures/json_responses/404_sys_type.json +0 -12
  40. data/spec/fixtures/json_responses/404_type.json +0 -10
  41. data/spec/fixtures/json_responses/content_type.json +0 -83
  42. data/spec/fixtures/json_responses/default_400.json +0 -7
  43. data/spec/fixtures/json_responses/default_401.json +0 -7
  44. data/spec/fixtures/json_responses/default_403.json +0 -7
  45. data/spec/fixtures/json_responses/default_404.json +0 -7
  46. data/spec/fixtures/json_responses/default_429.json +0 -7
  47. data/spec/fixtures/json_responses/default_500.json +0 -7
  48. data/spec/fixtures/json_responses/default_502.json +0 -7
  49. data/spec/fixtures/json_responses/default_503.json +0 -7
  50. data/spec/fixtures/json_responses/includes.json +0 -111
  51. data/spec/fixtures/json_responses/link_array.json +0 -43
  52. data/spec/fixtures/json_responses/not_found.json +0 -13
  53. data/spec/fixtures/json_responses/nyancat.json +0 -48
  54. data/spec/fixtures/json_responses/other_error.json +0 -9
  55. data/spec/fixtures/json_responses/other_error_no_details.json +0 -8
  56. data/spec/fixtures/json_responses/other_error_no_message.json +0 -8
  57. data/spec/fixtures/json_responses/other_error_no_request_id.json +0 -8
  58. data/spec/fixtures/json_responses/other_error_nothing.json +0 -6
  59. data/spec/fixtures/json_responses/self_link.json +0 -82
  60. data/spec/fixtures/json_responses/unparsable.json +0 -13
  61. data/spec/fixtures/vcr_cassettes/array.yml +0 -288
  62. data/spec/fixtures/vcr_cassettes/array/marshal_custom_classes.yml +0 -159
  63. data/spec/fixtures/vcr_cassettes/array/marshal_unpublished.yml +0 -315
  64. data/spec/fixtures/vcr_cassettes/array/nested_resources.yml +0 -159
  65. data/spec/fixtures/vcr_cassettes/arrayField.yml +0 -87
  66. data/spec/fixtures/vcr_cassettes/array_page_1.yml +0 -106
  67. data/spec/fixtures/vcr_cassettes/array_page_2.yml +0 -73
  68. data/spec/fixtures/vcr_cassettes/asset.yml +0 -96
  69. data/spec/fixtures/vcr_cassettes/asset/select_empty_array.yml +0 -104
  70. data/spec/fixtures/vcr_cassettes/asset/select_no_sys.yml +0 -119
  71. data/spec/fixtures/vcr_cassettes/asset/select_one_field.yml +0 -97
  72. data/spec/fixtures/vcr_cassettes/asset/select_only_sys.yml +0 -88
  73. data/spec/fixtures/vcr_cassettes/asset/with_tags.yml +0 -138
  74. data/spec/fixtures/vcr_cassettes/assets/issues_129.yml +0 -90
  75. data/spec/fixtures/vcr_cassettes/assets/issues_jekyll_46.yml +0 -115
  76. data/spec/fixtures/vcr_cassettes/bad_request.yml +0 -76
  77. data/spec/fixtures/vcr_cassettes/content_type.yml +0 -147
  78. data/spec/fixtures/vcr_cassettes/entries.yml +0 -561
  79. data/spec/fixtures/vcr_cassettes/entries/empty_fields.yml +0 -246
  80. data/spec/fixtures/vcr_cassettes/entries/issue_117.yml +0 -201
  81. data/spec/fixtures/vcr_cassettes/entries/issue_125.yml +0 -198
  82. data/spec/fixtures/vcr_cassettes/entries/rich_text.yml +0 -1707
  83. data/spec/fixtures/vcr_cassettes/entries/rich_text_hydration_issue.yml +0 -460
  84. data/spec/fixtures/vcr_cassettes/entries/rich_text_nested_fields.yml +0 -653
  85. data/spec/fixtures/vcr_cassettes/entries/rich_text_unresolved_relationships.yml +0 -983
  86. data/spec/fixtures/vcr_cassettes/entries/unresolvable_assets.yml +0 -89
  87. data/spec/fixtures/vcr_cassettes/entries/unresolvable_filter.yml +0 -159
  88. data/spec/fixtures/vcr_cassettes/entries/unresolvable_filter_deeply_nested.yml +0 -167
  89. data/spec/fixtures/vcr_cassettes/entry.yml +0 -102
  90. data/spec/fixtures/vcr_cassettes/entry/custom_resource.yml +0 -168
  91. data/spec/fixtures/vcr_cassettes/entry/include_resolution.yml +0 -101
  92. data/spec/fixtures/vcr_cassettes/entry/include_resolution_uniques.yml +0 -81
  93. data/spec/fixtures/vcr_cassettes/entry/json_objects.yml +0 -88
  94. data/spec/fixtures/vcr_cassettes/entry/json_objects_client.yml +0 -86
  95. data/spec/fixtures/vcr_cassettes/entry/marshal_138.yml +0 -159
  96. data/spec/fixtures/vcr_cassettes/entry/marshal_unpublished.yml +0 -303
  97. data/spec/fixtures/vcr_cassettes/entry/marshall.yml +0 -293
  98. data/spec/fixtures/vcr_cassettes/entry/raw.yml +0 -201
  99. data/spec/fixtures/vcr_cassettes/entry/search_link_to_asset.yml +0 -81
  100. data/spec/fixtures/vcr_cassettes/entry/search_link_to_entry.yml +0 -81
  101. data/spec/fixtures/vcr_cassettes/entry/search_link_to_entry_with_custom_query.yml +0 -115
  102. data/spec/fixtures/vcr_cassettes/entry/select_empty_array.yml +0 -111
  103. data/spec/fixtures/vcr_cassettes/entry/select_no_sys.yml +0 -102
  104. data/spec/fixtures/vcr_cassettes/entry/select_one_field.yml +0 -76
  105. data/spec/fixtures/vcr_cassettes/entry/select_one_field_proper.yml +0 -114
  106. data/spec/fixtures/vcr_cassettes/entry/select_only_sys.yml +0 -111
  107. data/spec/fixtures/vcr_cassettes/entry/with_tags.yml +0 -238
  108. data/spec/fixtures/vcr_cassettes/entry_cache.yml +0 -288
  109. data/spec/fixtures/vcr_cassettes/entry_locales.yml +0 -104
  110. data/spec/fixtures/vcr_cassettes/field.yml +0 -147
  111. data/spec/fixtures/vcr_cassettes/human.yml +0 -118
  112. data/spec/fixtures/vcr_cassettes/linkField.yml +0 -83
  113. data/spec/fixtures/vcr_cassettes/locale.yml +0 -83
  114. data/spec/fixtures/vcr_cassettes/locale_from_environment.yml +0 -121
  115. data/spec/fixtures/vcr_cassettes/location.yml +0 -193
  116. data/spec/fixtures/vcr_cassettes/multi_locale_array_reference.yml +0 -196
  117. data/spec/fixtures/vcr_cassettes/multi_locale_reference.yml +0 -214
  118. data/spec/fixtures/vcr_cassettes/not_found.yml +0 -76
  119. data/spec/fixtures/vcr_cassettes/nyancat.yml +0 -102
  120. data/spec/fixtures/vcr_cassettes/query_array_1.yml +0 -89
  121. data/spec/fixtures/vcr_cassettes/query_array_2.yml +0 -89
  122. data/spec/fixtures/vcr_cassettes/ratelimit.yml +0 -64
  123. data/spec/fixtures/vcr_cassettes/ratelimit_retry.yml +0 -294
  124. data/spec/fixtures/vcr_cassettes/reloaded_entry.yml +0 -102
  125. data/spec/fixtures/vcr_cassettes/space.yml +0 -83
  126. data/spec/fixtures/vcr_cassettes/sync_deleted_asset.yml +0 -174
  127. data/spec/fixtures/vcr_cassettes/sync_deleted_entry.yml +0 -89
  128. data/spec/fixtures/vcr_cassettes/sync_deletion.yml +0 -191
  129. data/spec/fixtures/vcr_cassettes/sync_environment.yml +0 -81
  130. data/spec/fixtures/vcr_cassettes/sync_page.yml +0 -637
  131. data/spec/fixtures/vcr_cassettes/sync_page_2.yml +0 -71
  132. data/spec/fixtures/vcr_cassettes/sync_page_short.yml +0 -106
  133. data/spec/fixtures/vcr_cassettes/unauthorized.yml +0 -64
  134. data/spec/fixtures/vcr_cassettes/unavailable.yml +0 -76
  135. data/spec/link_spec.rb +0 -50
  136. data/spec/locale_spec.rb +0 -37
  137. data/spec/location_spec.rb +0 -25
  138. data/spec/request_spec.rb +0 -57
  139. data/spec/resource_building_spec.rb +0 -31
  140. data/spec/response_spec.rb +0 -62
  141. data/spec/space_spec.rb +0 -31
  142. data/spec/spec_helper.rb +0 -14
  143. data/spec/support/client.rb +0 -6
  144. data/spec/support/json_responses.rb +0 -18
  145. data/spec/support/vcr.rb +0 -16
  146. data/spec/sync_page_spec.rb +0 -103
  147. data/spec/sync_spec.rb +0 -180
data/.rubocop_todo.yml DELETED
@@ -1,35 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2016-02-02 13:30:13 -0300 using RuboCop version 0.36.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 6
10
- Metrics/AbcSize:
11
- Max: 38
12
-
13
- # Offense count: 5
14
- Metrics/CyclomaticComplexity:
15
- Max: 10
16
-
17
- # Offense count: 1
18
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
19
- # URISchemes: http, https
20
- Metrics/LineLength:
21
- Max: 142
22
-
23
- # Offense count: 12
24
- # Configuration parameters: CountComments.
25
- Metrics/MethodLength:
26
- Max: 27
27
-
28
- # Offense count: 2
29
- # Configuration parameters: CountComments.
30
- Metrics/ModuleLength:
31
- Max: 500
32
-
33
- # Offense count: 4
34
- Metrics/PerceivedComplexity:
35
- Max: 10
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.7.0
4
- - 2.6.1
5
- - 2.5.1
6
- - 2.4.1
7
- - 2.3.1
8
- notifications:
9
- slack:
10
- secure: Zr3mKCiTb0vaTD4MPtTG8BbyYyErFuoxioM25QyrqePKVkDFeZC1MtGmg5klQQrJiWTKZPa/zB8NAHYkoUxg9I+z15JK0hYfz9KRubEpCrXCaqTC9Vzq88kJ3LN8YsTyBF66izaBH2KLsOfaJRxwplFzZqgpg4GG2DUBPtrGtes=
11
- before_install: gem install bundler -v 1.10.6
12
- script: bundle exec rake rspec_rubocop
13
- matrix:
14
- allow_failures:
15
- - rvm: jruby
data/.yardopts DELETED
@@ -1,4 +0,0 @@
1
- --no-private
2
- -
3
- CHANGELOG.md
4
- LICENSE.txt
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- gem 'listen', '3.0.6'
6
-
7
- group :documentation do
8
- gem 'coveralls', :require => false
9
- end
data/Guardfile DELETED
@@ -1,24 +0,0 @@
1
- group :green_red_refactor, halt_on_fail: true do
2
- guard :rspec, cmd: "bundle exec rspec" do
3
- require "guard/rspec/dsl"
4
- dsl = Guard::RSpec::Dsl.new(self)
5
-
6
- # Feel free to open issues for suggestions and improvements
7
-
8
- # RSpec files
9
- rspec = dsl.rspec
10
- watch(rspec.spec_helper) { rspec.spec_dir }
11
- watch(rspec.spec_support) { rspec.spec_dir }
12
- watch(rspec.spec_files)
13
-
14
- # Ruby files
15
- ruby = dsl.ruby
16
- dsl.watch_spec_files_for(ruby.lib_files)
17
- end
18
-
19
- guard :yard, cmd: "yard doc" do
20
- end
21
-
22
- guard :rubocop, cmd: "rubocop" do
23
- end
24
- end
data/RELEASE.md DELETED
@@ -1,8 +0,0 @@
1
- # Releasing new versions:
2
-
3
- Make sure all points are taken care of:
4
-
5
- - [ ] Make sure tests are green.
6
- - [ ] Update Changelog: http://keepachangelog.com/
7
- - [ ] Bump version number: http://semver.org/
8
- - [ ] Release gem and communicate updates
data/Rakefile DELETED
@@ -1,33 +0,0 @@
1
- require 'rubygems'
2
-
3
- begin
4
- require 'bundler'
5
- rescue LoadError => e
6
- warn e.message
7
- warn 'Run `gem install bundler` to install Bundler.'
8
- exit -1
9
- end
10
-
11
- begin
12
- Bundler.setup(:development)
13
- rescue Bundler::BundlerError => e
14
- warn e.message
15
- warn 'Run `bundle install` to install missing gems.'
16
- exit e.status_code
17
- end
18
-
19
- require 'rake'
20
-
21
- require 'rubygems/tasks'
22
- Gem::Tasks.new
23
-
24
- require 'rspec/core/rake_task'
25
- RSpec::Core::RakeTask.new
26
-
27
- require 'rubocop/rake_task'
28
- RuboCop::RakeTask.new
29
-
30
- task rspec_rubocop: %w(spec rubocop)
31
-
32
- task test: :spec
33
- task default: :spec
data/contentful.gemspec DELETED
@@ -1,44 +0,0 @@
1
- require File.expand_path('../lib/contentful/version', __FILE__)
2
-
3
- Gem::Specification.new do |gem|
4
- gem.name = 'contentful'
5
- gem.version = Contentful::VERSION
6
- gem.summary = 'contentful'
7
- gem.description = 'Ruby client for the https://www.contentful.com Content Delivery API'
8
- gem.license = 'MIT'
9
- gem.authors = ['Contentful GmbH (Jan Lelis)', 'Contentful GmbH (Andreas Tiefenthaler)', 'Contentful GmbH (David Litvak Bruno)']
10
- gem.email = 'rubygems@contentful.com'
11
- gem.homepage = 'https://github.com/contentful/contentful.rb'
12
-
13
- gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) && !path.start_with?('pkg') }
14
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
15
- gem.test_files = gem.files.grep(%r{^spec/})
16
- gem.require_paths = ['lib']
17
-
18
- if RUBY_VERSION.start_with?('1.')
19
- gem.add_dependency 'http', '> 0.8', '< 2'
20
- gem.add_dependency 'json', '~> 1.0'
21
- gem.add_development_dependency'term-ansicolor', '~> 1.3.0'
22
- gem.add_development_dependency 'public_suffix', '< 1.5'
23
- else
24
- gem.add_dependency 'http', '> 0.8', '< 5.0'
25
- end
26
-
27
- gem.add_dependency 'multi_json', '~> 1'
28
-
29
- gem.add_development_dependency 'bundler'
30
- gem.add_development_dependency 'rake', '>= 12.3.3'
31
- gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
32
-
33
- gem.add_development_dependency 'guard'
34
- gem.add_development_dependency 'guard-rspec'
35
- gem.add_development_dependency 'guard-rubocop'
36
- gem.add_development_dependency 'guard-yard'
37
- gem.add_development_dependency 'rubocop', '~> 0.49.1'
38
- gem.add_development_dependency 'rspec', '~> 3'
39
- gem.add_development_dependency 'rr'
40
- gem.add_development_dependency 'vcr'
41
- gem.add_development_dependency 'simplecov'
42
- gem.add_development_dependency 'webmock'
43
- gem.add_development_dependency 'tins', '~> 1.6.0'
44
- end
@@ -1,39 +0,0 @@
1
- require 'contentful'
2
-
3
- # You can define your own custom classes that inherit from Contentful::Entry.
4
- # This allows you to define custom behaviour, for example, in this case, we want
5
- # the :country field to act as a Contentful::Locale
6
- class MyResource < Contentful::Entry
7
- def country(locale = nil)
8
- @country ||= Contentful::Locale.new(fields(locale)[:country])
9
- end
10
- end
11
-
12
- res = MyResource.new('fields' => {
13
- 'some' => 'value',
14
- 'age' => '25',
15
- 'country' => { 'code' => 'de', 'name' => 'Deutschland' },
16
- 'unknown_property' => 'ignored'
17
- })
18
-
19
- p res.some # => "value"
20
- p res.age # => 25
21
- p res.country # #<Contentful::Locale: ...
22
- p res.unknown_property # NoMethodError
23
-
24
- # To then have it mapped automatically from the client,
25
- # upon client instantiation, you set the :entry_mapping for your ContentType.
26
-
27
- client = Contentful::Client.new(
28
- space: 'your_space_id',
29
- access_token: 'your_access_token',
30
- entry_mapping: {
31
- 'myResource' => MyResource
32
- }
33
- )
34
-
35
- # We request the entries, entries of the 'myResource` content type,
36
- # will return MyResource class objects, while others will remain Contentful::Entry.
37
- client.entries.each { |e| puts e }
38
- # => <Contentful::Entry[other_content_type] id='foobar'>
39
- # => <MyResource[myResource] id='baz'>
@@ -1,26 +0,0 @@
1
- require 'contentful'
2
-
3
- client = Contentful::Client.new(
4
- space: 'cfexampleapi',
5
- access_token: 'b4c0n73n7fu1',
6
- )
7
-
8
- p client.space
9
-
10
- p client.content_types
11
-
12
- p client.entry 'nyancat', locale: 'tlh'
13
-
14
- p client.entries(
15
- 'content_type' => 'cat',
16
- 'fields.likes' => 'lasagna',
17
- )
18
-
19
- p client.entries(
20
- query: 'bacon',
21
- )
22
-
23
- p client.content_types(
24
- order: '-sys.updatedAt',
25
- limit: 3,
26
- )
@@ -1,20 +0,0 @@
1
- require 'contentful'
2
-
3
- client = Contentful::Client.new(
4
- space: 'cfexampleapi',
5
- access_token: 'b4c0n73n7fu1',
6
- )
7
-
8
- begin
9
- p client.asset 'not found'
10
- rescue => error
11
- p error
12
- end
13
-
14
- client2 = Contentful::Client.new(
15
- space: 'cfexampleapi',
16
- access_token: 'b4c0n73n7fu1',
17
- raise_errors: false,
18
- )
19
-
20
- p client2.asset 'not found'
data/examples/raw_mode.rb DELETED
@@ -1,14 +0,0 @@
1
- require 'contentful'
2
-
3
- client = Contentful::Client.new(
4
- space: 'cfexampleapi',
5
- access_token: 'b4c0n73n7fu1',
6
- raw_mode: true,
7
- )
8
-
9
- entry = client.entry 'nyancat'
10
- p entry.is_a? Contentful::Resource # false
11
- p entry.is_a? Contentful::Response # true
12
- p entry.status
13
- p entry
14
- puts entry.raw
data/spec/array_spec.rb DELETED
@@ -1,187 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class CustomClass < Contentful::Entry; end
4
-
5
- describe Contentful::Array do
6
- let(:client) { create_client }
7
- let(:array) { vcr('array') { client.content_types } }
8
-
9
- describe 'SystemProperties' do
10
- it 'has a #sys getter returning a hash with symbol keys' do
11
- expect(array.sys).to be_a Hash
12
- expect(array.sys.keys.sample).to be_a Symbol
13
- end
14
-
15
- it 'has #type' do
16
- expect(array.type).to eq 'Array'
17
- end
18
- end
19
-
20
- describe 'Properties' do
21
- it 'has #total' do
22
- expect(array.total).to eq 4
23
- end
24
-
25
- it 'has #skip' do
26
- expect(array.skip).to eq 0
27
- end
28
-
29
- it 'has #limit' do
30
- expect(array.limit).to eq 100
31
- end
32
-
33
- it 'has #items which contain resources' do
34
- expect(array.items).to be_a Array
35
- expect(array.items.sample).to be_a Contentful::BaseResource
36
- end
37
- end
38
-
39
- describe '#[]' do
40
- it 'provides access to items by index' do
41
- expect(array[0]).to be_a Contentful::BaseResource
42
- end
43
-
44
- it 'provides access to items by two indices' do
45
- expect(array[0, 4]).to eq array.items
46
- end
47
- end
48
-
49
- describe '#each' do
50
- it 'is an Enumerator' do
51
- expect(array.each).to be_a Enumerator
52
- end
53
-
54
- it 'iterates over items' do
55
- expect(array.each.to_a).to eq array.items
56
- end
57
-
58
- it 'includes Enumerable' do
59
- expect(array.map { |r| r.type }).to eq array.items.map { |r| r.type }
60
- end
61
- end
62
-
63
- describe "#to_ary" do
64
- it 'is an array' do
65
- expect(array.to_ary).to be_a ::Array
66
- end
67
-
68
- it 'returns items' do
69
- expect(array.to_ary).to eq array.items
70
- end
71
- end
72
-
73
- describe '#next_page' do
74
- it 'requests more of the same content from the server, using its limit and skip values' do
75
- array_page_1 = vcr('array_page_1') { create_client.content_types(skip: 3, limit: 2) }
76
- array_page_2 = vcr('array_page_2') { array_page_1.next_page(client) }
77
-
78
- expect(array_page_2).to be_a Contentful::Array
79
- expect(array_page_2.limit).to eq 2
80
- expect(array_page_2.skip).to eq 5
81
- end
82
-
83
- it 'will return false if #request not available' do
84
- expect(Contentful::Array.new({}).reload).to be_falsey
85
- end
86
-
87
- it 'respects query parameters' do
88
- array_page_1 = vcr('query_array_1') { client.entries(content_type: 'cat', limit: 1) }
89
- array_page_2 = vcr('query_array_2') { array_page_1.next_page(client) }
90
-
91
- expect(array_page_1).to be_a Contentful::Array
92
- expect(array_page_2).to be_a Contentful::Array
93
-
94
- expect(array_page_1.query).to include(content_type: 'cat')
95
- expect(array_page_2.query).to include(content_type: 'cat')
96
-
97
- expect(array_page_1.size).to eq 1
98
- expect(array_page_2.size).to eq 1
99
-
100
- expect(array_page_1[0].content_type.id).to eq 'cat'
101
- expect(array_page_2[0].content_type.id).to eq 'cat'
102
-
103
- expect(array_page_1[0].id).not_to eq array_page_2[0].id
104
- end
105
- end
106
-
107
- describe 'marshalling' do
108
- it 'marshals/unmarshals properly - #132' do
109
- re_array = Marshal.load(Marshal.dump(array))
110
-
111
- expect(re_array.endpoint).to eq array.endpoint
112
- expect(re_array.total).to eq array.total
113
- expect(re_array.limit).to eq array.limit
114
- expect(re_array.skip).to eq array.skip
115
- expect(re_array.items).to eq array.items
116
- end
117
-
118
- it 'marshals nested includes propertly - #138' do
119
- vcr('array/nested_resources') {
120
- client = create_client(
121
- space: 'j8tb59fszch7',
122
- access_token: '5f711401f965951eb724ac72ac905e13d892294ba209268f13a9b32e896c8694',
123
- dynamic_entries: :auto,
124
- max_include_resolution_depth: 5
125
- )
126
- entries = client.entries(content_type: 'child')
127
- rehydrated = Marshal.load(Marshal.dump(entries))
128
-
129
- expect(entries.inspect).to eq rehydrated.inspect
130
-
131
- expect(entries.first.image1.url).to eq rehydrated.first.image1.url
132
- expect(entries.last.image1.url).to eq rehydrated.last.image1.url
133
-
134
- expect(entries.first.image2.url).to eq rehydrated.first.image2.url
135
- expect(entries.last.image2.url).to eq rehydrated.last.image2.url
136
- }
137
- end
138
-
139
- it 'marshals custom resources properly - #138' do
140
- vcr('array/marshal_custom_classes') {
141
- client = create_client(
142
- space: 'j8tb59fszch7',
143
- access_token: '5f711401f965951eb724ac72ac905e13d892294ba209268f13a9b32e896c8694',
144
- dynamic_entries: :auto,
145
- max_include_resolution_depth: 5,
146
- entry_mapping: {
147
- 'parent' => CustomClass
148
- }
149
- )
150
-
151
- entries = client.entries(content_type: 'parent')
152
-
153
- expect(entries.first.inspect).to eq "<CustomClass[parent] id='5aV3O0l5jU0cwQ2OkyYsyU'>"
154
-
155
- dehydrated = Marshal.load(Marshal.dump(entries))
156
-
157
- expect(dehydrated.first.inspect).to eq "<CustomClass[parent] id='5aV3O0l5jU0cwQ2OkyYsyU'>"
158
- }
159
- end
160
-
161
- it 'filters out unpublished resources after rehydration' do
162
- vcr('array/marshal_unpublished') {
163
- parent = create_client(
164
- space: 'z3eix6mwjid2',
165
- access_token: '9047c4394a2130dff8e9dc544a7a3ec299703fdac8e52575eb5a6678be06c468',
166
- dynamic_entries: :auto
167
- ).entries('sys.id': '5Etc0jWzIWwMeSu4W0SCi8')
168
-
169
- rehydrated = Marshal.load(Marshal.dump(parent))
170
-
171
- expect(rehydrated.first.children).to be_empty
172
-
173
- preview_parent = create_client(
174
- space: 'z3eix6mwjid2',
175
- access_token: '38153b942011a70b5482fda61c6a3a9d22f5e8a512662dac00fcf7eb344b75f4',
176
- dynamic_entries: :auto,
177
- api_url: 'preview.contentful.com'
178
- ).entries('sys.id': '5Etc0jWzIWwMeSu4W0SCi8')
179
-
180
- preview_rehydrated = Marshal.load(Marshal.dump(preview_parent))
181
-
182
- expect(preview_rehydrated.first.children).not_to be_empty
183
- expect(preview_rehydrated.first.children.first.title).to eq 'Child'
184
- }
185
- end
186
- end
187
- end