contentful-management 0.7.1 → 0.7.2

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: 24bb75aa07523683bbef6c810f411422deea4140
4
- data.tar.gz: c72ae53c5d8505ff32d23f2f5788da180b36945e
3
+ metadata.gz: 472e8a1070d8702011d2b2c66cf4f91d26b48c9b
4
+ data.tar.gz: 8e0b324dc7cd6e5ceae3199e37408d8d4e0f326d
5
5
  SHA512:
6
- metadata.gz: 3ad8b03581cabe9b0e6d084682f0e58b07dad11f3827f87e9c0b9ed08ab197755fddc7f6e02bb196c858833007bdc4638e44cf4e69b1d51f0157404e9318b340
7
- data.tar.gz: aacc23cf94ed71c318aa4a9302ee399382f77a0964145833a292d0c094c0d3781c53f5c9612cb67cf1f485c9b04a72cd6385c673d6b496391c79e90a0de1c23d
6
+ metadata.gz: 082d3ef8a03271e87b57401562294828cddc35f731d162648ba258b481c0a2553266bf0069a911c5ce43e07c3a266b6b4638ac4ab244509b0a5d40b4e4f09f04
7
+ data.tar.gz: 27db283177c954b7fe65e797dffde774b27b6135dd2224810fa059f8ac8d32baf5c3502cd55fe094f1b100d9eaf326d906962ed1845ec64516d2663b8bcf207e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
- =======
2
+
3
+ ## Master
4
+
5
+ ## 0.7.2
6
+ ### Fixed
7
+ * Ensure that `Validation.type` returns correct value [#59](https://github.com/contentful/contentful-management.rb/issues/59), [#66](https://github.com/contentful/contentful-management.rb/issues/66)
8
+ * Ensure that already existing `Space` returns correct `Locale` for `#default_locale` [#60](https://github.com/contentful/contentful-management.rb/issues/60)
9
+ * Remove unintended nested `Validation` [#49](https://github.com/contentful/contentful-management.rb/issues/49)
10
+
3
11
 
4
12
  ## 0.7.1
5
13
  ### Fixed
@@ -17,7 +25,6 @@
17
25
  * Merge values for default locale and current locale [#58](https://github.com/contentful/contentful-management.rb/pull/58)
18
26
 
19
27
 
20
-
21
28
  ## 0.6.1
22
29
  ### Fixed
23
30
  * Fix access to space default_locale instance variable [#47](https://github.com/contentful/contentful-management.rb/pull/47)
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency 'rspec', '~> 3'
27
27
  spec.add_development_dependency 'rspec-its'
28
28
  spec.add_development_dependency 'rubocop'
29
- spec.add_development_dependency 'reek'
29
+ spec.add_development_dependency 'reek', '~> 2', '>= 2.0.4'
30
30
  spec.add_development_dependency 'vcr'
31
31
  spec.add_development_dependency 'webmock', '~> 1', '>= 1.17.3'
32
32
  end
@@ -13,6 +13,7 @@ module Contentful
13
13
  property :contentManagementApi, :boolean
14
14
  property :contentDeliveryApi, :boolean
15
15
  property :publish, :boolean
16
+ property :default, :boolean
16
17
 
17
18
  # Gets a collection of locales.
18
19
  # Takes an id of a space.
@@ -23,6 +23,8 @@ module Contentful
23
23
  property :organization, :string
24
24
  property :locales, Locale
25
25
 
26
+ attr_accessor :found_locale
27
+
26
28
  # Gets a collection of spaces.
27
29
  # Returns a Contentful::Management::Array of Contentful::Management::Space.
28
30
  def self.all
@@ -59,7 +61,9 @@ module Contentful
59
61
  )
60
62
  response = request.post
61
63
  result = ResourceBuilder.new(response, {}, {})
62
- result.run
64
+ space = result.run
65
+ space.found_locale = default_locale if space.is_a? Space
66
+ space
63
67
  end
64
68
 
65
69
  # Updates a space.
@@ -135,6 +139,19 @@ module Contentful
135
139
  def webhooks
136
140
  SpaceWebhookMethodsFactory.new(self)
137
141
  end
142
+
143
+ # Retrieves Default Locale for current Space and leaves it cached
144
+ def default_locale
145
+ self.found_locale ||= find_locale
146
+ end
147
+
148
+ # Finds Default Locale Code for current Space
149
+ # This request makes an API call to the Locale endpoint
150
+ def find_locale
151
+ locale = ::Contentful::Management::Locale.all(self.id).detect { |l| l.default }
152
+ return locale.code unless locale.nil?
153
+ @default_locale
154
+ end
138
155
  end
139
156
  end
140
157
  end
@@ -9,7 +9,6 @@ module Contentful
9
9
  property :in, :array
10
10
  property :size, :hash
11
11
  property :present, :boolean
12
- property :validations, Validation
13
12
  property :regexp, :hash
14
13
  property :linkContentType, :array
15
14
  property :range, :hash
@@ -24,8 +23,9 @@ module Contentful
24
23
 
25
24
  # Returns type of validation
26
25
  def type
27
- properties.keys.each do |type|
28
- return type if !self.send(Support.snakify(type)).nil?
26
+ properties.keys.reject { |key| key == :validations }.each do |type|
27
+ value = self.send(Support.snakify(type))
28
+ return type if !value.nil? && value
29
29
  end
30
30
  end
31
31
 
@@ -1,5 +1,5 @@
1
1
  module Contentful
2
2
  module Management
3
- VERSION = '0.7.1'
3
+ VERSION = '0.7.2'
4
4
  end
5
5
  end
@@ -0,0 +1,95 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/n6spjc167pc2/locales/0X5xcjckv6RMrd9Trae81p
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContenfulManagementGem/0.0.1
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
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Mon, 14 Jul 2014 07:44:57 GMT
29
+ Content-Type:
30
+ - application/vnd.contentful.management.v1+json
31
+ Content-Length:
32
+ - '703'
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 200 OK
37
+ X-Contentful-Request-Id:
38
+ - 85f-1209864303
39
+ Etag:
40
+ - '"84473d86f0e8887dd6b44d2ffe155176"'
41
+ Accept-Ranges:
42
+ - bytes
43
+ Cache-Control:
44
+ - max-age=0
45
+ Access-Control-Allow-Origin:
46
+ - "*"
47
+ Access-Control-Allow-Headers:
48
+ - 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
49
+ Access-Control-Allow-Methods:
50
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
51
+ "^access-Control-Expose-Headers":
52
+ - Etag
53
+ Access-Control-Max-Age:
54
+ - '1728000'
55
+ body:
56
+ encoding: UTF-8
57
+ string: |
58
+ {
59
+ "sys":{
60
+ "type":"Locale",
61
+ "id":"0X5xcjckv6RMrd9Trae81p",
62
+ "version":6,
63
+ "space":{
64
+ "sys":{
65
+ "type":"Link",
66
+ "linkType":"Space",
67
+ "id":"n6spjc167pc2"
68
+ }
69
+ },
70
+ "createdBy":{
71
+ "sys":{
72
+ "type":"Link",
73
+ "linkType":"User",
74
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
75
+ }
76
+ },
77
+ "createdAt":"2014-07-11T10:43:30Z",
78
+ "updatedBy":{
79
+ "sys":{
80
+ "type":"Link",
81
+ "linkType":"User",
82
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
83
+ }
84
+ },
85
+ "updatedAt":"2014-07-11T13:29:23Z"
86
+ },
87
+ "name":"testNewLocaleName",
88
+ "code":"pl",
89
+ "default":true,
90
+ "contentManagementApi":true,
91
+ "publish":true,
92
+ "contentDeliveryApi":true}
93
+ http_version:
94
+ recorded_at: Mon, 14 Jul 2014 07:44:57 GMT
95
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,95 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/n6spjc167pc2/locales/0X5xcjckv6RMrd9Trae81p
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContenfulManagementGem/0.0.1
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
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Mon, 14 Jul 2014 07:44:57 GMT
29
+ Content-Type:
30
+ - application/vnd.contentful.management.v1+json
31
+ Content-Length:
32
+ - '703'
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 200 OK
37
+ X-Contentful-Request-Id:
38
+ - 85f-1209864303
39
+ Etag:
40
+ - '"84473d86f0e8887dd6b44d2ffe155176"'
41
+ Accept-Ranges:
42
+ - bytes
43
+ Cache-Control:
44
+ - max-age=0
45
+ Access-Control-Allow-Origin:
46
+ - "*"
47
+ Access-Control-Allow-Headers:
48
+ - 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
49
+ Access-Control-Allow-Methods:
50
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
51
+ "^access-Control-Expose-Headers":
52
+ - Etag
53
+ Access-Control-Max-Age:
54
+ - '1728000'
55
+ body:
56
+ encoding: UTF-8
57
+ string: |
58
+ {
59
+ "sys":{
60
+ "type":"Locale",
61
+ "id":"0X5xcjckv6RMrd9Trae81p",
62
+ "version":6,
63
+ "space":{
64
+ "sys":{
65
+ "type":"Link",
66
+ "linkType":"Space",
67
+ "id":"n6spjc167pc2"
68
+ }
69
+ },
70
+ "createdBy":{
71
+ "sys":{
72
+ "type":"Link",
73
+ "linkType":"User",
74
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
75
+ }
76
+ },
77
+ "createdAt":"2014-07-11T10:43:30Z",
78
+ "updatedBy":{
79
+ "sys":{
80
+ "type":"Link",
81
+ "linkType":"User",
82
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
83
+ }
84
+ },
85
+ "updatedAt":"2014-07-11T13:29:23Z"
86
+ },
87
+ "name":"testNewLocaleName",
88
+ "code":"pl",
89
+ "default":false,
90
+ "contentManagementApi":true,
91
+ "publish":true,
92
+ "contentDeliveryApi":true}
93
+ http_version:
94
+ recorded_at: Mon, 14 Jul 2014 07:44:57 GMT
95
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,572 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/spaces/yr5m0jky5hsh
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - RubyContenfulManagementGem/0.0.1
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
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Thu, 31 Jul 2014 07:10:02 GMT
29
+ Content-Type:
30
+ - application/vnd.contentful.management.v1+json
31
+ Content-Length:
32
+ - '453'
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 200 OK
37
+ X-Contentful-Request-Id:
38
+ - 85f-1334431491
39
+ Etag:
40
+ - '"cbeabcb3476920c3f3a426f8cf41795d"'
41
+ Accept-Ranges:
42
+ - bytes
43
+ Cache-Control:
44
+ - max-age=0
45
+ Access-Control-Allow-Origin:
46
+ - "*"
47
+ Access-Control-Allow-Headers:
48
+ - 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
49
+ Access-Control-Allow-Methods:
50
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
51
+ "^access-Control-Expose-Headers":
52
+ - Etag
53
+ Access-Control-Max-Age:
54
+ - '1728000'
55
+ body:
56
+ encoding: UTF-8
57
+ string: |
58
+ {
59
+ "sys":{
60
+ "type":"Space",
61
+ "id":"yr5m0jky5hsh",
62
+ "version":8,
63
+ "createdBy":{
64
+ "sys":{
65
+ "type":"Link",
66
+ "linkType":"User",
67
+ "id":"0fn5fOWn4WsKFyYla1gI5h"
68
+ }
69
+ },
70
+ "createdAt":"2014-07-30T07:46:19Z",
71
+ "updatedBy":{
72
+ "sys":{
73
+ "type":"Link",
74
+ "linkType":"User",
75
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
76
+ }
77
+ },
78
+ "updatedAt":"2014-07-31T07:04:29Z"
79
+ },
80
+ "name":"NewNameSpace"}
81
+ http_version:
82
+ recorded_at: Thu, 31 Jul 2014 07:10:02 GMT
83
+ - request:
84
+ method: get
85
+ uri: https://api.contentful.com/spaces/yr5m0jky5hsh/content_types
86
+ body:
87
+ encoding: US-ASCII
88
+ string: ''
89
+ headers:
90
+ User-Agent:
91
+ - RubyContenfulManagementGem/0.0.1
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
+ Server:
106
+ - nginx
107
+ Date:
108
+ - Thu, 31 Jul 2014 07:10:02 GMT
109
+ Content-Type:
110
+ - application/vnd.contentful.management.v1+json
111
+ Content-Length:
112
+ - '3054'
113
+ Connection:
114
+ - keep-alive
115
+ X-Powered-By:
116
+ - Express
117
+ Cf-Space-Id:
118
+ - yr5m0jky5hsh
119
+ Etag:
120
+ - '"4c43b6e34924f7e65971295370191384"'
121
+ Access-Control-Allow-Origin:
122
+ - "*"
123
+ Access-Control-Allow-Headers:
124
+ - 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
125
+ Access-Control-Allow-Methods:
126
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
127
+ "^access-Control-Expose-Headers":
128
+ - Etag
129
+ Access-Control-Max-Age:
130
+ - '1728000'
131
+ body:
132
+ encoding: UTF-8
133
+ string: |
134
+ {
135
+ "sys": {
136
+ "type": "Array"
137
+ },
138
+ "total": 1,
139
+ "skip": 0,
140
+ "limit": 100,
141
+ "items": [
142
+ {
143
+ "fields": [
144
+ {
145
+ "name": "name",
146
+ "id": "name",
147
+ "type": "Text",
148
+ "uiid": "3fflnrplhc0",
149
+ "localized": true
150
+ },
151
+ {
152
+ "name": "age",
153
+ "id": "age",
154
+ "uiid": "2t5blkc7u2o",
155
+ "type": "Integer",
156
+ "localized": true
157
+ },
158
+ {
159
+ "name": "city",
160
+ "id": "city",
161
+ "type": "Location",
162
+ "uiid": "4fzl5jkm1a8",
163
+ "localized": false
164
+ },
165
+ {
166
+ "name": "assets",
167
+ "id": "assets",
168
+ "uiid": "3aqrgdyesxs",
169
+ "type": "Array",
170
+ "items": {
171
+ "type": "Link",
172
+ "linkType": "Asset"
173
+ },
174
+ "localized": true
175
+ },
176
+ {
177
+ "name": "entries",
178
+ "id": "entries",
179
+ "type": "Array",
180
+ "uiid": "3xi486kbchs",
181
+ "items": {
182
+ "type": "Link",
183
+ "linkType": "Entry"
184
+ }
185
+ },
186
+ {
187
+ "name": "entry",
188
+ "id": "entry",
189
+ "type": "Link",
190
+ "uiid": "3uxjdd1n5ds",
191
+ "linkType": "Entry"
192
+ },
193
+ {
194
+ "name": "asset",
195
+ "id": "asset",
196
+ "type": "Link",
197
+ "uiid": "40ilp8h1xc0",
198
+ "linkType": "Asset"
199
+ },
200
+ {
201
+ "name": "bool",
202
+ "id": "bool",
203
+ "type": "Boolean",
204
+ "uiid": "2i1bgmn2dj4",
205
+ "localized": true
206
+ },
207
+ {
208
+ "name": "symbols",
209
+ "id": "symbols",
210
+ "type": "Array",
211
+ "uiid": "38rbncxmzuo",
212
+ "items": {
213
+ "type": "Symbol"
214
+ }
215
+ },
216
+ {
217
+ "name": "birthday",
218
+ "id": "birthday",
219
+ "type": "Date",
220
+ "uiid": "41bdwbk06bk"
221
+ }
222
+ ],
223
+ "name": "Author",
224
+ "sys": {
225
+ "id": "5DSpuKrl04eMAGQoQckeIq",
226
+ "type": "ContentType",
227
+ "createdAt": "2014-07-30T12:35:01.110Z",
228
+ "createdBy": {
229
+ "sys": {
230
+ "type": "Link",
231
+ "linkType": "User",
232
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
233
+ }
234
+ },
235
+ "space": {
236
+ "sys": {
237
+ "type": "Link",
238
+ "linkType": "Space",
239
+ "id": "yr5m0jky5hsh"
240
+ }
241
+ },
242
+ "firstPublishedAt": "2014-07-30T12:37:42.035Z",
243
+ "publishedCounter": 6,
244
+ "publishedAt": "2014-07-30T14:58:40.786Z",
245
+ "publishedBy": {
246
+ "sys": {
247
+ "type": "Link",
248
+ "linkType": "User",
249
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
250
+ }
251
+ },
252
+ "publishedVersion": 177,
253
+ "version": 178,
254
+ "updatedAt": "2014-07-30T14:58:40.796Z",
255
+ "updatedBy": {
256
+ "sys": {
257
+ "type": "Link",
258
+ "linkType": "User",
259
+ "id": "1E7acJL8I5XUXAMHQt9Grs"
260
+ }
261
+ }
262
+ },
263
+ "description": null,
264
+ "displayField": "name"
265
+ }
266
+ ]
267
+ }
268
+ http_version:
269
+ recorded_at: Thu, 31 Jul 2014 07:10:02 GMT
270
+ - request:
271
+ method: get
272
+ uri: https://api.contentful.com/spaces/yr5m0jky5hsh/locales
273
+ body:
274
+ encoding: US-ASCII
275
+ string: ''
276
+ headers:
277
+ User-Agent:
278
+ - RubyContenfulManagementGem/0.0.1
279
+ Authorization:
280
+ - Bearer <ACCESS_TOKEN>
281
+ Content-Type:
282
+ - application/vnd.contentful.management.v1+json
283
+ Content-Length:
284
+ - '0'
285
+ Host:
286
+ - api.contentful.com
287
+ response:
288
+ status:
289
+ code: 200
290
+ message: OK
291
+ headers:
292
+ Server:
293
+ - nginx
294
+ Date:
295
+ - Thu, 31 Jul 2014 07:10:03 GMT
296
+ Content-Type:
297
+ - application/vnd.contentful.management.v1+json
298
+ Content-Length:
299
+ - '3463'
300
+ Connection:
301
+ - keep-alive
302
+ Status:
303
+ - 200 OK
304
+ X-Contentful-Request-Id:
305
+ - 85f-1334431493
306
+ Etag:
307
+ - '"39640635b4519a9604d27cb6b3a979b3"'
308
+ Accept-Ranges:
309
+ - bytes
310
+ Cache-Control:
311
+ - max-age=0
312
+ Access-Control-Allow-Origin:
313
+ - "*"
314
+ Access-Control-Allow-Headers:
315
+ - 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
316
+ Access-Control-Allow-Methods:
317
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
318
+ "^access-Control-Expose-Headers":
319
+ - Etag
320
+ Access-Control-Max-Age:
321
+ - '1728000'
322
+ body:
323
+ encoding: UTF-8
324
+ string: |
325
+ {
326
+ "sys":{
327
+ "type":"Array"
328
+ },
329
+ "items":[
330
+ {
331
+ "sys":{
332
+ "type":"Locale",
333
+ "id":"42irhRZ5uMrRc9SZ1PyDRk",
334
+ "version":0,
335
+ "space":{
336
+ "sys":{
337
+ "type":"Link",
338
+ "linkType":"Space",
339
+ "id":"yr5m0jky5hsh"
340
+ }
341
+ },
342
+ "createdBy":{
343
+ "sys":{
344
+ "type":"Link",
345
+ "linkType":"User",
346
+ "id":"0fn5fOWn4WsKFyYla1gI5h"
347
+ }
348
+ },
349
+ "createdAt":"2014-07-30T07:46:19Z",
350
+ "updatedBy":{
351
+ "sys":{
352
+ "type":"Link",
353
+ "linkType":"User",
354
+ "id":"0fn5fOWn4WsKFyYla1gI5h"
355
+ }
356
+ },
357
+ "updatedAt":"2014-07-30T07:46:19Z"
358
+ },
359
+ "name":"German",
360
+ "code":"de-DE",
361
+ "default":true,
362
+ "contentManagementApi":true,
363
+ "publish":true,
364
+ "contentDeliveryApi":true
365
+ },
366
+ {
367
+ "sys":{
368
+ "type":"Locale",
369
+ "id":"3QwNQbA5IApftHq2TqWzbw",
370
+ "version":1,
371
+ "space":{
372
+ "sys":{
373
+ "type":"Link",
374
+ "linkType":"Space",
375
+ "id":"yr5m0jky5hsh"
376
+ }
377
+ },
378
+ "createdBy":{
379
+ "sys":{
380
+ "type":"Link",
381
+ "linkType":"User",
382
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
383
+ }
384
+ },
385
+ "createdAt":"2014-07-30T11:56:41Z",
386
+ "updatedBy":{
387
+ "sys":{
388
+ "type":"Link",
389
+ "linkType":"User",
390
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
391
+ }
392
+ },
393
+ "updatedAt":"2014-07-30T12:05:44Z"
394
+ },
395
+ "name":"Polish - PL",
396
+ "code":"pl-PL",
397
+ "default":false,
398
+ "contentManagementApi":true,
399
+ "publish":true,
400
+ "contentDeliveryApi":true
401
+ },
402
+ {
403
+ "sys":{
404
+ "type":"Locale",
405
+ "id":"3V5DI3HspzHXRhUuNNW8x8",
406
+ "version":0,
407
+ "space":{
408
+ "sys":{
409
+ "type":"Link",
410
+ "linkType":"Space",
411
+ "id":"yr5m0jky5hsh"
412
+ }
413
+ },
414
+ "createdBy":{
415
+ "sys":{
416
+ "type":"Link",
417
+ "linkType":"User",
418
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
419
+ }
420
+ },
421
+ "createdAt":"2014-07-30T11:56:45Z",
422
+ "updatedBy":{
423
+ "sys":{
424
+ "type":"Link",
425
+ "linkType":"User",
426
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
427
+ }
428
+ },
429
+ "updatedAt":"2014-07-30T11:56:45Z"
430
+ },
431
+ "name":"Polish",
432
+ "code":"pl",
433
+ "default":false,
434
+ "contentManagementApi":true,
435
+ "publish":true,
436
+ "contentDeliveryApi":true
437
+ },
438
+ {
439
+ "sys":{
440
+ "type":"Locale",
441
+ "id":"7E40Gt0Du4KBPwfw7pPw2O",
442
+ "version":0,
443
+ "space":{
444
+ "sys":{
445
+ "type":"Link",
446
+ "linkType":"Space",
447
+ "id":"yr5m0jky5hsh"
448
+ }
449
+ },
450
+ "createdBy":{
451
+ "sys":{
452
+ "type":"Link",
453
+ "linkType":"User",
454
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
455
+ }
456
+ },
457
+ "createdAt":"2014-07-30T12:07:20Z",
458
+ "updatedBy":{
459
+ "sys":{
460
+ "type":"Link",
461
+ "linkType":"User",
462
+ "id":"1E7acJL8I5XUXAMHQt9Grs"
463
+ }
464
+ },
465
+ "updatedAt":"2014-07-30T12:07:20Z"
466
+ },
467
+ "name":"Belgium",
468
+ "code":"bl-BL",
469
+ "default":false,
470
+ "contentManagementApi":true,
471
+ "publish":true,
472
+ "contentDeliveryApi":true
473
+ }
474
+ ],
475
+ "total":4,
476
+ "limit":25,
477
+ "skip":0}
478
+ http_version:
479
+ recorded_at: Thu, 31 Jul 2014 07:10:03 GMT
480
+ - request:
481
+ method: get
482
+ uri: https://api.contentful.com/spaces/yr5m0jky5hsh/locales/42irhRZ5uMrRc9SZ1PyDRk
483
+ body:
484
+ encoding: US-ASCII
485
+ string: ''
486
+ headers:
487
+ User-Agent:
488
+ - RubyContenfulManagementGem/0.0.1
489
+ Authorization:
490
+ - Bearer <ACCESS_TOKEN>
491
+ Content-Type:
492
+ - application/vnd.contentful.management.v1+json
493
+ Content-Length:
494
+ - '0'
495
+ Host:
496
+ - api.contentful.com
497
+ response:
498
+ status:
499
+ code: 200
500
+ message: OK
501
+ headers:
502
+ Server:
503
+ - nginx
504
+ Date:
505
+ - Thu, 31 Jul 2014 07:10:04 GMT
506
+ Content-Type:
507
+ - application/vnd.contentful.management.v1+json
508
+ Content-Length:
509
+ - '700'
510
+ Connection:
511
+ - keep-alive
512
+ Status:
513
+ - 200 OK
514
+ X-Contentful-Request-Id:
515
+ - 85f-1334431494
516
+ Etag:
517
+ - '"223ca1fe077cffa1fe228a6303f2b0c8"'
518
+ Accept-Ranges:
519
+ - bytes
520
+ Cache-Control:
521
+ - max-age=0
522
+ Access-Control-Allow-Origin:
523
+ - "*"
524
+ Access-Control-Allow-Headers:
525
+ - 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
526
+ Access-Control-Allow-Methods:
527
+ - DELETE,GET,HEAD,POST,PUT,OPTIONS
528
+ "^access-Control-Expose-Headers":
529
+ - Etag
530
+ Access-Control-Max-Age:
531
+ - '1728000'
532
+ body:
533
+ encoding: UTF-8
534
+ string: |
535
+ {
536
+ "sys":{
537
+ "type":"Locale",
538
+ "id":"42irhRZ5uMrRc9SZ1PyDRk",
539
+ "version":0,
540
+ "space":{
541
+ "sys":{
542
+ "type":"Link",
543
+ "linkType":"Space",
544
+ "id":"yr5m0jky5hsh"
545
+ }
546
+ },
547
+ "createdBy":{
548
+ "sys":{
549
+ "type":"Link",
550
+ "linkType":"User",
551
+ "id":"0fn5fOWn4WsKFyYla1gI5h"
552
+ }
553
+ },
554
+ "createdAt":"2014-07-30T07:46:19Z",
555
+ "updatedBy":{
556
+ "sys":{
557
+ "type":"Link",
558
+ "linkType":"User",
559
+ "id":"0fn5fOWn4WsKFyYla1gI5h"
560
+ }
561
+ },
562
+ "updatedAt":"2014-07-30T07:46:19Z"
563
+ },
564
+ "name":"German",
565
+ "code":"de-DE",
566
+ "default":true,
567
+ "contentManagementApi":true,
568
+ "publish":true,
569
+ "contentDeliveryApi":true}
570
+ http_version:
571
+ recorded_at: Thu, 31 Jul 2014 07:10:04 GMT
572
+ recorded_with: VCR 2.9.2
@@ -578,6 +578,7 @@ module Contentful
578
578
  content_type.fields.create(id: 'valid', name: 'Valid', type: 'Text', validations: [validation_size])
579
579
  expect(content_type.fields[2].validations.last.properties[:size]['min']).to eq 10
580
580
  expect(content_type.fields[2].validations.last.properties[:size]['max']).to eq 15
581
+ expect(content_type.fields[2].validations.last.type).to be :size
581
582
  end
582
583
  end
583
584
  end
@@ -591,6 +592,7 @@ module Contentful
591
592
  content_type.fields.create(id: 'number', name: 'Number', type: 'Number', validations: [validation_range])
592
593
  expect(content_type.fields.first.validations.first.properties[:range]['min']).to eq 30
593
594
  expect(content_type.fields.first.validations.first.properties[:range]['max']).to eq 100
595
+ expect(content_type.fields.first.validations.first.type).to be :range
594
596
  end
595
597
  end
596
598
  it 'change `range` validation to existing field' do
@@ -613,6 +615,7 @@ module Contentful
613
615
  validation_present.present = true
614
616
  content_type.fields.create(id: 'present', name: 'Present', type: 'Text', validations: [validation_present])
615
617
  expect(content_type.fields.last.validations.last.properties[:present]).to be_truthy
618
+ expect(content_type.fields.last.validations.last.type).to be :present
616
619
  end
617
620
  end
618
621
  end
@@ -625,6 +628,7 @@ module Contentful
625
628
  content_type.fields.create(id: 'text', name: 'Text', type: 'Text', validations: [validation_regexp])
626
629
  expect(content_type.fields.last.validations.first.properties[:regexp]['pattern']).to eq '^such'
627
630
  expect(content_type.fields.last.validations.first.properties[:regexp]['flags']).to eq 'im'
631
+ expect(content_type.fields.last.validations.first.type).to eq :regexp
628
632
  end
629
633
  end
630
634
  end
@@ -636,6 +640,7 @@ module Contentful
636
640
  validation_link_content_type.link_content_type = ['post_content_type']
637
641
  content_type.fields.create(id: 'entries', validations: [validation_link_content_type])
638
642
  expect(content_type.fields[1].validations.first.properties[:linkContentType]).to eq %w( post_content_type )
643
+ expect(content_type.fields[1].validations.first.type).to be :linkContentType
639
644
  end
640
645
  end
641
646
  end
@@ -647,6 +652,7 @@ module Contentful
647
652
  validation_link_mimetype_group.link_mimetype_group = 'image'
648
653
  content_type.fields.create(id: 'entries', validations: [validation_link_mimetype_group])
649
654
  expect(content_type.fields[1].validations.first.properties[:linkMimetypeGroup]).to eq 'image'
655
+ expect(content_type.fields[1].validations.first.type).to be :linkMimetypeGroup
650
656
  end
651
657
  end
652
658
  end
@@ -658,6 +664,7 @@ module Contentful
658
664
  validation_link_mimetype_group.link_field = true
659
665
  content_type.fields.create(id: 'link_field', validations: [validation_link_mimetype_group])
660
666
  expect(content_type.fields.last.validations.first.properties[:linkField]).to be_truthy
667
+ expect(content_type.fields.last.validations.first.type).to be :linkField
661
668
  end
662
669
  end
663
670
  end
@@ -61,6 +61,21 @@ module Contentful
61
61
  end
62
62
  end
63
63
  end
64
+
65
+ describe '#default' do
66
+ it 'is false for non default' do
67
+ vcr('locale/find_not_default') do
68
+ locale = subject.find(space_id, locale_id)
69
+ expect(locale.default).to be_falsey
70
+ end
71
+ end
72
+ it 'is true for default' do
73
+ vcr('locale/find_default') do
74
+ locale = subject.find(space_id, locale_id)
75
+ expect(locale.default).to be_truthy
76
+ end
77
+ end
78
+ end
64
79
  end
65
80
  end
66
81
  end
@@ -38,7 +38,7 @@ module Contentful
38
38
  end
39
39
  end
40
40
  it 'returns space for a given key' do
41
- vcr('space/find') do
41
+ vcr('space/locale/find') do
42
42
  space = subject.find(space_id)
43
43
  expect(space.id).to eql space_id
44
44
  expect(space.default_locale).to eql 'en-US'
@@ -152,6 +152,15 @@ module Contentful
152
152
  end
153
153
  end
154
154
 
155
+ describe '#default_locale' do
156
+ it 'can set default locales from space locales on already existing spaces' do
157
+ vcr('space/locale/find_other_locale') do
158
+ space = subject.find(space_id)
159
+ expect(space.default_locale).to eql 'de-DE'
160
+ end
161
+ end
162
+ end
163
+
155
164
  describe '#locales' do
156
165
  let(:locale_id) { '42irhRZ5uMrRc9SZ1PyDRk' }
157
166
 
metadata CHANGED
@@ -1,145 +1,150 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful-management
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Protas
8
8
  - Tomasz Warkocki
9
9
  - Contentful GmbH (Andreas Tiefenthaler)
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-06-24 00:00:00.000000000 Z
13
+ date: 2015-10-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: http
17
16
  requirement: !ruby/object:Gem::Requirement
18
17
  requirements:
19
18
  - - "~>"
20
19
  - !ruby/object:Gem::Version
21
20
  version: '0.8'
22
- type: :runtime
21
+ name: http
23
22
  prerelease: false
23
+ type: :runtime
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0.8'
29
29
  - !ruby/object:Gem::Dependency
30
- name: multi_json
31
30
  requirement: !ruby/object:Gem::Requirement
32
31
  requirements:
33
32
  - - "~>"
34
33
  - !ruby/object:Gem::Version
35
34
  version: '1'
36
- type: :runtime
35
+ name: multi_json
37
36
  prerelease: false
37
+ type: :runtime
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '1'
43
43
  - !ruby/object:Gem::Dependency
44
- name: bundler
45
44
  requirement: !ruby/object:Gem::Requirement
46
45
  requirements:
47
46
  - - "~>"
48
47
  - !ruby/object:Gem::Version
49
48
  version: '1.6'
50
- type: :development
49
+ name: bundler
51
50
  prerelease: false
51
+ type: :development
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '1.6'
57
57
  - !ruby/object:Gem::Dependency
58
- name: rake
59
58
  requirement: !ruby/object:Gem::Requirement
60
59
  requirements:
61
60
  - - ">="
62
61
  - !ruby/object:Gem::Version
63
62
  version: '0'
64
- type: :development
63
+ name: rake
65
64
  prerelease: false
65
+ type: :development
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  - !ruby/object:Gem::Dependency
72
- name: rspec
73
72
  requirement: !ruby/object:Gem::Requirement
74
73
  requirements:
75
74
  - - "~>"
76
75
  - !ruby/object:Gem::Version
77
76
  version: '3'
78
- type: :development
77
+ name: rspec
79
78
  prerelease: false
79
+ type: :development
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
84
  version: '3'
85
85
  - !ruby/object:Gem::Dependency
86
- name: rspec-its
87
86
  requirement: !ruby/object:Gem::Requirement
88
87
  requirements:
89
88
  - - ">="
90
89
  - !ruby/object:Gem::Version
91
90
  version: '0'
92
- type: :development
91
+ name: rspec-its
93
92
  prerelease: false
93
+ type: :development
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  - !ruby/object:Gem::Dependency
100
- name: rubocop
101
100
  requirement: !ruby/object:Gem::Requirement
102
101
  requirements:
103
102
  - - ">="
104
103
  - !ruby/object:Gem::Version
105
104
  version: '0'
106
- type: :development
105
+ name: rubocop
107
106
  prerelease: false
107
+ type: :development
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  - !ruby/object:Gem::Dependency
114
- name: reek
115
114
  requirement: !ruby/object:Gem::Requirement
116
115
  requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '2'
117
119
  - - ">="
118
120
  - !ruby/object:Gem::Version
119
- version: '0'
120
- type: :development
121
+ version: 2.0.4
122
+ name: reek
121
123
  prerelease: false
124
+ type: :development
122
125
  version_requirements: !ruby/object:Gem::Requirement
123
126
  requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '2'
124
130
  - - ">="
125
131
  - !ruby/object:Gem::Version
126
- version: '0'
132
+ version: 2.0.4
127
133
  - !ruby/object:Gem::Dependency
128
- name: vcr
129
134
  requirement: !ruby/object:Gem::Requirement
130
135
  requirements:
131
136
  - - ">="
132
137
  - !ruby/object:Gem::Version
133
138
  version: '0'
134
- type: :development
139
+ name: vcr
135
140
  prerelease: false
141
+ type: :development
136
142
  version_requirements: !ruby/object:Gem::Requirement
137
143
  requirements:
138
144
  - - ">="
139
145
  - !ruby/object:Gem::Version
140
146
  version: '0'
141
147
  - !ruby/object:Gem::Dependency
142
- name: webmock
143
148
  requirement: !ruby/object:Gem::Requirement
144
149
  requirements:
145
150
  - - "~>"
@@ -148,8 +153,9 @@ dependencies:
148
153
  - - ">="
149
154
  - !ruby/object:Gem::Version
150
155
  version: 1.17.3
151
- type: :development
156
+ name: webmock
152
157
  prerelease: false
158
+ type: :development
153
159
  version_requirements: !ruby/object:Gem::Requirement
154
160
  requirements:
155
161
  - - "~>"
@@ -376,7 +382,9 @@ files:
376
382
  - spec/fixtures/vcr_cassettes/locale/all_for_space.yml
377
383
  - spec/fixtures/vcr_cassettes/locale/create_for_space.yml
378
384
  - spec/fixtures/vcr_cassettes/locale/find.yml
385
+ - spec/fixtures/vcr_cassettes/locale/find_default.yml
379
386
  - spec/fixtures/vcr_cassettes/locale/find_for_space_not_found.yml
387
+ - spec/fixtures/vcr_cassettes/locale/find_not_default.yml
380
388
  - spec/fixtures/vcr_cassettes/locale/reload.yml
381
389
  - spec/fixtures/vcr_cassettes/space/all.yml
382
390
  - spec/fixtures/vcr_cassettes/space/asset/all.yml
@@ -407,6 +415,7 @@ files:
407
415
  - spec/fixtures/vcr_cassettes/space/locale/create_with_the_same_code.yml
408
416
  - spec/fixtures/vcr_cassettes/space/locale/find.yml
409
417
  - spec/fixtures/vcr_cassettes/space/locale/find_not_found.yml
418
+ - spec/fixtures/vcr_cassettes/space/locale/find_other_locale.yml
410
419
  - spec/fixtures/vcr_cassettes/space/locale/update.yml
411
420
  - spec/fixtures/vcr_cassettes/space/reload.yml
412
421
  - spec/fixtures/vcr_cassettes/space/save_new_space.yml
@@ -437,7 +446,7 @@ homepage: https://github.com/contentful/contentful-management.rb
437
446
  licenses:
438
447
  - MIT
439
448
  metadata: {}
440
- post_install_message:
449
+ post_install_message:
441
450
  rdoc_options: []
442
451
  require_paths:
443
452
  - lib
@@ -452,9 +461,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
452
461
  - !ruby/object:Gem::Version
453
462
  version: '0'
454
463
  requirements: []
455
- rubyforge_project:
456
- rubygems_version: 2.2.2
457
- signing_key:
464
+ rubyforge_project:
465
+ rubygems_version: 2.4.8
466
+ signing_key:
458
467
  specification_version: 4
459
468
  summary: contentful management api
460
469
  test_files:
@@ -614,7 +623,9 @@ test_files:
614
623
  - spec/fixtures/vcr_cassettes/locale/all_for_space.yml
615
624
  - spec/fixtures/vcr_cassettes/locale/create_for_space.yml
616
625
  - spec/fixtures/vcr_cassettes/locale/find.yml
626
+ - spec/fixtures/vcr_cassettes/locale/find_default.yml
617
627
  - spec/fixtures/vcr_cassettes/locale/find_for_space_not_found.yml
628
+ - spec/fixtures/vcr_cassettes/locale/find_not_default.yml
618
629
  - spec/fixtures/vcr_cassettes/locale/reload.yml
619
630
  - spec/fixtures/vcr_cassettes/space/all.yml
620
631
  - spec/fixtures/vcr_cassettes/space/asset/all.yml
@@ -645,6 +656,7 @@ test_files:
645
656
  - spec/fixtures/vcr_cassettes/space/locale/create_with_the_same_code.yml
646
657
  - spec/fixtures/vcr_cassettes/space/locale/find.yml
647
658
  - spec/fixtures/vcr_cassettes/space/locale/find_not_found.yml
659
+ - spec/fixtures/vcr_cassettes/space/locale/find_other_locale.yml
648
660
  - spec/fixtures/vcr_cassettes/space/locale/update.yml
649
661
  - spec/fixtures/vcr_cassettes/space/reload.yml
650
662
  - spec/fixtures/vcr_cassettes/space/save_new_space.yml