contentful-management 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/.reek +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +408 -0
- data/Rakefile +37 -0
- data/bin/cma-console +8 -0
- data/contentful-management.gemspec +33 -0
- data/examples/blog.rb +82 -0
- data/examples/content_types.rb +45 -0
- data/examples/create_space.rb +35 -0
- data/lib/contentful/management.rb +12 -0
- data/lib/contentful/management/array.rb +35 -0
- data/lib/contentful/management/asset.rb +163 -0
- data/lib/contentful/management/client.rb +160 -0
- data/lib/contentful/management/content_type.rb +180 -0
- data/lib/contentful/management/dynamic_entry.rb +71 -0
- data/lib/contentful/management/entry.rb +213 -0
- data/lib/contentful/management/error.rb +62 -0
- data/lib/contentful/management/field.rb +34 -0
- data/lib/contentful/management/file.rb +15 -0
- data/lib/contentful/management/http_client.rb +22 -0
- data/lib/contentful/management/link.rb +23 -0
- data/lib/contentful/management/locale.rb +48 -0
- data/lib/contentful/management/location.rb +15 -0
- data/lib/contentful/management/request.rb +82 -0
- data/lib/contentful/management/resource.rb +166 -0
- data/lib/contentful/management/resource/array_like.rb +37 -0
- data/lib/contentful/management/resource/fields.rb +69 -0
- data/lib/contentful/management/resource/refresher.rb +21 -0
- data/lib/contentful/management/resource/system_properties.rb +56 -0
- data/lib/contentful/management/resource_builder.rb +269 -0
- data/lib/contentful/management/response.rb +72 -0
- data/lib/contentful/management/space.rb +159 -0
- data/lib/contentful/management/support.rb +24 -0
- data/lib/contentful/management/version.rb +6 -0
- data/spec/fixtures/vcr_cassettes/array_page_1.yml +1337 -0
- data/spec/fixtures/vcr_cassettes/asset/all.yml +611 -0
- data/spec/fixtures/vcr_cassettes/asset/archive.yml +228 -0
- data/spec/fixtures/vcr_cassettes/asset/archive_published.yml +177 -0
- data/spec/fixtures/vcr_cassettes/asset/archived_false.yml +228 -0
- data/spec/fixtures/vcr_cassettes/asset/archived_true.yml +228 -0
- data/spec/fixtures/vcr_cassettes/asset/create.yml +150 -0
- data/spec/fixtures/vcr_cassettes/asset/create_with_already_used_id.yml +56 -0
- data/spec/fixtures/vcr_cassettes/asset/create_with_custom_id.yml +150 -0
- data/spec/fixtures/vcr_cassettes/asset/destroy.yml +159 -0
- data/spec/fixtures/vcr_cassettes/asset/destroy_published.yml +175 -0
- data/spec/fixtures/vcr_cassettes/asset/find.yml +108 -0
- data/spec/fixtures/vcr_cassettes/asset/find_not_found.yml +64 -0
- data/spec/fixtures/vcr_cassettes/asset/image_url.yml +133 -0
- data/spec/fixtures/vcr_cassettes/asset/locale.yml +110 -0
- data/spec/fixtures/vcr_cassettes/asset/publish.yml +228 -0
- data/spec/fixtures/vcr_cassettes/asset/publish_already_published.yml +176 -0
- data/spec/fixtures/vcr_cassettes/asset/published_false.yml +228 -0
- data/spec/fixtures/vcr_cassettes/asset/published_true.yml +226 -0
- data/spec/fixtures/vcr_cassettes/asset/save_update.yml +242 -0
- data/spec/fixtures/vcr_cassettes/asset/set_locale.yml +110 -0
- data/spec/fixtures/vcr_cassettes/asset/unarchive.yml +228 -0
- data/spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchive.yml +168 -0
- data/spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchived.yml +168 -0
- data/spec/fixtures/vcr_cassettes/asset/unpublish.yml +228 -0
- data/spec/fixtures/vcr_cassettes/asset/unpublish_already_unpublished.yml +168 -0
- data/spec/fixtures/vcr_cassettes/asset/update_file.yml +207 -0
- data/spec/fixtures/vcr_cassettes/asset/update_to_specified_locale.yml +224 -0
- data/spec/fixtures/vcr_cassettes/asset/update_with_default_locale_without_file.yml +214 -0
- data/spec/fixtures/vcr_cassettes/content_type/activate.yml +246 -0
- data/spec/fixtures/vcr_cassettes/content_type/activate_with_invalid_version.yml +186 -0
- data/spec/fixtures/vcr_cassettes/content_type/activated_false.yml +246 -0
- data/spec/fixtures/vcr_cassettes/content_type/activated_true.yml +257 -0
- data/spec/fixtures/vcr_cassettes/content_type/all.yml +190 -0
- data/spec/fixtures/vcr_cassettes/content_type/create.yml +87 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_content_type_with_id.yml +87 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Array_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Boolean_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Date_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Integer_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Link_field.yml +95 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Location_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Number_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Object_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Symbol_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/create_with_Text_field.yml +94 -0
- data/spec/fixtures/vcr_cassettes/content_type/deactivate.yml +246 -0
- data/spec/fixtures/vcr_cassettes/content_type/deactivate_already_deactivated.yml +176 -0
- data/spec/fixtures/vcr_cassettes/content_type/deactivate_with_entries.yml +236 -0
- data/spec/fixtures/vcr_cassettes/content_type/deactivate_with_version_change.yml +248 -0
- data/spec/fixtures/vcr_cassettes/content_type/destroy.yml +148 -0
- data/spec/fixtures/vcr_cassettes/content_type/destroy_activated.yml +164 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/create.yml +1344 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_camel_case_id_to_multiple_locales.yml +235 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries.yml +398 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries_for_multiple_locales.yml +3157 -0
- data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_multiple_locales.yml +230 -0
- data/spec/fixtures/vcr_cassettes/content_type/fields/add.yml +345 -0
- data/spec/fixtures/vcr_cassettes/content_type/fields/create.yml +353 -0
- data/spec/fixtures/vcr_cassettes/content_type/fields/create_array_with_params.yml +228 -0
- data/spec/fixtures/vcr_cassettes/content_type/fields/create_with_params.yml +221 -0
- data/spec/fixtures/vcr_cassettes/content_type/fields/destroy.yml +349 -0
- data/spec/fixtures/vcr_cassettes/content_type/fields/update_field.yml +358 -0
- data/spec/fixtures/vcr_cassettes/content_type/find.yml +180 -0
- data/spec/fixtures/vcr_cassettes/content_type/find_not_found.yml +64 -0
- data/spec/fixtures/vcr_cassettes/content_type/save_new.yml +876 -0
- data/spec/fixtures/vcr_cassettes/content_type/save_updated.yml +345 -0
- data/spec/fixtures/vcr_cassettes/content_type/save_with_added_field.yml +217 -0
- data/spec/fixtures/vcr_cassettes/content_type/update.yml +175 -0
- data/spec/fixtures/vcr_cassettes/content_type/update_change_field_name.yml +222 -0
- data/spec/fixtures/vcr_cassettes/content_type/update_remove_field.yml +231 -0
- data/spec/fixtures/vcr_cassettes/content_type/update_with_fields.yml +222 -0
- data/spec/fixtures/vcr_cassettes/content_type/update_with_one_new_field.yml +251 -0
- data/spec/fixtures/vcr_cassettes/entry/all.yml +139 -0
- data/spec/fixtures/vcr_cassettes/entry/archive.yml +222 -0
- data/spec/fixtures/vcr_cassettes/entry/archive_published.yml +187 -0
- data/spec/fixtures/vcr_cassettes/entry/archived_false.yml +178 -0
- data/spec/fixtures/vcr_cassettes/entry/archived_true.yml +248 -0
- data/spec/fixtures/vcr_cassettes/entry/create.yml +245 -0
- data/spec/fixtures/vcr_cassettes/entry/create_test.yml +150 -0
- data/spec/fixtures/vcr_cassettes/entry/create_with_asset.yml +403 -0
- data/spec/fixtures/vcr_cassettes/entry/create_with_assets.yml +419 -0
- data/spec/fixtures/vcr_cassettes/entry/create_with_entries.yml +418 -0
- data/spec/fixtures/vcr_cassettes/entry/create_with_entry.yml +493 -0
- data/spec/fixtures/vcr_cassettes/entry/create_with_location.yml +259 -0
- data/spec/fixtures/vcr_cassettes/entry/create_with_symbols.yml +271 -0
- data/spec/fixtures/vcr_cassettes/entry/destory_published.yml +172 -0
- data/spec/fixtures/vcr_cassettes/entry/destroy.yml +156 -0
- data/spec/fixtures/vcr_cassettes/entry/find.yml +129 -0
- data/spec/fixtures/vcr_cassettes/entry/find_not_found.yml +64 -0
- data/spec/fixtures/vcr_cassettes/entry/publish.yml +248 -0
- data/spec/fixtures/vcr_cassettes/entry/publish_already_published.yml +186 -0
- data/spec/fixtures/vcr_cassettes/entry/published_false.yml +248 -0
- data/spec/fixtures/vcr_cassettes/entry/published_true.yml +257 -0
- data/spec/fixtures/vcr_cassettes/entry/save_update.yml +211 -0
- data/spec/fixtures/vcr_cassettes/entry/unarchive.yml +248 -0
- data/spec/fixtures/vcr_cassettes/entry/unarchive_already_unarchived.yml +178 -0
- data/spec/fixtures/vcr_cassettes/entry/unpublish.yml +248 -0
- data/spec/fixtures/vcr_cassettes/entry/unpublish_already_unpublished.yml +178 -0
- data/spec/fixtures/vcr_cassettes/entry/update.yml +626 -0
- data/spec/fixtures/vcr_cassettes/entry/update_unlocalized_field.yml +308 -0
- data/spec/fixtures/vcr_cassettes/entry/update_with_custom_locale.yml +332 -0
- data/spec/fixtures/vcr_cassettes/get_request.yml +37 -0
- data/spec/fixtures/vcr_cassettes/locale/all_for_space.yml +321 -0
- data/spec/fixtures/vcr_cassettes/locale/create_for_space.yml +95 -0
- data/spec/fixtures/vcr_cassettes/locale/find.yml +95 -0
- data/spec/fixtures/vcr_cassettes/locale/find_for_space_not_found.yml +67 -0
- data/spec/fixtures/vcr_cassettes/space/all.yml +1201 -0
- data/spec/fixtures/vcr_cassettes/space/asset/all.yml +475 -0
- data/spec/fixtures/vcr_cassettes/space/asset/assets.yml +826 -0
- data/spec/fixtures/vcr_cassettes/space/asset/create.yml +508 -0
- data/spec/fixtures/vcr_cassettes/space/asset/create_with_multiple_locales.yml +1062 -0
- data/spec/fixtures/vcr_cassettes/space/asset/find.yml +634 -0
- data/spec/fixtures/vcr_cassettes/space/content_type/all.yml +470 -0
- data/spec/fixtures/vcr_cassettes/space/content_type/content_types.yml +341 -0
- data/spec/fixtures/vcr_cassettes/space/content_type/create.yml +425 -0
- data/spec/fixtures/vcr_cassettes/space/content_type/find.yml +493 -0
- data/spec/fixtures/vcr_cassettes/space/create.yml +85 -0
- data/spec/fixtures/vcr_cassettes/space/create_when_limit_has_been_reached.yml +67 -0
- data/spec/fixtures/vcr_cassettes/space/create_with_unknown_organization.yml +65 -0
- data/spec/fixtures/vcr_cassettes/space/create_without_organization.yml +83 -0
- data/spec/fixtures/vcr_cassettes/space/destory.yml +196 -0
- data/spec/fixtures/vcr_cassettes/space/entry/all.yml +634 -0
- data/spec/fixtures/vcr_cassettes/space/entry/entries.yml +498 -0
- data/spec/fixtures/vcr_cassettes/space/entry/find.yml +624 -0
- data/spec/fixtures/vcr_cassettes/space/find.yml +270 -0
- data/spec/fixtures/vcr_cassettes/space/find_not_found.yml +67 -0
- data/spec/fixtures/vcr_cassettes/space/locale/all.yml +690 -0
- data/spec/fixtures/vcr_cassettes/space/locale/create.yml +572 -0
- data/spec/fixtures/vcr_cassettes/space/locale/create_with_the_same_code.yml +585 -0
- data/spec/fixtures/vcr_cassettes/space/locale/find.yml +572 -0
- data/spec/fixtures/vcr_cassettes/space/locale/find_not_found.yml +580 -0
- data/spec/fixtures/vcr_cassettes/space/locale/locales.yml +480 -0
- data/spec/fixtures/vcr_cassettes/space/locale/update.yml +700 -0
- data/spec/fixtures/vcr_cassettes/space/save_new_space.yml +67 -0
- data/spec/fixtures/vcr_cassettes/space/save_update_space.yml +352 -0
- data/spec/fixtures/vcr_cassettes/space/update.yml +350 -0
- data/spec/fixtures/vcr_cassettes/space/update_with_the_same_data.yml +350 -0
- data/spec/lib/contentful/management/array_spec.rb +59 -0
- data/spec/lib/contentful/management/asset_spec.rb +321 -0
- data/spec/lib/contentful/management/client_spec.rb +80 -0
- data/spec/lib/contentful/management/content_type_spec.rb +455 -0
- data/spec/lib/contentful/management/entry_spec.rb +308 -0
- data/spec/lib/contentful/management/locale_spec.rb +53 -0
- data/spec/lib/contentful/management/space_spec.rb +317 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/vcr.rb +17 -0
- metadata +554 -0
@@ -0,0 +1,308 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'contentful/management/space'
|
4
|
+
require 'contentful/management/client'
|
5
|
+
|
6
|
+
module Contentful
|
7
|
+
module Management
|
8
|
+
describe Entry do
|
9
|
+
let(:token) { '<ACCESS_TOKEN>' }
|
10
|
+
let(:space_id) { 'yr5m0jky5hsh' }
|
11
|
+
let(:entry_id) { '4Rouux8SoUCKwkyCq2I0E0' }
|
12
|
+
|
13
|
+
let!(:client) { Client.new(token) }
|
14
|
+
|
15
|
+
subject { Contentful::Management::Entry }
|
16
|
+
|
17
|
+
describe '.all' do
|
18
|
+
it 'returns a Contentful::Array' do
|
19
|
+
vcr('entry/all') { expect(subject.all(space_id)).to be_kind_of Contentful::Management::Array }
|
20
|
+
end
|
21
|
+
it 'builds a Contentful::Management::Entry object' do
|
22
|
+
vcr('entry/all') { expect(subject.all(space_id).first).to be_kind_of Contentful::Management::Entry }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#find' do
|
27
|
+
it 'returns a Contentful::Management::Entry' do
|
28
|
+
vcr('entry/find') { expect(subject.find(space_id, entry_id)).to be_kind_of Contentful::Management::Entry }
|
29
|
+
end
|
30
|
+
it 'returns the entry for a given key' do
|
31
|
+
vcr('entry/find') do
|
32
|
+
entry = subject.find(space_id, entry_id)
|
33
|
+
expect(entry.id).to eql entry_id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
it 'returns an error when entry does not exists' do
|
37
|
+
vcr('entry/find_not_found') do
|
38
|
+
result = subject.find(space_id, 'not_exist')
|
39
|
+
expect(result).to be_kind_of Contentful::Management::NotFound
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#destroy' do
|
45
|
+
it 'returns Contentful::BadRequest error when content type is published' do
|
46
|
+
vcr('entry/destory_published') do
|
47
|
+
result = subject.find(space_id, '3U7JqGuVzOWIimU40mKeem').destroy
|
48
|
+
expect(result).to be_kind_of Contentful::Management::BadRequest
|
49
|
+
expect(result.message).to eq 'Cannot deleted published'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
it 'returns true when entry is not published' do
|
53
|
+
vcr('entry/destroy') do
|
54
|
+
result = subject.find(space_id, '3U7JqGuVzOWIimU40mKeem').destroy
|
55
|
+
expect(result).to eq true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#unpublish' do
|
61
|
+
it 'unpublish the entry' do
|
62
|
+
vcr('entry/unpublish') do
|
63
|
+
entry = subject.find(space_id, entry_id)
|
64
|
+
initial_version = entry.sys[:version]
|
65
|
+
entry.unpublish
|
66
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
67
|
+
expect(entry.sys[:version]).to eql initial_version + 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns BadRequest error when already unpublished' do
|
72
|
+
vcr('entry/unpublish_already_unpublished') do
|
73
|
+
result = subject.find(space_id, entry_id).unpublish
|
74
|
+
expect(result).to be_kind_of Contentful::Management::BadRequest
|
75
|
+
expect(result.message).to eq 'Not published'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#publish' do
|
81
|
+
it 'returns Contentful::Management::Entry' do
|
82
|
+
vcr('entry/publish') do
|
83
|
+
entry = subject.find(space_id, entry_id)
|
84
|
+
initial_version = entry.sys[:version]
|
85
|
+
entry.publish
|
86
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
87
|
+
expect(entry.sys[:version]).to eql initial_version + 1
|
88
|
+
end
|
89
|
+
end
|
90
|
+
it 'returns BadRequest error when already published' do
|
91
|
+
vcr('entry/publish_already_published') do
|
92
|
+
entry = subject.find(space_id, entry_id)
|
93
|
+
entry.sys[:version] = -1
|
94
|
+
result = entry.publish
|
95
|
+
expect(result).to be_kind_of Contentful::Management::BadRequest
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#published?' do
|
101
|
+
it 'returns true if entry is published' do
|
102
|
+
vcr('entry/published_true') do
|
103
|
+
entry = subject.find(space_id, entry_id)
|
104
|
+
entry.publish
|
105
|
+
expect(entry.published?).to be_truthy
|
106
|
+
end
|
107
|
+
end
|
108
|
+
it 'returns false if entry is not published' do
|
109
|
+
vcr('entry/published_false') do
|
110
|
+
entry = subject.find(space_id, entry_id)
|
111
|
+
entry.unpublish
|
112
|
+
expect(entry.published?).to be_falsey
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#unarchive' do
|
118
|
+
it 'unarchive the entry' do
|
119
|
+
vcr('entry/unarchive') do
|
120
|
+
entry = subject.find(space_id, entry_id)
|
121
|
+
initial_version = entry.sys[:version]
|
122
|
+
entry.unarchive
|
123
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
124
|
+
expect(entry.sys[:version]).to eql initial_version + 1
|
125
|
+
end
|
126
|
+
end
|
127
|
+
it 'returns BadRequest error when already unpublished' do
|
128
|
+
vcr('entry/unarchive_already_unarchived') do
|
129
|
+
result = subject.find(space_id, entry_id).unarchive
|
130
|
+
expect(result).to be_kind_of Contentful::Management::BadRequest
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'returns BadRequest error when already unarchived' do
|
135
|
+
vcr('entry/unarchive_already_unarchived') do
|
136
|
+
result = subject.find(space_id, entry_id).unarchive
|
137
|
+
expect(result).to be_kind_of Contentful::Management::BadRequest
|
138
|
+
expect(result.message).to eql 'Not archived'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#archive' do
|
144
|
+
it 'entry' do
|
145
|
+
vcr(:'entry/archive') do
|
146
|
+
entry = subject.find(space_id, '3U7JqGuVzOWIimU40mKeem')
|
147
|
+
initial_version = entry.sys[:version]
|
148
|
+
entry.archive
|
149
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
150
|
+
expect(entry.sys[:version]).to eql initial_version + 1
|
151
|
+
end
|
152
|
+
end
|
153
|
+
it 'returns error when archive published entry' do
|
154
|
+
vcr('entry/archive_published') do
|
155
|
+
entry = subject.find(space_id, entry_id).archive
|
156
|
+
expect(entry).to be_kind_of Contentful::Management::BadRequest
|
157
|
+
expect(entry.message).to eql 'Cannot archive published'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#archived?' do
|
163
|
+
it 'returns true if entry is archived' do
|
164
|
+
vcr('entry/archived_true') do
|
165
|
+
entry = subject.find(space_id, entry_id)
|
166
|
+
entry.archive
|
167
|
+
expect(entry.archived?).to be_truthy
|
168
|
+
end
|
169
|
+
end
|
170
|
+
it 'returns false if entry is not archived' do
|
171
|
+
vcr('entry/archived_false') do
|
172
|
+
entry = subject.find(space_id, entry_id)
|
173
|
+
entry.unarchive
|
174
|
+
expect(entry.archived?).to be_falsey
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe '.create' do
|
180
|
+
let(:content_type_id) { '5DSpuKrl04eMAGQoQckeIq' }
|
181
|
+
let(:content_type) { Contentful::Management::ContentType.find(space_id, content_type_id) }
|
182
|
+
it 'with location' do
|
183
|
+
vcr('entry/create_with_location') do
|
184
|
+
location = Location.new
|
185
|
+
location.lat = 22.44
|
186
|
+
location.lon = 33.33
|
187
|
+
|
188
|
+
entry = subject.create(content_type, name: 'Tom Handy', age: 30, city: location)
|
189
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
190
|
+
expect(entry.name).to eq 'Tom Handy'
|
191
|
+
expect(entry.age).to eq 30
|
192
|
+
expect(entry.city.properties[:lat]).to eq location.lat
|
193
|
+
expect(entry.city.properties[:lon]).to eq location.lon
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'with entry' do
|
198
|
+
vcr('entry/create_with_entry') do
|
199
|
+
entry_att = Entry.find(space_id, '4o6ghKSmSko4i828YCYaEo')
|
200
|
+
entry = subject.create(content_type, name: 'EntryWithEntry', age: 20, entry: entry_att)
|
201
|
+
expect(entry.name).to eq 'EntryWithEntry'
|
202
|
+
expect(entry.age).to eq 20
|
203
|
+
expect(entry.fields[:entry]['sys']['id']).to eq entry_att.id
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'with entries' do
|
208
|
+
vcr('entry/create_with_entries') do
|
209
|
+
entry_att = Entry.find(space_id, '1d1QDYzeiyWmgqQYysae8u')
|
210
|
+
entry2 = subject.create(content_type, name: 'EntryWithEntries', age: 20, entries: [entry_att, entry_att, entry_att])
|
211
|
+
expect(entry2.name).to eq 'EntryWithEntries'
|
212
|
+
expect(entry2.age).to eq 20
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'with asset' do
|
217
|
+
vcr('entry/create_with_asset') do
|
218
|
+
asset = Asset.find(space_id, 'codequest_id_test_custom')
|
219
|
+
entry = subject.create(content_type, name: 'OneAsset', asset: asset)
|
220
|
+
expect(entry.name).to eq 'OneAsset'
|
221
|
+
end
|
222
|
+
end
|
223
|
+
it 'with assets' do
|
224
|
+
vcr('entry/create_with_assets') do
|
225
|
+
asset = Asset.find(space_id, 'codequest_id_test_custom')
|
226
|
+
entry = subject.create(content_type, name: 'multiAssets', assets: [asset, asset, asset])
|
227
|
+
expect(entry.name).to eq 'multiAssets'
|
228
|
+
end
|
229
|
+
end
|
230
|
+
it 'with symbols' do
|
231
|
+
vcr('entry/create_with_symbols') do
|
232
|
+
entry = subject.create(content_type, name: 'SymbolTest', symbols: 'USD, PL, XX')
|
233
|
+
expect(entry.name).to eq 'SymbolTest'
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe '#update' do
|
239
|
+
let(:entry_id) { '1I3qWOiP8k2WWYCogKy88S' }
|
240
|
+
it 'update entry' do
|
241
|
+
vcr('entry/update') do
|
242
|
+
asset = Asset.find(space_id, 'codequest_id_test_custom_id')
|
243
|
+
entry_att = Entry.find(space_id, '1d1QDYzeiyWmgqQYysae8u')
|
244
|
+
entry = Contentful::Management::Entry.find(space_id, '4o6ghKSmSko4i828YCYaEo')
|
245
|
+
|
246
|
+
location = Location.new
|
247
|
+
location.lat = 22.44
|
248
|
+
location.lon = 33.33
|
249
|
+
|
250
|
+
result = entry.update(name: 'Tom Handy', age: 20, birthday: '2000-07-12T11:11:00+02:00', city: location, bool: false,
|
251
|
+
asset: asset, assets: [asset, asset, asset],
|
252
|
+
entry: entry_att, entries: [entry_att, entry_att, entry_att],
|
253
|
+
symbols: ['PL', 'USD', 'XX'])
|
254
|
+
|
255
|
+
expect(result).to be_kind_of Contentful::Management::Entry
|
256
|
+
|
257
|
+
expect(result.fields[:name]).to eq 'Tom Handy'
|
258
|
+
expect(result.fields[:age]).to eq 20
|
259
|
+
expect(result.fields[:bool]).to eq false
|
260
|
+
expect(result.fields[:asset]['sys']['id']).to eq asset.id
|
261
|
+
expect(result.fields[:entry]['sys']['id']).to eq entry_att.id
|
262
|
+
expect(result.fields[:entries].first['sys']['id']).to eq entry_att.id
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'update entry for custom locale' do
|
267
|
+
vcr('entry/update_with_custom_locale') do
|
268
|
+
entry = Contentful::Management::Entry.find(space_id, '3U7JqGuVzOWIimU40mKeem')
|
269
|
+
entry.locale = 'pl'
|
270
|
+
|
271
|
+
result = entry.update(name: 'testName', bool: true)
|
272
|
+
result.locale = 'pl'
|
273
|
+
expect(result).to be_kind_of Contentful::Management::Entry
|
274
|
+
expect(result.fields[:name]).to eq 'testName'
|
275
|
+
expect(result.fields[:bool]).to eq true
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'return Error when update not localized field' do
|
280
|
+
vcr('entry/update_unlocalized_field') do
|
281
|
+
asset = Asset.find(space_id, 'codequest_id_test_custom_id')
|
282
|
+
|
283
|
+
location = Location.new
|
284
|
+
location.lat = 22.44
|
285
|
+
location.lon = 33.33
|
286
|
+
entry = Contentful::Management::Entry.find(space_id, '3U7JqGuVzOWIimU40mKeem')
|
287
|
+
entry.locale = 'pl'
|
288
|
+
result = entry.update(name: 'DoestMatter', bool: false, city: location, asset: asset)
|
289
|
+
expect(result).to be_kind_of Contentful::Management::Error
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
describe '#save' do
|
295
|
+
it 'save updated' do
|
296
|
+
vcr('entry/save_update') do
|
297
|
+
entry = Contentful::Management::Entry.find(space_id, '664EPJ6zHqAeMO6O0mGggU')
|
298
|
+
entry.fields[:carMark] = 'Merc'
|
299
|
+
entry.save
|
300
|
+
expect(entry).to be_kind_of Contentful::Management::Entry
|
301
|
+
expect(entry.fields[:carMark]).to eq 'Merc'
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'contentful/management/space'
|
4
|
+
require 'contentful/management/client'
|
5
|
+
|
6
|
+
module Contentful
|
7
|
+
module Management
|
8
|
+
describe Locale do
|
9
|
+
let(:token) { '<ACCESS_TOKEN>' }
|
10
|
+
let(:space_id) { 'n6spjc167pc2' }
|
11
|
+
let(:locale_id) { '0X5xcjckv6RMrd9Trae81p' }
|
12
|
+
|
13
|
+
let!(:client) { Client.new(token) }
|
14
|
+
|
15
|
+
subject { Contentful::Management::Locale }
|
16
|
+
|
17
|
+
describe '.all' do
|
18
|
+
it 'returns a Contentful::Array' do
|
19
|
+
vcr('locale/all_for_space') { expect(subject.all(space_id)).to be_kind_of Contentful::Management::Array }
|
20
|
+
end
|
21
|
+
it 'builds a Contentful::Management::Locale object' do
|
22
|
+
vcr('locale/all_for_space') { expect(subject.all(space_id).first).to be_kind_of Contentful::Management::Locale }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.find' do
|
27
|
+
it 'returns a Contentful::Management::Locale' do
|
28
|
+
vcr('locale/find') { expect(subject.find(space_id, locale_id)).to be_kind_of Contentful::Management::Locale }
|
29
|
+
end
|
30
|
+
it 'returns the locale for a given key' do
|
31
|
+
vcr('locale/find') do
|
32
|
+
locale = subject.find(space_id, locale_id)
|
33
|
+
expect(locale.id).to eql locale_id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
it 'returns an error when content_type does not exists' do
|
37
|
+
vcr('locale/find_for_space_not_found') do
|
38
|
+
result = subject.find(space_id, 'not_exist')
|
39
|
+
expect(result).to be_kind_of Contentful::Management::NotFound
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
describe '.create' do
|
44
|
+
it 'create locales for space' do
|
45
|
+
vcr('locale/create_for_space') do
|
46
|
+
locale = subject.create(space_id, name: 'testLocalCreate', code: 'bg')
|
47
|
+
expect(locale.name).to eql 'testLocalCreate'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,317 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'contentful/management/space'
|
4
|
+
require 'contentful/management/client'
|
5
|
+
|
6
|
+
module Contentful
|
7
|
+
module Management
|
8
|
+
describe Space do
|
9
|
+
let(:token) { '<ACCESS_TOKEN>' }
|
10
|
+
let(:space_id) { 'yr5m0jky5hsh' }
|
11
|
+
|
12
|
+
let!(:client) { Client.new(token) }
|
13
|
+
|
14
|
+
subject { Contentful::Management::Space }
|
15
|
+
|
16
|
+
describe '.all' do
|
17
|
+
it 'returns a Contentful::Array' do
|
18
|
+
vcr('space/all') { expect(subject.all).to be_kind_of Contentful::Management::Array }
|
19
|
+
end
|
20
|
+
it 'builds a Contentful::Management::Space object' do
|
21
|
+
vcr('space/all') { expect(subject.all.first).to be_kind_of Contentful::Management::Space }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.find' do
|
26
|
+
it 'returns a Contentful::Management::Space' do
|
27
|
+
vcr('space/find') { expect(subject.find(space_id)).to be_kind_of Contentful::Management::Space }
|
28
|
+
end
|
29
|
+
it 'returns space for a given key' do
|
30
|
+
vcr('space/find') do
|
31
|
+
space = subject.find(space_id)
|
32
|
+
expect(space.id).to eql space_id
|
33
|
+
end
|
34
|
+
end
|
35
|
+
it 'returns an error when space not found' do
|
36
|
+
vcr('space/find_not_found') do
|
37
|
+
result = subject.find('not_exist')
|
38
|
+
expect(result).to be_kind_of Contentful::Management::NotFound
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#destroy' do
|
44
|
+
it 'returns true when a space was deleted' do
|
45
|
+
vcr('space/destory') do
|
46
|
+
result = subject.find('aopzqyf8j4yq').destroy
|
47
|
+
expect(result).to eql true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '.create' do
|
53
|
+
let(:space_name) { 'My Test Space' }
|
54
|
+
let(:organization_id) { '0fV1n3ykR3arQQAa8aylMi' }
|
55
|
+
|
56
|
+
it 'creates a space within an organization' do
|
57
|
+
vcr('space/create') do
|
58
|
+
space = subject.create(name: space_name, organization_id: organization_id)
|
59
|
+
expect(space).to be_kind_of Contentful::Management::Space
|
60
|
+
expect(space.name).to eq space_name
|
61
|
+
end
|
62
|
+
end
|
63
|
+
it 'creates a space when the user only has one organization' do
|
64
|
+
vcr('space/create_without_organization') do
|
65
|
+
space = subject.create(name: space_name)
|
66
|
+
expect(space).to be_kind_of Contentful::Management::Space
|
67
|
+
expect(space.name).to eq space_name
|
68
|
+
end
|
69
|
+
end
|
70
|
+
it 'returns error when user have multiple organizations and not pass organization_id' do
|
71
|
+
vcr('space/create_with_unknown_organization') do
|
72
|
+
space = subject.create(name: space_name)
|
73
|
+
expect(space).to be_kind_of Contentful::Management::NotFound
|
74
|
+
end
|
75
|
+
end
|
76
|
+
it 'returns error when limit has been reached' do
|
77
|
+
vcr('space/create_when_limit_has_been_reached') do
|
78
|
+
space = subject.create(name: space_name, organization_id: organization_id)
|
79
|
+
expect(space).to be_kind_of Contentful::Management::AccessDenied
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#update' do
|
85
|
+
it 'updates the space name and increase version by +1' do
|
86
|
+
vcr('space/update') do
|
87
|
+
space = subject.find(space_id)
|
88
|
+
initial_version = space.sys[:version]
|
89
|
+
space.update(name: 'NewNameSpace')
|
90
|
+
expect(space.sys[:version]).to eql initial_version + 1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
it 'update name to the same name not increase version' do
|
94
|
+
vcr(:'space/update_with_the_same_data') do
|
95
|
+
space = subject.find(space_id)
|
96
|
+
initial_version = space.sys[:version]
|
97
|
+
space.update(name: 'NewNameSpace')
|
98
|
+
expect(space.sys[:version]).to eql initial_version
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#content_types' do
|
104
|
+
let(:content_type_id) { '5DSpuKrl04eMAGQoQckeIq' }
|
105
|
+
let(:content_type_name) { 'ContentTypeForSpace' }
|
106
|
+
|
107
|
+
it 'creates content type' do
|
108
|
+
vcr('space/content_type/create') do
|
109
|
+
content_type = subject.find(space_id).content_types.create(name: content_type_name)
|
110
|
+
expect(content_type).to be_kind_of Contentful::Management::ContentType
|
111
|
+
expect(content_type.name).to eq content_type_name
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'lists content types to given space' do
|
116
|
+
vcr('space/content_type/content_types') do
|
117
|
+
content_types = subject.find(space_id).content_types
|
118
|
+
expect(content_types).to be_kind_of Contentful::Management::Array
|
119
|
+
end
|
120
|
+
end
|
121
|
+
it 'builds a Contentful::Management::ContentType object' do
|
122
|
+
vcr('space/content_type/content_types') { expect(subject.find(space_id).content_types.first).to be_kind_of Contentful::Management::ContentType }
|
123
|
+
end
|
124
|
+
it '#content_types.find' do
|
125
|
+
vcr('space/content_type/find') do
|
126
|
+
content_type = subject.find(space_id).content_types.find('1AZQOWKr2I8W2ugY0KiGEU')
|
127
|
+
expect(content_type).to be_kind_of Contentful::Management::ContentType
|
128
|
+
expect(content_type.name).to eq content_type_name
|
129
|
+
end
|
130
|
+
end
|
131
|
+
it '.content_types.all' do
|
132
|
+
vcr('space/content_type/all') do
|
133
|
+
content_types = subject.find(space_id).content_types.all
|
134
|
+
expect(content_types).to be_kind_of Contentful::Management::Array
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#locales' do
|
140
|
+
let(:locale_id) { '42irhRZ5uMrRc9SZ1PyDRk' }
|
141
|
+
it 'lists locales to given space' do
|
142
|
+
vcr('space/locale/locales') do
|
143
|
+
locales = subject.find(space_id).locales
|
144
|
+
expect(locales).to be_kind_of Contentful::Management::Array
|
145
|
+
end
|
146
|
+
end
|
147
|
+
it 'builds a Contentful::Management::Local object' do
|
148
|
+
vcr('space/locale/locales') { expect(subject.find(space_id).locales.first).to be_kind_of Contentful::Management::Locale }
|
149
|
+
end
|
150
|
+
|
151
|
+
it '#locales.all' do
|
152
|
+
vcr('space/locale/all') do
|
153
|
+
locales = subject.find(space_id).locales.all
|
154
|
+
expect(locales).to be_kind_of Contentful::Management::Array
|
155
|
+
end
|
156
|
+
end
|
157
|
+
it 'builds a Contentful::Management::Local object' do
|
158
|
+
vcr('space/locale/all') { expect(subject.find(space_id).locales.all.first).to be_kind_of Contentful::Management::Locale }
|
159
|
+
end
|
160
|
+
it '#locales.find' do
|
161
|
+
vcr('space/locale/find') do
|
162
|
+
locales = subject.find(space_id).locales.find(locale_id)
|
163
|
+
expect(locales).to be_kind_of Contentful::Management::Locale
|
164
|
+
expect(locales.code).to eql 'en-US'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'when locale not found' do
|
169
|
+
vcr('space/locale/find_not_found') do
|
170
|
+
locale = subject.find(space_id).locales.find('invalid_id')
|
171
|
+
expect(locale).to be_kind_of Contentful::Management::NotFound
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'creates locales to space' do
|
176
|
+
vcr('space/locale/create') do
|
177
|
+
locale = subject.find(space_id).locales.create(name: 'ru-RU', contentManagementApi: true, publish: true, contentDeliveryApi: true, code: 'ru-RU')
|
178
|
+
expect(locale).to be_kind_of Contentful::Management::Locale
|
179
|
+
expect(locale.name).to eql 'ru-RU'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'returns error when locale already exists' do
|
184
|
+
vcr('space/locale/create_with_the_same_code') do
|
185
|
+
locale = subject.find(space_id).locales.create(name: 'ru-RU', contentManagementApi: true, publish: true, contentDeliveryApi: true, code: 'ru-RU')
|
186
|
+
expect(locale).to be_kind_of Contentful::Management::Error
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it '#update when all params are given' do
|
191
|
+
vcr('space/locale/update') do
|
192
|
+
locale = subject.find(space_id).locales.find('6vn9hLab7q0D44XgRUwpoO')
|
193
|
+
initial_version = locale.sys[:version]
|
194
|
+
locale.update(name: 'Russia', contentManagementApi: true, publish: true, contentDeliveryApi: true)
|
195
|
+
expect(locale).to be_kind_of Contentful::Management::Locale
|
196
|
+
expect(locale.name).to eql 'Russia'
|
197
|
+
expect(locale.sys[:version]).to eql initial_version + 1
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
describe '#save' do
|
203
|
+
let(:new_name) { 'SaveNewName' }
|
204
|
+
it ' new space' do
|
205
|
+
vcr('space/save_new_space') do
|
206
|
+
space = subject.new
|
207
|
+
space.name = new_name
|
208
|
+
space.save
|
209
|
+
expect(space).to be_kind_of Contentful::Management::Space
|
210
|
+
expect(space.name).to eq new_name
|
211
|
+
end
|
212
|
+
end
|
213
|
+
it 'update space' do
|
214
|
+
vcr('space/save_update_space') do
|
215
|
+
space = subject.find(space_id)
|
216
|
+
space.name = new_name
|
217
|
+
space.save
|
218
|
+
expect(space).to be_kind_of Contentful::Management::Space
|
219
|
+
expect(space.name).to eq new_name
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe '#assets' do
|
225
|
+
it 'returns a Contentful::Array' do
|
226
|
+
vcr('space/asset/assets') { expect(subject.find(space_id).assets).to be_kind_of Contentful::Management::Array }
|
227
|
+
end
|
228
|
+
it 'builds a Contentful::Management::Asset object' do
|
229
|
+
vcr('space/asset/assets') { expect(subject.find(space_id).assets.first).to be_kind_of Contentful::Management::Asset }
|
230
|
+
end
|
231
|
+
it '#assets.all' do
|
232
|
+
vcr('space/asset/all') do
|
233
|
+
assets = subject.find(space_id).assets.all
|
234
|
+
expect(assets).to be_kind_of Contentful::Management::Array
|
235
|
+
end
|
236
|
+
end
|
237
|
+
it 'builds a Contentful::Management::Asset object' do
|
238
|
+
vcr('space/asset/all') { expect(subject.find(space_id).assets.all.first).to be_kind_of Contentful::Management::Asset }
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'return asset for a given key' do
|
242
|
+
vcr('space/asset/find') do
|
243
|
+
result = subject.find(space_id).assets.find('6zEogZjpO8cq6YOOQigiAw')
|
244
|
+
expect(result).to be_kind_of Contentful::Management::Asset
|
245
|
+
expect(result.id).to eql '6zEogZjpO8cq6YOOQigiAw'
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'create asset for space' do
|
250
|
+
vcr('space/asset/create') do
|
251
|
+
file = Contentful::Management::File.new
|
252
|
+
file.properties[:contentType] = 'image/jpeg'
|
253
|
+
file.properties[:fileName] = 'codequest.jpg'
|
254
|
+
file.properties[:upload] = 'http://static.goldenline.pl/firm_logo/082/firm_225106_22f37f_small.jpg'
|
255
|
+
|
256
|
+
space_assets = subject.find(space_id).assets
|
257
|
+
asset = space_assets.create(title: 'CodeQuest', description: 'Logo of Codequest', file: file)
|
258
|
+
expect(asset).to be_kind_of Contentful::Management::Asset
|
259
|
+
expect(asset.title).to eql 'CodeQuest'
|
260
|
+
expect(asset.description).to eql 'Logo of Codequest'
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'creates asset with multiple locales ' do
|
265
|
+
vcr('space/asset/create_with_multiple_locales') do
|
266
|
+
file = Contentful::Management::File.new
|
267
|
+
file.properties[:contentType] = 'image/jpeg'
|
268
|
+
file.properties[:fileName] = 'codequest.jpg'
|
269
|
+
file.properties[:upload] = 'http://static.goldenline.pl/firm_logo/082/firm_225106_22f37f_small.jpg'
|
270
|
+
space = subject.find(space_id)
|
271
|
+
asset = space.assets.new
|
272
|
+
asset.title_with_locales = { 'en-US' => 'Company logo', 'pl' => 'Firmowe logo' }
|
273
|
+
asset.title = 'Logo of Codequest comapny'
|
274
|
+
asset.description_with_locales = { 'en-US' => 'Company logo codequest', 'pl' => 'Logo firmy Codequest' }
|
275
|
+
asset.file_with_locales = { 'en-US' => file, 'pl' => file }
|
276
|
+
asset.save
|
277
|
+
|
278
|
+
expect(asset).to be_kind_of Contentful::Management::Asset
|
279
|
+
expect(asset.title).to eq 'Logo of Codequest comapny'
|
280
|
+
expect(asset.description).to eq 'Company logo codequest'
|
281
|
+
asset.locale = 'pl'
|
282
|
+
expect(asset.title).to eq 'Firmowe logo'
|
283
|
+
expect(asset.description).to eq 'Logo firmy Codequest'
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
describe '#entries' do
|
289
|
+
it 'returns a Contentful::Entry' do
|
290
|
+
vcr('space/entry/entries') { expect(subject.find(space_id).entries).to be_kind_of Contentful::Management::Array }
|
291
|
+
end
|
292
|
+
it 'builds a Contentful::Management::Entry object' do
|
293
|
+
vcr('space/entry/entries') { expect(subject.find(space_id).entries.first).to be_kind_of Contentful::Management::Entry }
|
294
|
+
end
|
295
|
+
it '#entries.all' do
|
296
|
+
vcr('space/entry/all') do
|
297
|
+
entries = subject.find(space_id).entries.all
|
298
|
+
expect(entries).to be_kind_of Contentful::Management::Array
|
299
|
+
end
|
300
|
+
end
|
301
|
+
it 'builds a Contentful::Management::Entry object' do
|
302
|
+
vcr('space/entry/all') { expect(subject.find(space_id).entries.all.first).to be_kind_of Contentful::Management::Entry }
|
303
|
+
end
|
304
|
+
it 'return entry for a given key' do
|
305
|
+
vcr('space/entry/find') do
|
306
|
+
result = subject.find(space_id).entries.find('4Rouux8SoUCKwkyCq2I0E0')
|
307
|
+
expect(result).to be_kind_of Contentful::Management::Entry
|
308
|
+
expect(result.id).to eql '4Rouux8SoUCKwkyCq2I0E0'
|
309
|
+
expect(result.name_with_locales['en-US']).to eq 'Tom Handy'
|
310
|
+
expect(result.class.to_s).to eq "Contentful::Management::DynamicEntry[#{ result.class.content_type.id }]"
|
311
|
+
expect(result.class.inspect).to eq "Contentful::Management::DynamicEntry[#{ result.class.content_type.id }]"
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|