contentful-management 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf3767440a711329cd8a89e79165348a4e7e7c1b
4
- data.tar.gz: f7a51847bf88d1dd1c7e92814df67b727772ac64
3
+ metadata.gz: 049eb488576c16400cff6e5ccda07a6d49730cf2
4
+ data.tar.gz: f8e3875a69f5a41827fade93d588b105e2ebea0b
5
5
  SHA512:
6
- metadata.gz: 8bc3c9c2e2421fbadb69cbd4f350e34df803a9e2c8197575ebfabb02504f48f4e99f4e26caea2443e9a4529addd8b220cd3b9241d5ecf19fb071d0ea327a06c1
7
- data.tar.gz: 518a8413cbe4611e42594c2b2eef3f6b8c129851960c01245b65ed5c14c7aa79ebe9275fe070fe84ad47ba3d9631c467fddef038537d8ccfce10b49c7fb3565e
6
+ metadata.gz: c945200f9958c740a37f5712d0579b9c37b951d1450cd27a9677505aa2a95b68245ed0b929d1570651bd6b3997ec5a490c25f6e3f9dcfdd752eafc93d9569224
7
+ data.tar.gz: b606b3c542b8c0bb64976e34916f2a3004b3c03c15b7dfd806792dd58da8b81d5846ae568a6895a8d9b4b27b0dbca6da0e537190ec68041bd012589bf1218dd4
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log
2
- ## 0.3.1
2
+ ## Unreleased
3
+ ### Fixed
4
+ * Return Keep attribute if it's already a hash [#33](https://github.com/contentful/contentful-management.rb/pull/33)
5
+ * Typo in header [#34](https://github.com/contentful/contentful-management.rb/pull/34)
6
+ * Items are nil when creating an array field for a content type [#35](https://github.com/contentful/contentful-management.rb/issues/35)
3
7
 
8
+ ## 0.3.1
4
9
  ### Added
5
10
  * Logging of requests
6
11
  * Access to validations in responses
@@ -12,6 +17,7 @@
12
17
  ### Other
13
18
  * Cleaned the code
14
19
  * Remove encoding strings from the source code files
20
+
15
21
  ## 0.2.1
16
22
  ### Fixed
17
23
  * Fix: Use array for symbols in entry fields
@@ -141,7 +141,7 @@ module Contentful
141
141
  end
142
142
 
143
143
  def user_agent
144
- Hash['User-Agent', "RubyContenfulManagementGem/#{ Contentful::Management::VERSION }"]
144
+ Hash['User-Agent', "RubyContentfulManagementGem/#{ Contentful::Management::VERSION }"]
145
145
  end
146
146
 
147
147
  def organization_header(organization_id)
@@ -244,6 +244,8 @@ module Contentful
244
244
  hash_with_link_object('Entry', attr)
245
245
  when Asset then
246
246
  hash_with_link_object('Asset', attr)
247
+ when Hash then
248
+ attr
247
249
  end
248
250
  end
249
251
  end
@@ -34,7 +34,7 @@ module Contentful
34
34
  def parse_value(key, value)
35
35
  case key
36
36
  when :items
37
- value.properties_to_hash if type == 'Array' && type.is_a?(Field)
37
+ value.properties_to_hash if type == 'Array' && value.is_a?(Field)
38
38
  when :validations
39
39
  validations_to_hash(value) if value.is_a?(::Array)
40
40
  else
@@ -1,5 +1,5 @@
1
1
  module Contentful
2
2
  module Management
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
@@ -0,0 +1,355 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/2jtuu7nex6e6
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContentfulManagementGem/0.3.0
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Content-Length:
17
+ - '0'
18
+ Host:
19
+ - api.contentful.com
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Accept-Ranges:
26
+ - bytes
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
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
+ Cache-Control:
38
+ - max-age=0
39
+ Content-Type:
40
+ - application/vnd.contentful.management.v1+json
41
+ Date:
42
+ - Fri, 31 Oct 2014 09:27:35 GMT
43
+ Etag:
44
+ - '"8620008058aad4ab4e700a2e238956ea"'
45
+ Server:
46
+ - nginx
47
+ Status:
48
+ - 200 OK
49
+ X-Contentful-Request-Id:
50
+ - 85f-509441256
51
+ Content-Length:
52
+ - '450'
53
+ Connection:
54
+ - keep-alive
55
+ body:
56
+ encoding: UTF-8
57
+ string: |
58
+ {
59
+ "sys":{
60
+ "type":"Space",
61
+ "id":"2jtuu7nex6e6",
62
+ "version":1,
63
+ "createdBy":{
64
+ "sys":{
65
+ "type":"Link",
66
+ "linkType":"User",
67
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
68
+ }
69
+ },
70
+ "createdAt":"2014-10-31T08:35:42Z",
71
+ "updatedBy":{
72
+ "sys":{
73
+ "type":"Link",
74
+ "linkType":"User",
75
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
76
+ }
77
+ },
78
+ "updatedAt":"2014-10-31T08:35:42Z"
79
+ },
80
+ "name":"CMA-SPACE"}
81
+ http_version:
82
+ recorded_at: Fri, 31 Oct 2014 09:27:35 GMT
83
+ - request:
84
+ method: get
85
+ uri: https://api.contentful.com/spaces/2jtuu7nex6e6/content_types
86
+ body:
87
+ encoding: US-ASCII
88
+ string: ''
89
+ headers:
90
+ User-Agent:
91
+ - RubyContentfulManagementGem/0.3.0
92
+ Authorization:
93
+ - Bearer <ACCESS_TOKEN>
94
+ Content-Type:
95
+ - application/vnd.contentful.management.v1+json
96
+ Content-Length:
97
+ - '0'
98
+ Host:
99
+ - api.contentful.com
100
+ response:
101
+ status:
102
+ code: 200
103
+ message: OK
104
+ headers:
105
+ Access-Control-Allow-Headers:
106
+ - 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
107
+ Access-Control-Allow-Methods:
108
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
109
+ Access-Control-Allow-Origin:
110
+ - "*"
111
+ Access-Control-Expose-Headers:
112
+ - Etag
113
+ Access-Control-Max-Age:
114
+ - '1728000'
115
+ Cf-Space-Id:
116
+ - 2jtuu7nex6e6
117
+ Content-Type:
118
+ - application/vnd.contentful.management.v1+json
119
+ Date:
120
+ - Fri, 31 Oct 2014 09:27:37 GMT
121
+ Etag:
122
+ - '"29f2c21be26360c424f617d8592cf6f9"'
123
+ Server:
124
+ - nginx
125
+ X-Powered-By:
126
+ - Express
127
+ Content-Length:
128
+ - '97'
129
+ Connection:
130
+ - keep-alive
131
+ body:
132
+ encoding: UTF-8
133
+ string: |
134
+ {
135
+ "sys": {
136
+ "type": "Array"
137
+ },
138
+ "total": 0,
139
+ "skip": 0,
140
+ "limit": 100,
141
+ "items": []
142
+ }
143
+ http_version:
144
+ recorded_at: Fri, 31 Oct 2014 09:27:37 GMT
145
+ - request:
146
+ method: post
147
+ uri: https://api.contentful.com/spaces/2jtuu7nex6e6/content_types/
148
+ body:
149
+ encoding: UTF-8
150
+ string: '{"name":"Testing Content Types","description":"","fields":[{"id":"entries","name":"Entries","type":"Array","items":{"type":"Link","linkType":"Entry"}}]}'
151
+ headers:
152
+ User-Agent:
153
+ - RubyContentfulManagementGem/0.3.0
154
+ Authorization:
155
+ - Bearer <ACCESS_TOKEN>
156
+ Content-Type:
157
+ - application/vnd.contentful.management.v1+json
158
+ Host:
159
+ - api.contentful.com
160
+ response:
161
+ status:
162
+ code: 201
163
+ message: Created
164
+ headers:
165
+ Access-Control-Allow-Headers:
166
+ - 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
167
+ Access-Control-Allow-Methods:
168
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
169
+ Access-Control-Allow-Origin:
170
+ - "*"
171
+ Access-Control-Expose-Headers:
172
+ - Etag
173
+ Access-Control-Max-Age:
174
+ - '1728000'
175
+ Cf-Space-Id:
176
+ - 2jtuu7nex6e6
177
+ Content-Type:
178
+ - application/vnd.contentful.management.v1+json
179
+ Date:
180
+ - Fri, 31 Oct 2014 09:27:38 GMT
181
+ Etag:
182
+ - '"a6a6971f8f2fbc32e035c6cc708ca272"'
183
+ Server:
184
+ - nginx
185
+ X-Powered-By:
186
+ - Express
187
+ Content-Length:
188
+ - '831'
189
+ Connection:
190
+ - keep-alive
191
+ body:
192
+ encoding: UTF-8
193
+ string: |
194
+ {
195
+ "name": "Testing Content Types",
196
+ "description": "",
197
+ "fields": [
198
+ {
199
+ "id": "entries",
200
+ "name": "Entries",
201
+ "type": "Array",
202
+ "items": {
203
+ "type": "Link",
204
+ "linkType": "Entry"
205
+ }
206
+ }
207
+ ],
208
+ "sys": {
209
+ "id": "5RKS0W3uWQcaWwss6Y20MQ",
210
+ "type": "ContentType",
211
+ "version": 1,
212
+ "createdAt": "2014-10-31T09:27:37.870Z",
213
+ "createdBy": {
214
+ "sys": {
215
+ "type": "Link",
216
+ "linkType": "User",
217
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
218
+ }
219
+ },
220
+ "space": {
221
+ "sys": {
222
+ "type": "Link",
223
+ "linkType": "Space",
224
+ "id": "2jtuu7nex6e6"
225
+ }
226
+ },
227
+ "updatedAt": "2014-10-31T09:27:37.870Z",
228
+ "updatedBy": {
229
+ "sys": {
230
+ "type": "Link",
231
+ "linkType": "User",
232
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
233
+ }
234
+ }
235
+ }
236
+ }
237
+ http_version:
238
+ recorded_at: Fri, 31 Oct 2014 09:27:38 GMT
239
+ - request:
240
+ method: put
241
+ uri: https://api.contentful.com/spaces/2jtuu7nex6e6/content_types/5RKS0W3uWQcaWwss6Y20MQ
242
+ body:
243
+ encoding: UTF-8
244
+ string: '{"name":"Testing Content Types","description":"","fields":[{"id":"entries","name":"Entries","type":"Array","linkType":null,"items":{"id":null,"name":null,"type":"Link","linkType":"Entry","items":null,"required":null,"localized":null,"validations":null},"required":null,"localized":null,"validations":null},{"id":"Entries_two","name":"Entries
245
+ Two","type":"Array","items":{"type":"Link","linkType":"Entry"}}]}'
246
+ headers:
247
+ User-Agent:
248
+ - RubyContentfulManagementGem/0.3.0
249
+ Authorization:
250
+ - Bearer <ACCESS_TOKEN>
251
+ Content-Type:
252
+ - application/vnd.contentful.management.v1+json
253
+ X-Contentful-Version:
254
+ - '1'
255
+ Host:
256
+ - api.contentful.com
257
+ response:
258
+ status:
259
+ code: 200
260
+ message: OK
261
+ headers:
262
+ Access-Control-Allow-Headers:
263
+ - 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
264
+ Access-Control-Allow-Methods:
265
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
266
+ Access-Control-Allow-Origin:
267
+ - "*"
268
+ Access-Control-Expose-Headers:
269
+ - Etag
270
+ Access-Control-Max-Age:
271
+ - '1728000'
272
+ Cf-Space-Id:
273
+ - 2jtuu7nex6e6
274
+ Content-Type:
275
+ - application/vnd.contentful.management.v1+json
276
+ Date:
277
+ - Fri, 31 Oct 2014 09:27:39 GMT
278
+ Etag:
279
+ - '"1671cb64a30aec28d06b21396b03dee1"'
280
+ Server:
281
+ - nginx
282
+ X-Powered-By:
283
+ - Express
284
+ Content-Length:
285
+ - '1247'
286
+ Connection:
287
+ - keep-alive
288
+ body:
289
+ encoding: UTF-8
290
+ string: |
291
+ {
292
+ "name": "Testing Content Types",
293
+ "description": "",
294
+ "fields": [
295
+ {
296
+ "id": "entries",
297
+ "name": "Entries",
298
+ "type": "Array",
299
+ "linkType": null,
300
+ "items": {
301
+ "id": null,
302
+ "name": null,
303
+ "type": "Link",
304
+ "linkType": "Entry",
305
+ "items": null,
306
+ "required": null,
307
+ "localized": null,
308
+ "validations": null
309
+ },
310
+ "required": null,
311
+ "localized": null,
312
+ "validations": null
313
+ },
314
+ {
315
+ "id": "Entries_two",
316
+ "name": "Entries Two",
317
+ "type": "Array",
318
+ "items": {
319
+ "type": "Link",
320
+ "linkType": "Entry"
321
+ }
322
+ }
323
+ ],
324
+ "sys": {
325
+ "id": "5RKS0W3uWQcaWwss6Y20MQ",
326
+ "type": "ContentType",
327
+ "createdAt": "2014-10-31T09:27:37.870Z",
328
+ "createdBy": {
329
+ "sys": {
330
+ "type": "Link",
331
+ "linkType": "User",
332
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
333
+ }
334
+ },
335
+ "space": {
336
+ "sys": {
337
+ "type": "Link",
338
+ "linkType": "Space",
339
+ "id": "2jtuu7nex6e6"
340
+ }
341
+ },
342
+ "version": 2,
343
+ "updatedAt": "2014-10-31T09:27:39.150Z",
344
+ "updatedBy": {
345
+ "sys": {
346
+ "type": "Link",
347
+ "linkType": "User",
348
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
349
+ }
350
+ }
351
+ }
352
+ }
353
+ http_version:
354
+ recorded_at: Fri, 31 Oct 2014 09:27:39 GMT
355
+ recorded_with: VCR 2.9.2
@@ -31,7 +31,7 @@ module Contentful
31
31
 
32
32
  describe '#user_agent' do
33
33
  its(:user_agent) { should be_kind_of Hash }
34
- its(:user_agent) { should eq 'User-Agent' => "RubyContenfulManagementGem/#{ Contentful::Management::VERSION }" }
34
+ its(:user_agent) { should eq 'User-Agent' => "RubyContentfulManagementGem/#{ Contentful::Management::VERSION }" }
35
35
  end
36
36
 
37
37
  describe '#organization_header' do
@@ -678,6 +678,41 @@ module Contentful
678
678
  end
679
679
  end
680
680
  end
681
+
682
+ describe 'create fields with array type' do
683
+ it 'creates new content type with fields' do
684
+ vcr('content_type/fields/create_array_types') do
685
+
686
+ space = Contentful::Management::Space.find('2jtuu7nex6e6')
687
+
688
+ items = Contentful::Management::Field.new
689
+ items.type = 'Link'
690
+ items.link_type = 'Entry'
691
+
692
+ field = Contentful::Management::Field.new
693
+ field.id = 'entries'
694
+ field.name = 'Entries'
695
+ field.type = 'Array'
696
+ field.items = items
697
+
698
+ content_type = space.content_types.new
699
+ content_type.name = 'Testing Content Types'
700
+ content_type.fields = [field]
701
+ content_type.save
702
+
703
+ content_type.fields.create(id: 'Entries_two', name: 'Entries Two', type: 'Array', items: items)
704
+ first_field = content_type.fields.first
705
+ second_field = content_type.fields.last
706
+ expect(content_type).to be_kind_of Contentful::Management::ContentType
707
+ expect(first_field).to be_kind_of Contentful::Management::Field
708
+ expect(second_field).to be_kind_of Contentful::Management::Field
709
+ expect(first_field.type).to eq 'Array'
710
+ expect(first_field.items.link_type).to eq 'Entry'
711
+ expect(second_field.type).to eq 'Array'
712
+ expect(second_field.items.link_type).to eq 'Entry'
713
+ end
714
+ end
715
+ end
681
716
  end
682
717
  end
683
718
  end
@@ -604,6 +604,15 @@ module Contentful
604
604
 
605
605
  end
606
606
 
607
+ it 'keepd hashes in attributes' do
608
+ attributes = {
609
+ entries: [{sys: {type: 'Link', linkType: 'Entry', id: nil}}, {sys: {type: 'Link', linkType: 'Entry', id: nil}}]
610
+ }
611
+
612
+ parsed_attributes = Entry.new.fields_from_attributes(attributes)
613
+
614
+ expect(parsed_attributes[:entries]).to match('en-US' => [{sys: {type: 'Link', linkType: 'Entry', id: nil}}, {sys: {type: 'Link', linkType: 'Entry', id: nil}}])
615
+ end
607
616
  end
608
617
 
609
618
  end
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: 0.3.0
4
+ version: 0.3.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: 2014-10-20 00:00:00.000000000 Z
13
+ date: 2014-10-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http
@@ -288,6 +288,7 @@ files:
288
288
  - spec/fixtures/vcr_cassettes/content_type/entry/update_only_with_localized_fields.yml
289
289
  - spec/fixtures/vcr_cassettes/content_type/fields/add.yml
290
290
  - spec/fixtures/vcr_cassettes/content_type/fields/create.yml
291
+ - spec/fixtures/vcr_cassettes/content_type/fields/create_array_types.yml
291
292
  - spec/fixtures/vcr_cassettes/content_type/fields/create_array_with_params.yml
292
293
  - spec/fixtures/vcr_cassettes/content_type/fields/create_with_params.yml
293
294
  - spec/fixtures/vcr_cassettes/content_type/fields/destroy.yml
@@ -516,6 +517,7 @@ test_files:
516
517
  - spec/fixtures/vcr_cassettes/content_type/entry/update_only_with_localized_fields.yml
517
518
  - spec/fixtures/vcr_cassettes/content_type/fields/add.yml
518
519
  - spec/fixtures/vcr_cassettes/content_type/fields/create.yml
520
+ - spec/fixtures/vcr_cassettes/content_type/fields/create_array_types.yml
519
521
  - spec/fixtures/vcr_cassettes/content_type/fields/create_array_with_params.yml
520
522
  - spec/fixtures/vcr_cassettes/content_type/fields/create_with_params.yml
521
523
  - spec/fixtures/vcr_cassettes/content_type/fields/destroy.yml