contentful 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +24 -26
- data/README.md +5 -0
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +2399 -460
- data/coverage/assets/{0.10.1 → 0.10.2}/application.css +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/application.js +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/colorbox/border.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/colorbox/controls.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/colorbox/loading.gif +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/colorbox/loading_background.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/favicon_green.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/favicon_red.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/favicon_yellow.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/loading.gif +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/magnify.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/{0.10.1 → 0.10.2}/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +17490 -3213
- data/doc/Contentful.html +3 -3
- data/doc/Contentful/AccessDenied.html +1 -1
- data/doc/Contentful/Array.html +1 -1
- data/doc/Contentful/ArrayCoercion.html +7 -7
- data/doc/Contentful/ArrayLike.html +1 -1
- data/doc/Contentful/Asset.html +1 -1
- data/doc/Contentful/BadGateway.html +159 -0
- data/doc/Contentful/BadRequest.html +1 -1
- data/doc/Contentful/BaseCoercion.html +1 -1
- data/doc/Contentful/BaseResource.html +2 -2
- data/doc/Contentful/BooleanCoercion.html +1 -1
- data/doc/Contentful/Client.html +20 -26
- data/doc/Contentful/ContentType.html +7 -1
- data/doc/Contentful/ContentTypeCache.html +1 -1
- data/doc/Contentful/DateCoercion.html +1 -1
- data/doc/Contentful/DeletedAsset.html +1 -1
- data/doc/Contentful/DeletedEntry.html +1 -1
- data/doc/Contentful/Entry.html +1 -1
- data/doc/Contentful/Error.html +16 -28
- data/doc/Contentful/Field.html +1 -1
- data/doc/Contentful/FieldsResource.html +1 -1
- data/doc/Contentful/File.html +8 -308
- data/doc/Contentful/FloatCoercion.html +1 -1
- data/doc/Contentful/IntegerCoercion.html +1 -1
- data/doc/Contentful/Link.html +1 -1
- data/doc/Contentful/LinkCoercion.html +1 -1
- data/doc/Contentful/Locale.html +1 -1
- data/doc/Contentful/Location.html +1 -1
- data/doc/Contentful/LocationCoercion.html +1 -1
- data/doc/Contentful/NotFound.html +1 -1
- data/doc/Contentful/ObjectCoercion.html +2 -2
- data/doc/Contentful/RateLimitExceeded.html +183 -2
- data/doc/Contentful/Request.html +1 -1
- data/doc/Contentful/ResourceBuilder.html +1 -1
- data/doc/Contentful/Response.html +72 -1
- data/doc/Contentful/ServerError.html +1 -1
- data/doc/Contentful/ServiceUnavailable.html +1 -1
- data/doc/Contentful/Space.html +1 -1
- data/doc/Contentful/StringCoercion.html +1 -1
- data/doc/Contentful/Support.html +49 -27
- data/doc/Contentful/SymbolCoercion.html +1 -1
- data/doc/Contentful/Sync.html +1 -1
- data/doc/Contentful/SyncPage.html +1 -1
- data/doc/Contentful/TextCoercion.html +1 -1
- data/doc/Contentful/Unauthorized.html +1 -1
- data/doc/Contentful/UnparsableJson.html +1 -1
- data/doc/Contentful/UnparsableResource.html +1 -1
- data/doc/_index.html +8 -1
- data/doc/class_list.html +1 -1
- data/doc/file.CHANGELOG.html +15 -1
- data/doc/file.LICENSE.html +1 -1
- data/doc/file.README.html +8 -1
- data/doc/index.html +8 -1
- data/doc/method_list.html +147 -155
- data/doc/top-level-namespace.html +1 -1
- data/lib/contentful/asset.rb +2 -2
- data/lib/contentful/base_resource.rb +3 -3
- data/lib/contentful/client.rb +3 -3
- data/lib/contentful/coercions.rb +1 -20
- data/lib/contentful/content_type.rb +2 -0
- data/lib/contentful/entry.rb +4 -2
- data/lib/contentful/error.rb +168 -29
- data/lib/contentful/fields_resource.rb +8 -5
- data/lib/contentful/file.rb +14 -6
- data/lib/contentful/response.rb +5 -4
- data/lib/contentful/support.rb +4 -1
- data/lib/contentful/version.rb +1 -1
- data/spec/asset_spec.rb +9 -0
- data/spec/content_type_spec.rb +10 -0
- data/spec/deleted_asset_spec.rb +10 -0
- data/spec/deleted_entry_spec.rb +10 -0
- data/spec/entry_spec.rb +11 -0
- data/spec/error_class_spec.rb +244 -3
- data/spec/field_spec.rb +21 -0
- data/spec/file_spec.rb +10 -0
- data/spec/fixtures/json_responses/400_details_errors_object.json +14 -0
- data/spec/fixtures/json_responses/400_details_errors_string.json +12 -0
- data/spec/fixtures/json_responses/400_details_string.json +8 -0
- data/spec/fixtures/json_responses/403_reasons.json +13 -0
- data/spec/fixtures/json_responses/404_id.json +11 -0
- data/spec/fixtures/json_responses/404_type.json +10 -0
- data/spec/fixtures/json_responses/default_400.json +7 -0
- data/spec/fixtures/json_responses/default_401.json +7 -0
- data/spec/fixtures/json_responses/default_403.json +7 -0
- data/spec/fixtures/json_responses/default_404.json +7 -0
- data/spec/fixtures/json_responses/default_429.json +7 -0
- data/spec/fixtures/json_responses/default_500.json +7 -0
- data/spec/fixtures/json_responses/default_502.json +7 -0
- data/spec/fixtures/json_responses/default_503.json +7 -0
- data/spec/fixtures/json_responses/other_error.json +9 -0
- data/spec/fixtures/json_responses/other_error_no_details.json +8 -0
- data/spec/fixtures/json_responses/other_error_no_message.json +8 -0
- data/spec/fixtures/json_responses/other_error_no_request_id.json +8 -0
- data/spec/fixtures/json_responses/other_error_nothing.json +6 -0
- data/spec/link_spec.rb +9 -0
- data/spec/support/json_responses.rb +4 -2
- metadata +66 -27
data/lib/contentful/support.rb
CHANGED
@@ -5,9 +5,12 @@ module Contentful
|
|
5
5
|
# Transforms CamelCase into snake_case (taken from zucker)
|
6
6
|
#
|
7
7
|
# @param [String] object camelCaseName
|
8
|
+
# @param [Boolean] skip if true, skips returns original object
|
8
9
|
#
|
9
10
|
# @return [String] snake_case_name
|
10
|
-
def snakify(object)
|
11
|
+
def snakify(object, skip = false)
|
12
|
+
return object if skip
|
13
|
+
|
11
14
|
String(object)
|
12
15
|
.gsub(/::/, '/')
|
13
16
|
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
data/lib/contentful/version.rb
CHANGED
data/spec/asset_spec.rb
CHANGED
@@ -156,4 +156,13 @@ describe Contentful::Asset do
|
|
156
156
|
}
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
describe 'camelCase' do
|
161
|
+
it 'properties now are accessed with camelcase' do
|
162
|
+
vcr('asset') {
|
163
|
+
asset = create_client(use_camel_case: true).asset('nyancat')
|
164
|
+
expect(asset.file.fileName).to eq 'Nyan_cat_250px_frame.png'
|
165
|
+
}
|
166
|
+
end
|
167
|
+
end
|
159
168
|
end
|
data/spec/content_type_spec.rb
CHANGED
@@ -36,4 +36,14 @@ describe Contentful::ContentType do
|
|
36
36
|
expect(content_type).to respond_to :display_field
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe 'camel case' do
|
41
|
+
it 'supports camel case' do
|
42
|
+
vcr('content_type') {
|
43
|
+
content_type = create_client(use_camel_case: true).content_type 'cat'
|
44
|
+
|
45
|
+
expect(content_type.displayField).to eq 'name'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
39
49
|
end
|
data/spec/deleted_asset_spec.rb
CHANGED
@@ -25,4 +25,14 @@ describe 'DeletedAsset' do
|
|
25
25
|
expect(deleted_asset.created_at).to be_a DateTime
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe 'camel case' do
|
30
|
+
it 'supports camel case' do
|
31
|
+
vcr('sync_deleted_asset') {
|
32
|
+
deleted_asset = create_client(use_camel_case: true).sync(initial: true, type: 'DeletedAsset').first_page.items[0]
|
33
|
+
|
34
|
+
expect(deleted_asset.createdAt).to be_a DateTime
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
28
38
|
end
|
data/spec/deleted_entry_spec.rb
CHANGED
@@ -25,4 +25,14 @@ describe 'DeletedEntry' do
|
|
25
25
|
expect(deleted_entry.created_at).to be_a DateTime
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe 'camel case' do
|
30
|
+
it 'supports camel case' do
|
31
|
+
vcr('sync_deleted_entry') {
|
32
|
+
deleted_entry = create_client(use_camel_case: true).sync(initial: true, type: 'DeletedEntry').first_page.items[0]
|
33
|
+
|
34
|
+
expect(deleted_entry.createdAt).to be_a DateTime
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
28
38
|
end
|
data/spec/entry_spec.rb
CHANGED
@@ -358,4 +358,15 @@ describe Contentful::Entry do
|
|
358
358
|
}
|
359
359
|
end
|
360
360
|
end
|
361
|
+
|
362
|
+
describe 'camel case' do
|
363
|
+
it 'supports camel case' do
|
364
|
+
vcr('entry') {
|
365
|
+
entry = create_client(use_camel_case: true).entry 'nyancat'
|
366
|
+
|
367
|
+
expect(entry.bestFriend.name).to eq 'Happy Cat'
|
368
|
+
expect(entry.createdAt).to be_a DateTime
|
369
|
+
}
|
370
|
+
end
|
371
|
+
end
|
361
372
|
end
|
data/spec/error_class_spec.rb
CHANGED
@@ -11,9 +11,251 @@ describe Contentful::Error do
|
|
11
11
|
|
12
12
|
describe '#message' do
|
13
13
|
it 'returns the message found in the response json' do
|
14
|
+
message = "HTTP status code: 404\n"\
|
15
|
+
"Message: The resource could not be found.\n"\
|
16
|
+
"Details: {\"type\"=>\"Entry\", \"space\"=>\"cfexampleapi\", \"id\"=>\"not found\"}\n"\
|
17
|
+
"Request ID: 85f-351076632"
|
14
18
|
expect(Contentful::Error.new(r).message).not_to be_nil
|
15
|
-
expect(Contentful::Error.new(r).message).to
|
16
|
-
|
19
|
+
expect(Contentful::Error.new(r).message).to eq message
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'message types' do
|
23
|
+
describe 'default messages' do
|
24
|
+
it '400' do
|
25
|
+
response = Contentful::Response.new raw_fixture('default_400', 400)
|
26
|
+
error = Contentful::Error[response.raw.status].new(response)
|
27
|
+
|
28
|
+
message = "HTTP status code: 400\n"\
|
29
|
+
"Message: The request was malformed or missing a required parameter.\n"\
|
30
|
+
"Request ID: 85f-351076632"
|
31
|
+
expect(error.message).to eq message
|
32
|
+
end
|
33
|
+
|
34
|
+
it '401' do
|
35
|
+
response = Contentful::Response.new raw_fixture('default_401', 401)
|
36
|
+
error = Contentful::Error[response.raw.status].new(response)
|
37
|
+
|
38
|
+
message = "HTTP status code: 401\n"\
|
39
|
+
"Message: The authorization token was invalid.\n"\
|
40
|
+
"Request ID: 85f-351076632"
|
41
|
+
expect(error.message).to eq message
|
42
|
+
end
|
43
|
+
|
44
|
+
it '403' do
|
45
|
+
response = Contentful::Response.new raw_fixture('default_403', 403)
|
46
|
+
error = Contentful::Error[response.raw.status].new(response)
|
47
|
+
|
48
|
+
message = "HTTP status code: 403\n"\
|
49
|
+
"Message: The specified token does not have access to the requested resource.\n"\
|
50
|
+
"Request ID: 85f-351076632"
|
51
|
+
expect(error.message).to eq message
|
52
|
+
end
|
53
|
+
|
54
|
+
it '404' do
|
55
|
+
response = Contentful::Response.new raw_fixture('default_404', 404)
|
56
|
+
error = Contentful::Error[response.raw.status].new(response)
|
57
|
+
|
58
|
+
message = "HTTP status code: 404\n"\
|
59
|
+
"Message: The requested resource or endpoint could not be found.\n"\
|
60
|
+
"Request ID: 85f-351076632"
|
61
|
+
expect(error.message).to eq message
|
62
|
+
end
|
63
|
+
|
64
|
+
it '429' do
|
65
|
+
response = Contentful::Response.new raw_fixture('default_429', 429)
|
66
|
+
error = Contentful::Error[response.raw.status].new(response)
|
67
|
+
|
68
|
+
message = "HTTP status code: 429\n"\
|
69
|
+
"Message: Rate limit exceeded. Too many requests.\n"\
|
70
|
+
"Request ID: 85f-351076632"
|
71
|
+
expect(error.message).to eq message
|
72
|
+
end
|
73
|
+
|
74
|
+
it '500' do
|
75
|
+
response = Contentful::Response.new raw_fixture('default_500', 500)
|
76
|
+
error = Contentful::Error[response.raw.status].new(response)
|
77
|
+
|
78
|
+
message = "HTTP status code: 500\n"\
|
79
|
+
"Message: Internal server error.\n"\
|
80
|
+
"Request ID: 85f-351076632"
|
81
|
+
expect(error.message).to eq message
|
82
|
+
end
|
83
|
+
|
84
|
+
it '502' do
|
85
|
+
response = Contentful::Response.new raw_fixture('default_502', 502)
|
86
|
+
error = Contentful::Error[response.raw.status].new(response)
|
87
|
+
|
88
|
+
message = "HTTP status code: 502\n"\
|
89
|
+
"Message: The requested space is hibernated.\n"\
|
90
|
+
"Request ID: 85f-351076632"
|
91
|
+
expect(error.message).to eq message
|
92
|
+
end
|
93
|
+
|
94
|
+
it '503' do
|
95
|
+
response = Contentful::Response.new raw_fixture('default_503', 503)
|
96
|
+
error = Contentful::Error[response.raw.status].new(response)
|
97
|
+
|
98
|
+
message = "HTTP status code: 503\n"\
|
99
|
+
"Message: The request was malformed or missing a required parameter.\n"\
|
100
|
+
"Request ID: 85f-351076632"
|
101
|
+
expect(error.message).to eq message
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'special cases' do
|
106
|
+
describe '400' do
|
107
|
+
it 'details is a string' do
|
108
|
+
response = Contentful::Response.new raw_fixture('400_details_string', 400)
|
109
|
+
error = Contentful::Error[response.raw.status].new(response)
|
110
|
+
|
111
|
+
message = "HTTP status code: 400\n"\
|
112
|
+
"Message: The request was malformed or missing a required parameter.\n"\
|
113
|
+
"Details: some error\n"\
|
114
|
+
"Request ID: 85f-351076632"
|
115
|
+
expect(error.message).to eq message
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'details is an object, internal errors are strings' do
|
119
|
+
response = Contentful::Response.new raw_fixture('400_details_errors_string', 400)
|
120
|
+
error = Contentful::Error[response.raw.status].new(response)
|
121
|
+
|
122
|
+
message = "HTTP status code: 400\n"\
|
123
|
+
"Message: The request was malformed or missing a required parameter.\n"\
|
124
|
+
"Details: some error\n"\
|
125
|
+
"Request ID: 85f-351076632"
|
126
|
+
expect(error.message).to eq message
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'details is an object, internal errors are objects which have details' do
|
130
|
+
response = Contentful::Response.new raw_fixture('400_details_errors_object', 400)
|
131
|
+
error = Contentful::Error[response.raw.status].new(response)
|
132
|
+
|
133
|
+
message = "HTTP status code: 400\n"\
|
134
|
+
"Message: The request was malformed or missing a required parameter.\n"\
|
135
|
+
"Details: some error\n"\
|
136
|
+
"Request ID: 85f-351076632"
|
137
|
+
expect(error.message).to eq message
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe '403' do
|
142
|
+
it 'has an array of reasons' do
|
143
|
+
response = Contentful::Response.new raw_fixture('403_reasons', 403)
|
144
|
+
error = Contentful::Error[response.raw.status].new(response)
|
145
|
+
|
146
|
+
message = "HTTP status code: 403\n"\
|
147
|
+
"Message: The specified token does not have access to the requested resource.\n"\
|
148
|
+
"Details: \n\tReasons:\n"\
|
149
|
+
"\t\tfoo\n"\
|
150
|
+
"\t\tbar\n"\
|
151
|
+
"Request ID: 85f-351076632"
|
152
|
+
expect(error.message).to eq message
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '404' do
|
157
|
+
it 'has a type' do
|
158
|
+
response = Contentful::Response.new raw_fixture('404_type', 404)
|
159
|
+
error = Contentful::Error[response.raw.status].new(response)
|
160
|
+
|
161
|
+
message = "HTTP status code: 404\n"\
|
162
|
+
"Message: The requested resource or endpoint could not be found.\n"\
|
163
|
+
"Details: The requested Asset could not be found.\n"\
|
164
|
+
"Request ID: 85f-351076632"
|
165
|
+
expect(error.message).to eq message
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'can specify the resource id' do
|
169
|
+
response = Contentful::Response.new raw_fixture('404_id', 404)
|
170
|
+
error = Contentful::Error[response.raw.status].new(response)
|
171
|
+
|
172
|
+
message = "HTTP status code: 404\n"\
|
173
|
+
"Message: The requested resource or endpoint could not be found.\n"\
|
174
|
+
"Details: The requested Asset could not be found. ID: foobar.\n"\
|
175
|
+
"Request ID: 85f-351076632"
|
176
|
+
expect(error.message).to eq message
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe '429' do
|
181
|
+
it 'can show the time until reset' do
|
182
|
+
response = Contentful::Response.new raw_fixture('default_429', 429, false, {'x-contentful-ratelimit-reset' => 60})
|
183
|
+
error = Contentful::Error[response.raw.status].new(response)
|
184
|
+
|
185
|
+
message = "HTTP status code: 429\n"\
|
186
|
+
"Message: Rate limit exceeded. Too many requests.\n"\
|
187
|
+
"Request ID: 85f-351076632\n"\
|
188
|
+
"Time until reset (seconds): 60"
|
189
|
+
expect(error.message).to eq message
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe 'generic error' do
|
195
|
+
it 'with everything' do
|
196
|
+
response = Contentful::Response.new raw_fixture('other_error', 512)
|
197
|
+
error = Contentful::Error[response.raw.status].new(response)
|
198
|
+
|
199
|
+
message = "HTTP status code: 512\n"\
|
200
|
+
"Message: Some error occurred.\n"\
|
201
|
+
"Details: some text\n"\
|
202
|
+
"Request ID: 85f-351076632"
|
203
|
+
expect(error.message).to eq message
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'no details' do
|
207
|
+
response = Contentful::Response.new raw_fixture('other_error_no_details', 512)
|
208
|
+
error = Contentful::Error[response.raw.status].new(response)
|
209
|
+
|
210
|
+
message = "HTTP status code: 512\n"\
|
211
|
+
"Message: Some error occurred.\n"\
|
212
|
+
"Request ID: 85f-351076632"
|
213
|
+
expect(error.message).to eq message
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'no request id' do
|
217
|
+
response = Contentful::Response.new raw_fixture('other_error_no_request_id', 512)
|
218
|
+
error = Contentful::Error[response.raw.status].new(response)
|
219
|
+
|
220
|
+
message = "HTTP status code: 512\n"\
|
221
|
+
"Message: Some error occurred.\n"\
|
222
|
+
"Details: some text"
|
223
|
+
expect(error.message).to eq message
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'no message' do
|
227
|
+
response = Contentful::Response.new raw_fixture('other_error_no_message', 512)
|
228
|
+
error = Contentful::Error[response.raw.status].new(response)
|
229
|
+
|
230
|
+
message = "HTTP status code: 512\n"\
|
231
|
+
"Message: The following error was received: {\n"\
|
232
|
+
" \"sys\": {\n"\
|
233
|
+
" \"type\": \"Error\",\n"\
|
234
|
+
" \"id\": \"SomeError\"\n"\
|
235
|
+
" },\n"\
|
236
|
+
" \"details\": \"some text\",\n"\
|
237
|
+
" \"requestId\": \"85f-351076632\"\n"\
|
238
|
+
"}\n"\
|
239
|
+
"\n"\
|
240
|
+
"Details: some text\n"\
|
241
|
+
"Request ID: 85f-351076632"
|
242
|
+
expect(error.message).to eq message
|
243
|
+
end
|
244
|
+
|
245
|
+
it 'nothing' do
|
246
|
+
response = Contentful::Response.new raw_fixture('other_error_nothing', 512)
|
247
|
+
error = Contentful::Error[response.raw.status].new(response)
|
248
|
+
|
249
|
+
message = "HTTP status code: 512\n"\
|
250
|
+
"Message: The following error was received: {\n"\
|
251
|
+
" \"sys\": {\n"\
|
252
|
+
" \"type\": \"Error\",\n"\
|
253
|
+
" \"id\": \"SomeError\"\n"\
|
254
|
+
" }\n"\
|
255
|
+
"}\n"
|
256
|
+
expect(error.message).to eq message
|
257
|
+
end
|
258
|
+
end
|
17
259
|
end
|
18
260
|
end
|
19
261
|
|
@@ -28,7 +270,6 @@ describe Contentful::Error do
|
|
28
270
|
end
|
29
271
|
|
30
272
|
describe '.[]' do
|
31
|
-
|
32
273
|
it 'returns BadRequest error class for 400' do
|
33
274
|
expect(Contentful::Error[400]).to eq Contentful::BadRequest
|
34
275
|
end
|
data/spec/field_spec.rb
CHANGED
@@ -58,4 +58,25 @@ describe Contentful::Field do
|
|
58
58
|
expect(arrayField.items.link_type).to eq 'Entry'
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
describe 'issues' do
|
63
|
+
describe 'json field' do
|
64
|
+
it 'can coerce properly when top level is not object' do
|
65
|
+
coercion = Contentful::ObjectCoercion.new([{foo: 123}])
|
66
|
+
expect(coercion.coerce).to eq [{foo: 123}]
|
67
|
+
|
68
|
+
coercion = Contentful::ObjectCoercion.new('foobar')
|
69
|
+
expect(coercion.coerce).to eq 'foobar'
|
70
|
+
|
71
|
+
coercion = Contentful::ObjectCoercion.new(true)
|
72
|
+
expect(coercion.coerce).to eq true
|
73
|
+
|
74
|
+
coercion = Contentful::ObjectCoercion.new(123)
|
75
|
+
expect(coercion.coerce).to eq 123
|
76
|
+
|
77
|
+
coercion = Contentful::ObjectCoercion.new({foo: 123})
|
78
|
+
expect(coercion.coerce).to eq(foo: 123)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
61
82
|
end
|
data/spec/file_spec.rb
CHANGED
@@ -20,4 +20,14 @@ describe Contentful::File do
|
|
20
20
|
expect(file.details).to be_instance_of Hash
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
describe 'camel case' do
|
25
|
+
it 'supports camel case' do
|
26
|
+
vcr('asset') {
|
27
|
+
file = create_client(use_camel_case: true).asset('nyancat').file
|
28
|
+
expect(file.contentType).to eq 'image/png'
|
29
|
+
expect(file.fileName).to eq 'Nyan_cat_250px_frame.png'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
23
33
|
end
|