contentful-management 2.2.2 → 2.3.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/CHANGELOG.md +13 -0
- data/lib/contentful/management/asset.rb +7 -8
- data/lib/contentful/management/client_space_membership_methods_factory.rb +8 -0
- data/lib/contentful/management/environment.rb +5 -0
- data/lib/contentful/management/space_membership.rb +23 -0
- data/lib/contentful/management/ui_extension.rb +12 -0
- data/lib/contentful/management/user.rb +1 -1
- data/lib/contentful/management/version.rb +1 -1
- data/lib/contentful/management/webhook.rb +4 -1
- data/spec/fixtures/vcr_cassettes/environment/find_3.yml +139 -0
- data/spec/fixtures/vcr_cassettes/space_memberships/find_2.yml +336 -0
- data/spec/fixtures/vcr_cassettes/ui_extension/create_parameters.yml +185 -0
- data/spec/fixtures/vcr_cassettes/user/find.yml +1 -1
- data/spec/fixtures/vcr_cassettes/webhook/filters.yml +152 -0
- data/spec/fixtures/vcr_cassettes/webhook/transformation.yml +152 -0
- data/spec/lib/contentful/management/environment_spec.rb +12 -0
- data/spec/lib/contentful/management/space_membership_spec.rb +9 -0
- data/spec/lib/contentful/management/ui_extension_spec.rb +76 -0
- data/spec/lib/contentful/management/webhook_spec.rb +47 -1
- metadata +12 -2
@@ -98,4 +98,16 @@ describe Contentful::Management::Environment do
|
|
98
98
|
}
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
describe '#reload' do
|
103
|
+
it 'can reload' do
|
104
|
+
vcr('environment/find') {
|
105
|
+
environment = subject.find(testing)
|
106
|
+
|
107
|
+
vcr('environment/find_3') {
|
108
|
+
expect { environment.reload }.not_to raise_exception
|
109
|
+
}
|
110
|
+
}
|
111
|
+
end
|
112
|
+
end
|
101
113
|
end
|
@@ -128,6 +128,15 @@ module Contentful
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
describe '.find' do
|
132
|
+
it 'finds a Contentful::Management::SpaceMembership' do
|
133
|
+
vcr('space_memberships/find_2') {
|
134
|
+
membership = subject.find(subject.all.first.id)
|
135
|
+
expect(membership).to be_a Contentful::Management::SpaceMembership
|
136
|
+
}
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
131
140
|
describe '#destroy' do
|
132
141
|
it 'deletes the membership' do
|
133
142
|
vcr('space_memberships/delete') {
|
@@ -256,6 +256,82 @@ module Contentful
|
|
256
256
|
expect(extension.id).to be_truthy
|
257
257
|
}
|
258
258
|
end
|
259
|
+
|
260
|
+
it 'can customize ui extension parameters' do
|
261
|
+
vcr('ui_extension/create_parameters') {
|
262
|
+
extension = client.ui_extensions(playground_space_id, 'master').create(extension: {
|
263
|
+
'name' => 'test extension with parameters',
|
264
|
+
'fieldTypes' => [{"type"=>"Symbol"}, {"type"=>"Text"}],
|
265
|
+
'srcdoc' => "<!doctype html><html lang='en'><head><meta charset='UTF-8'/><title>Sample Editor Extension</title><link rel='stylesheet' href='https://contentful.github.io/ui-extensions-sdk/cf-extension.css'><script src='https://contentful.github.io/ui-extensions-sdk/cf-extension-api.js'></script></head><body><div id='content'></div><script>window.contentfulExtension.init(function (extension) {window.alert(extension);var value = extension.field.getValue();extension.field.setValue('Hello world!');extension.field.onValueChanged(function(value) {if (value !== currentValue) {extension.field.setValue('Hello world!');}});});</script></body></html>",
|
266
|
+
'sidebar' => false,
|
267
|
+
'parameters' => {
|
268
|
+
'installation' => [
|
269
|
+
{
|
270
|
+
'id' => 'devMode',
|
271
|
+
'type' => 'Boolean',
|
272
|
+
'name' => 'Run in development mode'
|
273
|
+
},
|
274
|
+
{
|
275
|
+
'id' => 'retries',
|
276
|
+
'type' => 'Number',
|
277
|
+
'name' => 'Number of retries for API calls',
|
278
|
+
'required' => true,
|
279
|
+
'default' => 3
|
280
|
+
}
|
281
|
+
],
|
282
|
+
'instance' => [
|
283
|
+
{
|
284
|
+
'id' => 'helpText',
|
285
|
+
'type' => 'Symbol',
|
286
|
+
'name' => 'Help text',
|
287
|
+
'description' => 'Help text for a user to help them understand the editor'
|
288
|
+
},
|
289
|
+
{
|
290
|
+
'id' => 'theme',
|
291
|
+
'type' => 'Enum',
|
292
|
+
'name' => 'Theme',
|
293
|
+
'options' => [{'light' => 'Solarized light'}, {'dark' => 'Solarized dark'}],
|
294
|
+
'default' => 'light',
|
295
|
+
'required' => true
|
296
|
+
}
|
297
|
+
]
|
298
|
+
}
|
299
|
+
})
|
300
|
+
|
301
|
+
expect(extension.parameters).to eq(
|
302
|
+
'installation' => [
|
303
|
+
{
|
304
|
+
'id' => 'devMode',
|
305
|
+
'type' => 'Boolean',
|
306
|
+
'name' => 'Run in development mode'
|
307
|
+
},
|
308
|
+
{
|
309
|
+
'id' => 'retries',
|
310
|
+
'type' => 'Number',
|
311
|
+
'name' => 'Number of retries for API calls',
|
312
|
+
'required' => true,
|
313
|
+
'default' => 3
|
314
|
+
}
|
315
|
+
],
|
316
|
+
'instance' => [
|
317
|
+
{
|
318
|
+
'id' => 'helpText',
|
319
|
+
'type' => 'Symbol',
|
320
|
+
'name' => 'Help text',
|
321
|
+
'description' => 'Help text for a user to help them understand the editor'
|
322
|
+
},
|
323
|
+
{
|
324
|
+
'id' => 'theme',
|
325
|
+
'type' => 'Enum',
|
326
|
+
'name' => 'Theme',
|
327
|
+
'options' => [{'light' => 'Solarized light'}, {'dark' => 'Solarized dark'}],
|
328
|
+
'default' => 'light',
|
329
|
+
'required' => true
|
330
|
+
}
|
331
|
+
]
|
332
|
+
)
|
333
|
+
}
|
334
|
+
end
|
259
335
|
end
|
260
336
|
|
261
337
|
describe '#destroy' do
|
@@ -5,7 +5,7 @@ require 'contentful/management/client'
|
|
5
5
|
module Contentful
|
6
6
|
module Management
|
7
7
|
describe Webhook do
|
8
|
-
let(:token) { '<ACCESS_TOKEN>' }
|
8
|
+
let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
|
9
9
|
let(:space_id) { 'bfsvtul0c41g' }
|
10
10
|
let(:webhook_id) { '0rK8ZNEOWLgYnO5gaah2pp' }
|
11
11
|
let!(:client) { Client.new(token) }
|
@@ -98,6 +98,52 @@ module Contentful
|
|
98
98
|
expect(webhook.topics).to eq ['Entry.save', 'Entry.publish', 'ContentType.*']
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
it 'can create webhooks with specific filters' do
|
103
|
+
vcr('webhook/filters') do
|
104
|
+
webhook = described_class.create(
|
105
|
+
client,
|
106
|
+
'facgnwwgj5fe',
|
107
|
+
name: 'test_ruby_filters',
|
108
|
+
url: 'https://www.example.com',
|
109
|
+
topics: ['Entry.*'],
|
110
|
+
filters: [{
|
111
|
+
equals: [{ doc: "sys.environment.sys.id" }, "some-env-id"]
|
112
|
+
}]
|
113
|
+
)
|
114
|
+
|
115
|
+
expect(webhook.filters[0]).to eq('equals' => [{ 'doc' => "sys.environment.sys.id"}, "some-env-id"])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'can create webhooks with specific transformations' do
|
120
|
+
vcr('webhook/transformation') do
|
121
|
+
webhook = described_class.create(
|
122
|
+
client,
|
123
|
+
'facgnwwgj5fe',
|
124
|
+
name: 'test_ruby_filters',
|
125
|
+
url: 'https://www.example.com',
|
126
|
+
topics: ['Entry.*'],
|
127
|
+
transformation: {
|
128
|
+
method: 'POST',
|
129
|
+
contentType: 'application/vnd.contentful.management.v1+json; charset=utf-8',
|
130
|
+
body: {
|
131
|
+
entryId: "{ /payload/sys/id }",
|
132
|
+
fields: "{ /payload/fields }"
|
133
|
+
}
|
134
|
+
}
|
135
|
+
)
|
136
|
+
|
137
|
+
expect(webhook.transformation).to eq(
|
138
|
+
'method' => 'POST',
|
139
|
+
'contentType' => 'application/vnd.contentful.management.v1+json; charset=utf-8',
|
140
|
+
'body' => {
|
141
|
+
'entryId' => "{ /payload/sys/id }",
|
142
|
+
'fields' => "{ /payload/fields }"
|
143
|
+
}
|
144
|
+
)
|
145
|
+
end
|
146
|
+
end
|
101
147
|
end
|
102
148
|
|
103
149
|
describe '#update' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Protas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-08-
|
13
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -600,6 +600,7 @@ files:
|
|
600
600
|
- spec/fixtures/vcr_cassettes/environment/entry_proxy.yml
|
601
601
|
- spec/fixtures/vcr_cassettes/environment/find.yml
|
602
602
|
- spec/fixtures/vcr_cassettes/environment/find_2.yml
|
603
|
+
- spec/fixtures/vcr_cassettes/environment/find_3.yml
|
603
604
|
- spec/fixtures/vcr_cassettes/environment/not_found.yml
|
604
605
|
- spec/fixtures/vcr_cassettes/get_request.yml
|
605
606
|
- spec/fixtures/vcr_cassettes/locale/all_for_space.yml
|
@@ -689,8 +690,10 @@ files:
|
|
689
690
|
- spec/fixtures/vcr_cassettes/space_memberships/create.yml
|
690
691
|
- spec/fixtures/vcr_cassettes/space_memberships/delete.yml
|
691
692
|
- spec/fixtures/vcr_cassettes/space_memberships/find.yml
|
693
|
+
- spec/fixtures/vcr_cassettes/space_memberships/find_2.yml
|
692
694
|
- spec/fixtures/vcr_cassettes/ui_extension/all.yml
|
693
695
|
- spec/fixtures/vcr_cassettes/ui_extension/create.yml
|
696
|
+
- spec/fixtures/vcr_cassettes/ui_extension/create_parameters.yml
|
694
697
|
- spec/fixtures/vcr_cassettes/ui_extension/delete.yml
|
695
698
|
- spec/fixtures/vcr_cassettes/ui_extension/find.yml
|
696
699
|
- spec/fixtures/vcr_cassettes/upload/associate_with_asset.yml
|
@@ -705,9 +708,11 @@ files:
|
|
705
708
|
- spec/fixtures/vcr_cassettes/webhook/create_with_name_and_headers.yml
|
706
709
|
- spec/fixtures/vcr_cassettes/webhook/create_with_taken_url.yml
|
707
710
|
- spec/fixtures/vcr_cassettes/webhook/destroy.yml
|
711
|
+
- spec/fixtures/vcr_cassettes/webhook/filters.yml
|
708
712
|
- spec/fixtures/vcr_cassettes/webhook/find.yml
|
709
713
|
- spec/fixtures/vcr_cassettes/webhook/find_not_found.yml
|
710
714
|
- spec/fixtures/vcr_cassettes/webhook/topics.yml
|
715
|
+
- spec/fixtures/vcr_cassettes/webhook/transformation.yml
|
711
716
|
- spec/fixtures/vcr_cassettes/webhook/update.yml
|
712
717
|
- spec/fixtures/vcr_cassettes/webhook_call/all.yml
|
713
718
|
- spec/fixtures/vcr_cassettes/webhook_call/find.yml
|
@@ -981,6 +986,7 @@ test_files:
|
|
981
986
|
- spec/fixtures/vcr_cassettes/environment/entry_proxy.yml
|
982
987
|
- spec/fixtures/vcr_cassettes/environment/find.yml
|
983
988
|
- spec/fixtures/vcr_cassettes/environment/find_2.yml
|
989
|
+
- spec/fixtures/vcr_cassettes/environment/find_3.yml
|
984
990
|
- spec/fixtures/vcr_cassettes/environment/not_found.yml
|
985
991
|
- spec/fixtures/vcr_cassettes/get_request.yml
|
986
992
|
- spec/fixtures/vcr_cassettes/locale/all_for_space.yml
|
@@ -1070,8 +1076,10 @@ test_files:
|
|
1070
1076
|
- spec/fixtures/vcr_cassettes/space_memberships/create.yml
|
1071
1077
|
- spec/fixtures/vcr_cassettes/space_memberships/delete.yml
|
1072
1078
|
- spec/fixtures/vcr_cassettes/space_memberships/find.yml
|
1079
|
+
- spec/fixtures/vcr_cassettes/space_memberships/find_2.yml
|
1073
1080
|
- spec/fixtures/vcr_cassettes/ui_extension/all.yml
|
1074
1081
|
- spec/fixtures/vcr_cassettes/ui_extension/create.yml
|
1082
|
+
- spec/fixtures/vcr_cassettes/ui_extension/create_parameters.yml
|
1075
1083
|
- spec/fixtures/vcr_cassettes/ui_extension/delete.yml
|
1076
1084
|
- spec/fixtures/vcr_cassettes/ui_extension/find.yml
|
1077
1085
|
- spec/fixtures/vcr_cassettes/upload/associate_with_asset.yml
|
@@ -1086,9 +1094,11 @@ test_files:
|
|
1086
1094
|
- spec/fixtures/vcr_cassettes/webhook/create_with_name_and_headers.yml
|
1087
1095
|
- spec/fixtures/vcr_cassettes/webhook/create_with_taken_url.yml
|
1088
1096
|
- spec/fixtures/vcr_cassettes/webhook/destroy.yml
|
1097
|
+
- spec/fixtures/vcr_cassettes/webhook/filters.yml
|
1089
1098
|
- spec/fixtures/vcr_cassettes/webhook/find.yml
|
1090
1099
|
- spec/fixtures/vcr_cassettes/webhook/find_not_found.yml
|
1091
1100
|
- spec/fixtures/vcr_cassettes/webhook/topics.yml
|
1101
|
+
- spec/fixtures/vcr_cassettes/webhook/transformation.yml
|
1092
1102
|
- spec/fixtures/vcr_cassettes/webhook/update.yml
|
1093
1103
|
- spec/fixtures/vcr_cassettes/webhook_call/all.yml
|
1094
1104
|
- spec/fixtures/vcr_cassettes/webhook_call/find.yml
|