contentful-management 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/contentful/management/entry.rb +4 -4
- data/lib/contentful/management/resource_requester.rb +1 -1
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/entry/create_with_ct_entries_new.yml +279 -0
- data/spec/lib/contentful/management/entry_spec.rb +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b75e50ebfc4202efbbd7d47c99781cafa716bc3287ebfb4ab52f6a8bf010254f
|
4
|
+
data.tar.gz: 026f56b80f835f32709a190d73af227a1f2985aa763217266fc2a39065f16f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02c0a808c2c80a6e41912f66154c408bdfd46e82d8df9495e116bed6f09395e88b9677a35d19034ee719c5afffc490b4ab22d72f8c8a329246b6f4f845287635
|
7
|
+
data.tar.gz: 84ae44e1a8a0df806b1ae4e569249fdbc8e2844c45c00226db9cb246d110059c2ef7e0ce7c87347251a74834c73a038d090fc92b11a503dd2621f09a0cd55f33
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## 2.2.1
|
6
|
+
### Fixed
|
7
|
+
* Fixed side-effect that was causing entries created using `content_type.entries.new` to fail to save.
|
8
|
+
|
5
9
|
## 2.2.0
|
6
10
|
### Added
|
7
11
|
* Added `#save` as a shortcut for `editor_interface.update(controls: editor_interface.controls)`. [#155](https://github.com/contentful/contentful-management.rb/issues/155)
|
@@ -43,7 +43,7 @@ module Contentful
|
|
43
43
|
|
44
44
|
# @private
|
45
45
|
def self.create_attributes(client, attributes)
|
46
|
-
content_type = attributes
|
46
|
+
content_type = attributes.delete(:content_type)
|
47
47
|
fields_for_create = if attributes[:fields] # create from initialized dynamic entry via save
|
48
48
|
tmp_entry = new
|
49
49
|
tmp_entry.instance_variable_set(:@fields, attributes.delete(:fields) || {})
|
@@ -117,11 +117,11 @@ module Contentful
|
|
117
117
|
locale = attributes[:locale] || content_type.sys[:space].default_locale
|
118
118
|
fields = content_type.properties[:fields]
|
119
119
|
field_names = fields.map { |field| field.id.to_sym }
|
120
|
-
attributes.keep_if { |key| field_names.include?(key) }
|
120
|
+
attributes = attributes.keep_if { |key| field_names.include?(key) }
|
121
121
|
|
122
|
-
attributes.
|
122
|
+
attributes.each_with_object({}) do |(id, value), result|
|
123
123
|
field = fields.detect { |f| f.id.to_sym == id.to_sym }
|
124
|
-
|
124
|
+
result[id] = { locale => parse_attribute_with_field(value, field) }
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -24,7 +24,7 @@ module Contentful
|
|
24
24
|
request = Request.new(
|
25
25
|
client,
|
26
26
|
resource_class.build_endpoint(endpoint_options),
|
27
|
-
resource_class.create_attributes(client, attributes),
|
27
|
+
resource_class.create_attributes(client, attributes.clone),
|
28
28
|
nil,
|
29
29
|
resource_class.create_headers(client, attributes)
|
30
30
|
)
|
@@ -0,0 +1,279 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.contentful.com/spaces/facgnwwgj5fe/environments/master/content_types/test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
X-Contentful-User-Agent:
|
11
|
+
- sdk contentful-management.rb/2.2.0; platform ruby/2.5.1; os macOS/16;
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
Connection:
|
17
|
+
- close
|
18
|
+
Host:
|
19
|
+
- api.contentful.com
|
20
|
+
User-Agent:
|
21
|
+
- http.rb/2.2.2
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 200
|
25
|
+
message: OK
|
26
|
+
headers:
|
27
|
+
Access-Control-Allow-Headers:
|
28
|
+
- Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature
|
29
|
+
Access-Control-Allow-Methods:
|
30
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Expose-Headers:
|
34
|
+
- Etag
|
35
|
+
Access-Control-Max-Age:
|
36
|
+
- '1728000'
|
37
|
+
Cf-Space-Id:
|
38
|
+
- facgnwwgj5fe
|
39
|
+
Content-Type:
|
40
|
+
- application/vnd.contentful.management.v1+json
|
41
|
+
Date:
|
42
|
+
- Tue, 12 Jun 2018 12:39:08 GMT
|
43
|
+
Etag:
|
44
|
+
- '"b995d565da7819ad9bbbc285771244bd"'
|
45
|
+
Server:
|
46
|
+
- Contentful
|
47
|
+
Strict-Transport-Security:
|
48
|
+
- max-age=15768000
|
49
|
+
X-Content-Type-Options:
|
50
|
+
- nosniff
|
51
|
+
X-Contentful-Ratelimit-Hour-Limit:
|
52
|
+
- '36000'
|
53
|
+
X-Contentful-Ratelimit-Hour-Remaining:
|
54
|
+
- '35942'
|
55
|
+
X-Contentful-Ratelimit-Reset:
|
56
|
+
- '0'
|
57
|
+
X-Contentful-Ratelimit-Second-Limit:
|
58
|
+
- '10'
|
59
|
+
X-Contentful-Ratelimit-Second-Remaining:
|
60
|
+
- '9'
|
61
|
+
X-Contentful-Request-Id:
|
62
|
+
- d8a435708c3e0b59ab6b1d9158be9a8c
|
63
|
+
Content-Length:
|
64
|
+
- '1292'
|
65
|
+
Connection:
|
66
|
+
- Close
|
67
|
+
Set-Cookie:
|
68
|
+
- incap_ses_467_673446=C1b/cN48GXgAV1hxkh97Buu+H1sAAAAASfcv4CC5DGzbGMuOjAoQhw==;
|
69
|
+
path=/; Domain=.contentful.com
|
70
|
+
- nlbi_673446=cB42ZHEIFFCa7U1o6lKYhQAAAAAY+2t4guO/ocI/jh56hVZK; path=/; Domain=.contentful.com
|
71
|
+
- visid_incap_673446=LcBv1jChSkKIvoQWmkVXGuu+H1sAAAAAQUIPAAAAAABvEGPqBWsfuhqkzEaaOOb/;
|
72
|
+
expires=Wed, 12 Jun 2019 12:00:33 GMT; path=/; Domain=.contentful.com
|
73
|
+
X-Iinfo:
|
74
|
+
- 2-32234290-32234303 NNNN CT(105 107 0) RT(1528807146445 60) q(0 0 2 -1) r(8
|
75
|
+
8) U5
|
76
|
+
X-Cdn:
|
77
|
+
- Incapsula
|
78
|
+
body:
|
79
|
+
encoding: ASCII-8BIT
|
80
|
+
string: |
|
81
|
+
{
|
82
|
+
"sys": {
|
83
|
+
"space": {
|
84
|
+
"sys": {
|
85
|
+
"type": "Link",
|
86
|
+
"linkType": "Space",
|
87
|
+
"id": "facgnwwgj5fe"
|
88
|
+
}
|
89
|
+
},
|
90
|
+
"id": "test",
|
91
|
+
"type": "ContentType",
|
92
|
+
"createdAt": "2017-03-02T18:32:49.570Z",
|
93
|
+
"updatedAt": "2017-03-02T18:32:50.586Z",
|
94
|
+
"environment": {
|
95
|
+
"sys": {
|
96
|
+
"id": "master",
|
97
|
+
"type": "Link",
|
98
|
+
"linkType": "Environment"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
"createdBy": {
|
102
|
+
"sys": {
|
103
|
+
"type": "Link",
|
104
|
+
"linkType": "User",
|
105
|
+
"id": "4SejVrWT96dvL9IV4Nb7sQ"
|
106
|
+
}
|
107
|
+
},
|
108
|
+
"updatedBy": {
|
109
|
+
"sys": {
|
110
|
+
"type": "Link",
|
111
|
+
"linkType": "User",
|
112
|
+
"id": "4SejVrWT96dvL9IV4Nb7sQ"
|
113
|
+
}
|
114
|
+
},
|
115
|
+
"publishedCounter": 1,
|
116
|
+
"version": 2,
|
117
|
+
"publishedBy": {
|
118
|
+
"sys": {
|
119
|
+
"type": "Link",
|
120
|
+
"linkType": "User",
|
121
|
+
"id": "4SejVrWT96dvL9IV4Nb7sQ"
|
122
|
+
}
|
123
|
+
},
|
124
|
+
"publishedVersion": 1,
|
125
|
+
"firstPublishedAt": "2017-03-02T18:32:50.559Z",
|
126
|
+
"publishedAt": "2017-03-02T18:32:50.559Z"
|
127
|
+
},
|
128
|
+
"displayField": "name",
|
129
|
+
"name": "Test",
|
130
|
+
"description": "",
|
131
|
+
"fields": [
|
132
|
+
{
|
133
|
+
"id": "name",
|
134
|
+
"name": "name",
|
135
|
+
"type": "Symbol",
|
136
|
+
"localized": false,
|
137
|
+
"required": false,
|
138
|
+
"validations": [],
|
139
|
+
"disabled": false,
|
140
|
+
"omitted": false
|
141
|
+
}
|
142
|
+
]
|
143
|
+
}
|
144
|
+
http_version:
|
145
|
+
recorded_at: Tue, 12 Jun 2018 12:39:08 GMT
|
146
|
+
- request:
|
147
|
+
method: post
|
148
|
+
uri: https://api.contentful.com/spaces/facgnwwgj5fe/environments/master/entries
|
149
|
+
body:
|
150
|
+
encoding: UTF-8
|
151
|
+
string: '{"fields":{"name":{"en-US":"foobar"}}}'
|
152
|
+
headers:
|
153
|
+
X-Contentful-User-Agent:
|
154
|
+
- sdk contentful-management.rb/2.2.0; platform ruby/2.5.1; os macOS/16;
|
155
|
+
Authorization:
|
156
|
+
- Bearer <ACCESS_TOKEN>
|
157
|
+
Content-Type:
|
158
|
+
- application/vnd.contentful.management.v1+json
|
159
|
+
X-Contentful-Content-Type:
|
160
|
+
- test
|
161
|
+
Content-Type-Id:
|
162
|
+
- test
|
163
|
+
Connection:
|
164
|
+
- close
|
165
|
+
Host:
|
166
|
+
- api.contentful.com
|
167
|
+
User-Agent:
|
168
|
+
- http.rb/2.2.2
|
169
|
+
response:
|
170
|
+
status:
|
171
|
+
code: 201
|
172
|
+
message: Created
|
173
|
+
headers:
|
174
|
+
Access-Control-Allow-Headers:
|
175
|
+
- Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature
|
176
|
+
Access-Control-Allow-Methods:
|
177
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
178
|
+
Access-Control-Allow-Origin:
|
179
|
+
- "*"
|
180
|
+
Access-Control-Expose-Headers:
|
181
|
+
- Etag
|
182
|
+
Access-Control-Max-Age:
|
183
|
+
- '1728000'
|
184
|
+
Cf-Space-Id:
|
185
|
+
- facgnwwgj5fe
|
186
|
+
Content-Type:
|
187
|
+
- application/vnd.contentful.management.v1+json
|
188
|
+
Date:
|
189
|
+
- Tue, 12 Jun 2018 12:39:09 GMT
|
190
|
+
Etag:
|
191
|
+
- '"cbe73cdb8d7ece4ff67125c9cdd85cd0"'
|
192
|
+
Server:
|
193
|
+
- Contentful
|
194
|
+
Strict-Transport-Security:
|
195
|
+
- max-age=15768000
|
196
|
+
X-Content-Type-Options:
|
197
|
+
- nosniff
|
198
|
+
X-Contentful-Ratelimit-Hour-Limit:
|
199
|
+
- '36000'
|
200
|
+
X-Contentful-Ratelimit-Hour-Remaining:
|
201
|
+
- '35941'
|
202
|
+
X-Contentful-Ratelimit-Reset:
|
203
|
+
- '0'
|
204
|
+
X-Contentful-Ratelimit-Second-Limit:
|
205
|
+
- '10'
|
206
|
+
X-Contentful-Ratelimit-Second-Remaining:
|
207
|
+
- '9'
|
208
|
+
X-Contentful-Request-Id:
|
209
|
+
- 967c62f7ad9284b1b7c3c7f7648315f1
|
210
|
+
Content-Length:
|
211
|
+
- '917'
|
212
|
+
Connection:
|
213
|
+
- Close
|
214
|
+
Set-Cookie:
|
215
|
+
- incap_ses_467_673446=vFoZJEqLu1vAWlhxkh97Bu2+H1sAAAAAf9ScH7sPhALnoIORNSun3g==;
|
216
|
+
path=/; Domain=.contentful.com
|
217
|
+
- nlbi_673446=wEfNOUIdSXB0V1Pv6lKYhQAAAABeL4r3wGhe0A09T8AfE2hJ; path=/; Domain=.contentful.com
|
218
|
+
- visid_incap_673446=lIyDH8l2Rd6wPg0iUMfUYe2+H1sAAAAAQUIPAAAAAABPveL4akLQXa/OfV4860wc;
|
219
|
+
expires=Wed, 12 Jun 2019 12:00:33 GMT; path=/; Domain=.contentful.com
|
220
|
+
X-Iinfo:
|
221
|
+
- 2-32234372-32234374 NNNN CT(104 104 0) RT(1528807147413 67) q(0 0 2 -1) r(20
|
222
|
+
20) U5
|
223
|
+
X-Cdn:
|
224
|
+
- Incapsula
|
225
|
+
body:
|
226
|
+
encoding: ASCII-8BIT
|
227
|
+
string: |
|
228
|
+
{
|
229
|
+
"sys": {
|
230
|
+
"space": {
|
231
|
+
"sys": {
|
232
|
+
"type": "Link",
|
233
|
+
"linkType": "Space",
|
234
|
+
"id": "facgnwwgj5fe"
|
235
|
+
}
|
236
|
+
},
|
237
|
+
"id": "3Q8FXPXXzOs8MCYYquQgcs",
|
238
|
+
"type": "Entry",
|
239
|
+
"createdAt": "2018-06-12T12:39:09.268Z",
|
240
|
+
"updatedAt": "2018-06-12T12:39:09.268Z",
|
241
|
+
"environment": {
|
242
|
+
"sys": {
|
243
|
+
"id": "master",
|
244
|
+
"type": "Link",
|
245
|
+
"linkType": "Environment"
|
246
|
+
}
|
247
|
+
},
|
248
|
+
"createdBy": {
|
249
|
+
"sys": {
|
250
|
+
"type": "Link",
|
251
|
+
"linkType": "User",
|
252
|
+
"id": "4SejVrWT96dvL9IV4Nb7sQ"
|
253
|
+
}
|
254
|
+
},
|
255
|
+
"updatedBy": {
|
256
|
+
"sys": {
|
257
|
+
"type": "Link",
|
258
|
+
"linkType": "User",
|
259
|
+
"id": "4SejVrWT96dvL9IV4Nb7sQ"
|
260
|
+
}
|
261
|
+
},
|
262
|
+
"version": 1,
|
263
|
+
"contentType": {
|
264
|
+
"sys": {
|
265
|
+
"type": "Link",
|
266
|
+
"linkType": "ContentType",
|
267
|
+
"id": "test"
|
268
|
+
}
|
269
|
+
}
|
270
|
+
},
|
271
|
+
"fields": {
|
272
|
+
"name": {
|
273
|
+
"en-US": "foobar"
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
http_version:
|
278
|
+
recorded_at: Tue, 12 Jun 2018 12:39:10 GMT
|
279
|
+
recorded_with: VCR 4.0.0
|
@@ -920,6 +920,22 @@ describe Contentful::Management::Entry do
|
|
920
920
|
end
|
921
921
|
end
|
922
922
|
|
923
|
+
describe 'it can properly create entries from a content type using #new' do
|
924
|
+
let(:space_id) { 'facgnwwgj5fe' }
|
925
|
+
let(:environment_id) { 'master' }
|
926
|
+
let(:content_type_id) { 'test' }
|
927
|
+
|
928
|
+
it 'creates an entry' do
|
929
|
+
vcr('entry/create_with_ct_entries_new') {
|
930
|
+
new_entry = client.content_types(space_id, environment_id).find(content_type_id).entries.new
|
931
|
+
new_entry.name_with_locales = { 'en-US' => 'foobar' }
|
932
|
+
|
933
|
+
expect { new_entry.save }.not_to raise_error
|
934
|
+
expect(new_entry.name).to eq 'foobar'
|
935
|
+
}
|
936
|
+
end
|
937
|
+
end
|
938
|
+
|
923
939
|
describe 'it can properly assign, save and publish - #61' do
|
924
940
|
describe 'on an entry created through the api' do
|
925
941
|
describe 'before refetch' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Protas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-06-
|
13
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -528,6 +528,7 @@ files:
|
|
528
528
|
- spec/fixtures/vcr_cassettes/entry/create.yml
|
529
529
|
- spec/fixtures/vcr_cassettes/entry/create_with_asset.yml
|
530
530
|
- spec/fixtures/vcr_cassettes/entry/create_with_assets.yml
|
531
|
+
- spec/fixtures/vcr_cassettes/entry/create_with_ct_entries_new.yml
|
531
532
|
- spec/fixtures/vcr_cassettes/entry/create_with_custom_id.yml
|
532
533
|
- spec/fixtures/vcr_cassettes/entry/create_with_entries.yml
|
533
534
|
- spec/fixtures/vcr_cassettes/entry/create_with_entry.yml
|
@@ -908,6 +909,7 @@ test_files:
|
|
908
909
|
- spec/fixtures/vcr_cassettes/entry/create.yml
|
909
910
|
- spec/fixtures/vcr_cassettes/entry/create_with_asset.yml
|
910
911
|
- spec/fixtures/vcr_cassettes/entry/create_with_assets.yml
|
912
|
+
- spec/fixtures/vcr_cassettes/entry/create_with_ct_entries_new.yml
|
911
913
|
- spec/fixtures/vcr_cassettes/entry/create_with_custom_id.yml
|
912
914
|
- spec/fixtures/vcr_cassettes/entry/create_with_entries.yml
|
913
915
|
- spec/fixtures/vcr_cassettes/entry/create_with_entry.yml
|