contentful-management 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +15 -0
- data/README.md +209 -41
- data/contentful-management.gemspec +1 -1
- data/lib/contentful/management/asset.rb +1 -1
- data/lib/contentful/management/client.rb +155 -31
- data/lib/contentful/management/client_organization_methods_factory.rb +23 -0
- data/lib/contentful/management/client_personal_access_tokens_methods_factory.rb +27 -0
- data/lib/contentful/management/client_snapshot_methods_factory.rb +16 -6
- data/lib/contentful/management/client_space_membership_methods_factory.rb +15 -0
- data/lib/contentful/management/client_ui_extension_methods_factory.rb +15 -0
- data/lib/contentful/management/client_user_methods_factory.rb +27 -0
- data/lib/contentful/management/client_webhook_call_methods_factory.rb +30 -0
- data/lib/contentful/management/client_webhook_health_methods_factory.rb +27 -0
- data/lib/contentful/management/content_type.rb +10 -0
- data/lib/contentful/management/content_type_snapshot_methods_factory.rb +35 -0
- data/lib/contentful/management/editor_interface.rb +1 -1
- data/lib/contentful/management/organization.rb +20 -0
- data/lib/contentful/management/personal_access_token.rb +45 -0
- data/lib/contentful/management/request.rb +0 -1
- data/lib/contentful/management/resource.rb +4 -2
- data/lib/contentful/management/resource_builder.rb +15 -0
- data/lib/contentful/management/snapshot.rb +31 -20
- data/lib/contentful/management/space.rb +32 -10
- data/lib/contentful/management/space_membership.rb +43 -0
- data/lib/contentful/management/space_space_membership_methods_factory.rb +15 -0
- data/lib/contentful/management/space_ui_extension_methods_factory.rb +15 -0
- data/lib/contentful/management/ui_extension.rb +106 -0
- data/lib/contentful/management/user.rb +28 -0
- data/lib/contentful/management/version.rb +1 -1
- data/lib/contentful/management/webhook.rb +20 -0
- data/lib/contentful/management/webhook_call.rb +77 -0
- data/lib/contentful/management/webhook_health.rb +79 -0
- data/lib/contentful/management/webhook_webhook_call_methods_factory.rb +30 -0
- data/lib/contentful/management/webhook_webhook_health_methods_factory.rb +28 -0
- data/spec/fixtures/vcr_cassettes/get_request.yml +34 -17
- data/spec/fixtures/vcr_cassettes/organization/all.yml +100 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/all.yml +101 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/create.yml +94 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/find.yml +91 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/find_not_found.yml +88 -0
- data/spec/fixtures/vcr_cassettes/personal_access_token/revoke.yml +179 -0
- data/spec/fixtures/vcr_cassettes/snapshot/ct_all.yml +207 -0
- data/spec/fixtures/vcr_cassettes/snapshot/ct_find.yml +198 -0
- data/spec/fixtures/vcr_cassettes/snapshot/ct_find_not_found.yml +94 -0
- data/spec/fixtures/vcr_cassettes/space/all_disabled_cache.yml +428 -0
- data/spec/fixtures/vcr_cassettes/space/disabled_cache.yml +120 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/all.yml +190 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/create.yml +143 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/delete.yml +322 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/find.yml +141 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/all.yml +1020 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/create.yml +133 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/delete.yml +291 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/find.yml +126 -0
- data/spec/fixtures/vcr_cassettes/user/find.yml +96 -0
- data/spec/fixtures/vcr_cassettes/webhook_call/all.yml +151 -0
- data/spec/fixtures/vcr_cassettes/webhook_call/find.yml +88 -0
- data/spec/fixtures/vcr_cassettes/webhook_call/find_not_found.yml +93 -0
- data/spec/fixtures/vcr_cassettes/webhook_health/find.yml +111 -0
- data/spec/lib/contentful/management/client_spec.rb +25 -26
- data/spec/lib/contentful/management/entry_spec.rb +48 -48
- data/spec/lib/contentful/management/organization_spec.rb +33 -0
- data/spec/lib/contentful/management/personal_access_token_spec.rb +85 -0
- data/spec/lib/contentful/management/snapshot_spec.rb +134 -47
- data/spec/lib/contentful/management/space_membership_spec.rb +147 -0
- data/spec/lib/contentful/management/space_spec.rb +35 -1
- data/spec/lib/contentful/management/ui_extension_spec.rb +276 -0
- data/spec/lib/contentful/management/user_spec.rb +52 -0
- data/spec/lib/contentful/management/webhook_calls_spec.rb +69 -0
- data/spec/lib/contentful/management/webhook_health_spec.rb +51 -0
- metadata +88 -8
- data/lib/contentful/management/http_client.rb +0 -89
@@ -210,19 +210,19 @@ module Contentful
|
|
210
210
|
describe '#host_url' do
|
211
211
|
describe 'uploads' do
|
212
212
|
it 'returns uploads url when its a properly formed upload url' do
|
213
|
-
expect(subject.host_url(RequestDouble.new('/some_space_id/uploads'))).to eq subject.uploads_url
|
214
|
-
expect(subject.host_url(RequestDouble.new('/some_space_id/uploads/upload_id'))).to eq subject.uploads_url
|
215
|
-
expect(subject.host_url(RequestDouble.new('/uploads/uploads/uploads'))).to eq subject.uploads_url
|
213
|
+
expect(subject.host_url(RequestDouble.new('spaces/some_space_id/uploads'))).to eq subject.uploads_url
|
214
|
+
expect(subject.host_url(RequestDouble.new('spaces/some_space_id/uploads/upload_id'))).to eq subject.uploads_url
|
215
|
+
expect(subject.host_url(RequestDouble.new('spaces/uploads/uploads/uploads'))).to eq subject.uploads_url
|
216
216
|
end
|
217
217
|
|
218
218
|
it 'returns base url for non uploads url' do
|
219
|
-
uploads_as_space_id = '/uploads/entries/upload_id'
|
219
|
+
uploads_as_space_id = 'spaces/uploads/entries/upload_id'
|
220
220
|
expect(subject.host_url(RequestDouble.new(uploads_as_space_id))).to eq subject.base_url
|
221
221
|
|
222
|
-
uploads_as_entry_id = '/some_space_id/entries/uploads'
|
222
|
+
uploads_as_entry_id = 'spaces/some_space_id/entries/uploads'
|
223
223
|
expect(subject.host_url(RequestDouble.new(uploads_as_entry_id))).to eq subject.base_url
|
224
224
|
|
225
|
-
uploads_as_only_thing = '/uploads'
|
225
|
+
uploads_as_only_thing = 'spaces/uploads'
|
226
226
|
expect(subject.host_url(RequestDouble.new(uploads_as_only_thing))).to eq subject.base_url
|
227
227
|
end
|
228
228
|
end
|
@@ -253,31 +253,30 @@ module Contentful
|
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
|
-
describe '
|
257
|
-
|
258
|
-
|
259
|
-
|
256
|
+
describe 'http methods' do
|
257
|
+
let(:request) { Request.new(client, 'http://example.com', foo: 'bar') }
|
258
|
+
describe '#get' do
|
259
|
+
it 'does a GET request' do
|
260
|
+
vcr(:get_request) { subject.get(Request.new(client, 'http://mockbin.org/bin/be499b1d-286a-4d22-8d26-00a014b83817', foo: 'bar')) }
|
261
|
+
end
|
260
262
|
end
|
261
|
-
end
|
262
263
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
264
|
+
describe '#post' do
|
265
|
+
it 'does a POST request' do
|
266
|
+
vcr(:post_request) { subject.post(request) }
|
267
|
+
end
|
267
268
|
end
|
268
|
-
end
|
269
269
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
270
|
+
describe '#put' do
|
271
|
+
it 'does a PUT request' do
|
272
|
+
vcr(:put_request) { subject.put(request) }
|
273
|
+
end
|
274
274
|
end
|
275
|
-
end
|
276
275
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
276
|
+
describe '#delete' do
|
277
|
+
it 'does a DELETE request' do
|
278
|
+
vcr(:delete_request) { subject.delete(request) }
|
279
|
+
end
|
281
280
|
end
|
282
281
|
end
|
283
282
|
|
@@ -292,7 +291,7 @@ module Contentful
|
|
292
291
|
|
293
292
|
it 'effectively requests via proxy' do
|
294
293
|
vcr(:proxy_request) {
|
295
|
-
expect(subject
|
294
|
+
expect(subject).to receive(:proxy_send).twice.and_call_original
|
296
295
|
subject.spaces.find('zh42n1tmsaiq')
|
297
296
|
}
|
298
297
|
end
|
@@ -160,7 +160,7 @@ module Contentful
|
|
160
160
|
expect(result).to be_kind_of Contentful::Management::BadRequest
|
161
161
|
expect(result.message).to eq 'Not published'
|
162
162
|
expect(result.error[:message]).to eq 'Not published'
|
163
|
-
expect(result.error[:url]).to eq '/yr5m0jky5hsh/entries/4Rouux8SoUCKwkyCq2I0E0/published'
|
163
|
+
expect(result.error[:url]).to eq 'spaces/yr5m0jky5hsh/entries/4Rouux8SoUCKwkyCq2I0E0/published'
|
164
164
|
expect(result.error[:details]).to eq "{\n \"sys\": {\n \"type\": \"Error\",\n \"id\": \"BadRequest\"\n },\n \"message\": \"Not published\"\n}\n"
|
165
165
|
end
|
166
166
|
end
|
@@ -773,18 +773,18 @@ module Contentful
|
|
773
773
|
end
|
774
774
|
|
775
775
|
attributes = {
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
776
|
+
name: 'Test name',
|
777
|
+
number: 30,
|
778
|
+
float1: 1.1,
|
779
|
+
boolean: true, date: '2000-07-12T11:11:00+02:00',
|
780
|
+
time: '2000-07-12T11:11:00+02:00',
|
781
|
+
location: location,
|
782
|
+
image: Asset.new,
|
783
|
+
images: [Asset.new, Asset.new],
|
784
|
+
array: %w(PL USD XX),
|
785
|
+
entry: Entry.new,
|
786
|
+
entries: [Entry.new, Entry.new],
|
787
|
+
object_json: {'test' => {'@type' => 'Codequest'}}
|
788
788
|
}
|
789
789
|
|
790
790
|
parsed_attributes = Entry.new.fields_from_attributes(attributes)
|
@@ -807,7 +807,7 @@ module Contentful
|
|
807
807
|
|
808
808
|
it 'keepd hashes in attributes' do
|
809
809
|
attributes = {
|
810
|
-
|
810
|
+
entries: [{sys: {type: 'Link', linkType: 'Entry', id: nil}}, {sys: {type: 'Link', linkType: 'Entry', id: nil}}]
|
811
811
|
}
|
812
812
|
|
813
813
|
parsed_attributes = Entry.new.fields_from_attributes(attributes)
|
@@ -1040,53 +1040,53 @@ module Contentful
|
|
1040
1040
|
end
|
1041
1041
|
|
1042
1042
|
describe 'without dynamic entries' do
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1043
|
+
it 'on an already populated field' do
|
1044
|
+
vcr('entry/issue_61.7') {
|
1045
|
+
begin
|
1046
|
+
client.configuration[:default_locale] = 'en-GB'
|
1047
1047
|
|
1048
|
-
|
1048
|
+
expected_entry = subject.find('u2viwgfeal0o', 'fIpsfQSOd22IsqMQCiG0K')
|
1049
1049
|
|
1050
|
-
|
1050
|
+
expect(expected_entry.value).to eq 'hello'
|
1051
1051
|
|
1052
|
-
|
1052
|
+
expected_entry.value = 'goodbye'
|
1053
1053
|
|
1054
|
-
|
1055
|
-
|
1054
|
+
expected_entry.save
|
1055
|
+
expected_entry.publish
|
1056
1056
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1057
|
+
expect(expected_entry.value).to eq 'goodbye'
|
1058
|
+
ensure
|
1059
|
+
expected_entry.value = 'hello'
|
1060
1060
|
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1061
|
+
expected_entry.save
|
1062
|
+
expected_entry.publish
|
1063
|
+
end
|
1064
|
+
}
|
1065
|
+
end
|
1066
1066
|
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1067
|
+
it 'on a previously empty field' do
|
1068
|
+
vcr('entry/issue_61.8') {
|
1069
|
+
begin
|
1070
|
+
client.configuration[:default_locale] = 'en-GB'
|
1071
1071
|
|
1072
|
-
|
1072
|
+
expected_entry = subject.find('u2viwgfeal0o', '2GmtCwDBcIu4giMgQGIIcq')
|
1073
1073
|
|
1074
|
-
|
1074
|
+
expect(expected_entry.value).to eq nil
|
1075
1075
|
|
1076
|
-
|
1076
|
+
expected_entry.value = 'goodbye'
|
1077
1077
|
|
1078
|
-
|
1079
|
-
|
1078
|
+
expected_entry.save
|
1079
|
+
expected_entry.publish
|
1080
1080
|
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1081
|
+
expect(expected_entry.value).to eq 'goodbye'
|
1082
|
+
ensure
|
1083
|
+
expected_entry.value = nil
|
1084
1084
|
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1085
|
+
expected_entry.save
|
1086
|
+
expected_entry.publish
|
1087
|
+
end
|
1088
|
+
}
|
1089
|
+
end
|
1090
1090
|
end
|
1091
1091
|
end
|
1092
1092
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contentful/management/space'
|
3
|
+
require 'contentful/management/client'
|
4
|
+
|
5
|
+
module Contentful
|
6
|
+
module Management
|
7
|
+
describe Organization do
|
8
|
+
let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
|
9
|
+
let!(:client) { Client.new(token) }
|
10
|
+
|
11
|
+
subject { client.organizations }
|
12
|
+
|
13
|
+
describe '.all' do
|
14
|
+
it 'fetches the list of organizations belonging to the user' do
|
15
|
+
vcr('organization/all') {
|
16
|
+
organizations = subject.all
|
17
|
+
expect(organizations).to be_a Contentful::Management::Array
|
18
|
+
|
19
|
+
expect(organizations.first).to be_a Contentful::Management::Organization
|
20
|
+
expect(organizations.first.name).to eq 'My Test Organization'
|
21
|
+
expect(organizations.first.id).to be_truthy
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.find' do
|
27
|
+
it 'is not supported' do
|
28
|
+
expect { subject.find }.to raise_error 'Not supported'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contentful/management/space'
|
3
|
+
require 'contentful/management/client'
|
4
|
+
|
5
|
+
module Contentful
|
6
|
+
module Management
|
7
|
+
describe PersonalAccessToken do
|
8
|
+
let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
|
9
|
+
let(:pat_id) { '3XBnbqn5s7oJ5PxyZiTzIg' }
|
10
|
+
let!(:client) { Client.new(token) }
|
11
|
+
|
12
|
+
subject { client.personal_access_tokens }
|
13
|
+
|
14
|
+
describe '.all' do
|
15
|
+
it 'returns a Contentful::Array' do
|
16
|
+
vcr('personal_access_token/all') { expect(subject.all).to be_kind_of Contentful::Management::Array }
|
17
|
+
end
|
18
|
+
it 'builds a Contentful::Management::PersonalAccessToken object' do
|
19
|
+
vcr('personal_access_token/all') {
|
20
|
+
token = subject.all.first
|
21
|
+
expect(token).to be_kind_of Contentful::Management::PersonalAccessToken
|
22
|
+
expect(token.name).to eq 'Playground'
|
23
|
+
expect(token.revoked_at).to be_falsey
|
24
|
+
expect(token.scopes).not_to be_empty
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.find' do
|
30
|
+
it 'returns a Contentful::Management::Webhook' do
|
31
|
+
vcr('personal_access_token/find') { expect(subject.find(pat_id)).to be_kind_of Contentful::Management::PersonalAccessToken }
|
32
|
+
end
|
33
|
+
it 'returns webhook for a given key' do
|
34
|
+
vcr('personal_access_token/find') do
|
35
|
+
token = subject.find(pat_id)
|
36
|
+
expect(token.id).to eql pat_id
|
37
|
+
expect(token.name).to eq 'Playground'
|
38
|
+
expect(token.revoked_at).to be_falsey
|
39
|
+
expect(token.scopes).not_to be_empty
|
40
|
+
end
|
41
|
+
end
|
42
|
+
it 'returns an error when content_type does not exists' do
|
43
|
+
vcr('personal_access_token/find_not_found') do
|
44
|
+
result = subject.find('not_exist')
|
45
|
+
expect(result).to be_kind_of Contentful::Management::NotFound
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.create' do
|
51
|
+
it 'builds Contentful::Management::PersonalAccessToken object' do
|
52
|
+
vcr('personal_access_token/create') do
|
53
|
+
token = subject.create(name: 'Test Token', scopes: ["content_management_manage"])
|
54
|
+
expect(token).to be_kind_of Contentful::Management::PersonalAccessToken
|
55
|
+
expect(token.name).to eq 'Test Token'
|
56
|
+
expect(token.token).to eq 'CFPAT-testytest'
|
57
|
+
expect(token.scopes).to eq ['content_management_manage']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#destroy' do
|
63
|
+
it 'is not supported' do
|
64
|
+
vcr('personal_access_token/find') do
|
65
|
+
token = subject.find(pat_id)
|
66
|
+
expect { token.destroy }.to raise_error 'Not supported'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#revoke' do
|
72
|
+
it 'revokes a token' do
|
73
|
+
vcr('personal_access_token/revoke') do
|
74
|
+
token = subject.find('4us7wI40rNxTDzLuLl79dA')
|
75
|
+
expect(token.revoked_at).to be_falsey
|
76
|
+
|
77
|
+
token.revoke
|
78
|
+
|
79
|
+
expect(token.revoked_at).to be_truthy
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -5,80 +5,167 @@ require 'contentful/management/client'
|
|
5
5
|
module Contentful
|
6
6
|
module Management
|
7
7
|
describe Snapshot do
|
8
|
-
let(:token) { '<ACCESS_TOKEN>' }
|
8
|
+
let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
|
9
9
|
let(:space_id) { 'facgnwwgj5fe' }
|
10
10
|
let(:entry_id) { '5gQdVmPHKwIk2MumquYwOu' }
|
11
|
+
let(:content_type_id) { 'cat' }
|
11
12
|
let(:snapshot_id) { '6DglRQMMHWUnzi2F3RjFFo' }
|
13
|
+
let(:ct_snapshot_id) { '5bfy52PVk8HwBfXURLOsWJ' }
|
12
14
|
let!(:client) { Client.new(token) }
|
13
15
|
|
14
|
-
|
16
|
+
describe 'default behaviour is entry snapshots' do
|
17
|
+
subject { client.snapshots }
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
describe '.all' do
|
20
|
+
it 'class method also works' do
|
21
|
+
vcr('snapshot/all') { expect(Contentful::Management::Snapshot.all(client, space_id, entry_id)).to be_kind_of Contentful::Management::Array }
|
22
|
+
end
|
23
|
+
it 'returns a Contentful::Array' do
|
24
|
+
vcr('snapshot/all') { expect(subject.all(space_id, entry_id)).to be_kind_of Contentful::Management::Array }
|
25
|
+
end
|
26
|
+
it 'builds a Contentful::Management::Snapshot object' do
|
27
|
+
vcr('snapshot/all') { expect(subject.all(space_id, entry_id).first).to be_kind_of Contentful::Management::Snapshot }
|
28
|
+
end
|
25
29
|
end
|
26
|
-
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
describe '.find' do
|
32
|
+
it 'class method also works' do
|
33
|
+
vcr('snapshot/find') { expect(Contentful::Management::Snapshot.find(client, space_id, entry_id, snapshot_id)).to be_kind_of Contentful::Management::Snapshot }
|
34
|
+
end
|
35
|
+
it 'returns a Contentful::Management::Snapshot' do
|
36
|
+
vcr('snapshot/find') { expect(subject.find(space_id, entry_id, snapshot_id)).to be_kind_of Contentful::Management::Snapshot }
|
37
|
+
end
|
38
|
+
it 'returns snapshot for a given key' do
|
39
|
+
vcr('snapshot/find') do
|
40
|
+
snapshot = subject.find(space_id, entry_id, snapshot_id)
|
41
|
+
expect(snapshot.id).to eql snapshot_id
|
42
|
+
end
|
43
|
+
end
|
44
|
+
it 'returns an error when snapshot does not exist' do
|
45
|
+
vcr('snapshot/find_not_found') do
|
46
|
+
result = subject.find(space_id, entry_id, 'not_exist')
|
47
|
+
expect(result).to be_kind_of Contentful::Management::NotFound
|
48
|
+
end
|
49
|
+
end
|
34
50
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
expect
|
51
|
+
|
52
|
+
describe '.create' do
|
53
|
+
it 'is not supported' do
|
54
|
+
expect { subject.create }.to raise_error 'Not supported'
|
39
55
|
end
|
40
56
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
57
|
+
|
58
|
+
describe '#update' do
|
59
|
+
it 'is not supported' do
|
60
|
+
vcr('snapshot/find') do
|
61
|
+
snapshot = subject.find(space_id, entry_id, snapshot_id)
|
62
|
+
|
63
|
+
expect { snapshot.update }.to raise_error 'Not supported'
|
64
|
+
end
|
45
65
|
end
|
46
66
|
end
|
47
|
-
end
|
48
67
|
|
49
|
-
|
50
|
-
|
51
|
-
|
68
|
+
describe '#destroy' do
|
69
|
+
it 'is not supported' do
|
70
|
+
vcr('snapshot/find') do
|
71
|
+
snapshot = subject.find(space_id, entry_id, snapshot_id)
|
72
|
+
|
73
|
+
expect { snapshot.destroy }.to raise_error 'Not supported'
|
74
|
+
end
|
75
|
+
end
|
52
76
|
end
|
53
|
-
end
|
54
77
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
78
|
+
describe 'properties' do
|
79
|
+
it '.snapshot' do
|
80
|
+
vcr('snapshot/properties') do
|
81
|
+
snapshot = subject.find(space_id, entry_id, snapshot_id)
|
59
82
|
|
60
|
-
|
83
|
+
expect(snapshot.snapshot).to be_a Contentful::Management::Entry
|
84
|
+
expect(snapshot.snapshot.name['en-US']).to eq 'something else'
|
85
|
+
end
|
61
86
|
end
|
62
87
|
end
|
63
88
|
end
|
64
89
|
|
65
|
-
describe '
|
66
|
-
|
67
|
-
vcr('snapshot/find') do
|
68
|
-
snapshot = subject.find(space_id, entry_id, snapshot_id)
|
90
|
+
describe 'entry snapshots' do
|
91
|
+
subject { client.entry_snapshots }
|
69
92
|
|
70
|
-
|
93
|
+
describe '.all' do
|
94
|
+
it 'class method also works' do
|
95
|
+
vcr('snapshot/all') { expect(Contentful::Management::Snapshot.all(client, space_id, entry_id)).to be_kind_of Contentful::Management::Array }
|
96
|
+
end
|
97
|
+
it 'returns a Contentful::Array' do
|
98
|
+
vcr('snapshot/all') { expect(subject.all(space_id, entry_id)).to be_kind_of Contentful::Management::Array }
|
99
|
+
end
|
100
|
+
it 'builds a Contentful::Management::Snapshot object' do
|
101
|
+
vcr('snapshot/all') {
|
102
|
+
snapshot = subject.all(space_id, entry_id).first
|
103
|
+
expect(snapshot).to be_kind_of Contentful::Management::Snapshot
|
104
|
+
expect(snapshot.snapshot).to be_kind_of Contentful::Management::DynamicEntry
|
105
|
+
}
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '.find' do
|
110
|
+
it 'class method also works' do
|
111
|
+
vcr('snapshot/find') { expect(Contentful::Management::Snapshot.find(client, space_id, entry_id, snapshot_id)).to be_kind_of Contentful::Management::Snapshot }
|
112
|
+
end
|
113
|
+
it 'returns a Contentful::Management::Snapshot' do
|
114
|
+
vcr('snapshot/find') { expect(subject.find(space_id, entry_id, snapshot_id)).to be_kind_of Contentful::Management::Snapshot }
|
115
|
+
end
|
116
|
+
it 'returns snapshot for a given key' do
|
117
|
+
vcr('snapshot/find') do
|
118
|
+
snapshot = subject.find(space_id, entry_id, snapshot_id)
|
119
|
+
expect(snapshot.id).to eql snapshot_id
|
120
|
+
end
|
121
|
+
end
|
122
|
+
it 'returns an error when snapshot does not exist' do
|
123
|
+
vcr('snapshot/find_not_found') do
|
124
|
+
result = subject.find(space_id, entry_id, 'not_exist')
|
125
|
+
expect(result).to be_kind_of Contentful::Management::NotFound
|
126
|
+
end
|
71
127
|
end
|
72
128
|
end
|
73
129
|
end
|
74
130
|
|
75
|
-
describe '
|
76
|
-
|
77
|
-
vcr('snapshot/properties') do
|
78
|
-
snapshot = subject.find(space_id, entry_id, snapshot_id)
|
131
|
+
describe 'describe content type snapshots' do
|
132
|
+
subject { client.content_type_snapshots }
|
79
133
|
|
80
|
-
|
81
|
-
|
134
|
+
describe '.all' do
|
135
|
+
it 'class method also works' do
|
136
|
+
vcr('snapshot/ct_all') { expect(Contentful::Management::Snapshot.all(client, space_id, content_type_id, 'content_types')).to be_kind_of Contentful::Management::Array }
|
137
|
+
end
|
138
|
+
it 'returns a Contentful::Array' do
|
139
|
+
vcr('snapshot/ct_all') { expect(subject.all(space_id, content_type_id)).to be_kind_of Contentful::Management::Array }
|
140
|
+
end
|
141
|
+
it 'builds a Contentful::Management::Snapshot object' do
|
142
|
+
vcr('snapshot/ct_all') {
|
143
|
+
snapshot = subject.all(space_id, content_type_id).first
|
144
|
+
expect(snapshot).to be_kind_of Contentful::Management::Snapshot
|
145
|
+
expect(snapshot.snapshot).to be_kind_of Contentful::Management::ContentType
|
146
|
+
}
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe '.find' do
|
151
|
+
it 'class method also works' do
|
152
|
+
vcr('snapshot/ct_find') { expect(Contentful::Management::Snapshot.find(client, space_id, content_type_id, ct_snapshot_id, 'content_types')).to be_kind_of Contentful::Management::Snapshot }
|
153
|
+
end
|
154
|
+
it 'returns a Contentful::Management::Snapshot' do
|
155
|
+
vcr('snapshot/ct_find') { expect(subject.find(space_id, content_type_id, ct_snapshot_id)).to be_kind_of Contentful::Management::Snapshot }
|
156
|
+
end
|
157
|
+
it 'returns snapshot for a given key' do
|
158
|
+
vcr('snapshot/ct_find') do
|
159
|
+
snapshot = subject.find(space_id, content_type_id, ct_snapshot_id)
|
160
|
+
expect(snapshot.id).to eql ct_snapshot_id
|
161
|
+
expect(snapshot.snapshot.id).to eq content_type_id
|
162
|
+
end
|
163
|
+
end
|
164
|
+
it 'returns an error when snapshot does not exist' do
|
165
|
+
vcr('snapshot/ct_find_not_found') do
|
166
|
+
result = subject.find(space_id, content_type_id, 'not_exist')
|
167
|
+
expect(result).to be_kind_of Contentful::Management::NotFound
|
168
|
+
end
|
82
169
|
end
|
83
170
|
end
|
84
171
|
end
|