contentful-management 1.8.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +15 -0
  4. data/README.md +209 -41
  5. data/contentful-management.gemspec +1 -1
  6. data/lib/contentful/management/asset.rb +1 -1
  7. data/lib/contentful/management/client.rb +155 -31
  8. data/lib/contentful/management/client_organization_methods_factory.rb +23 -0
  9. data/lib/contentful/management/client_personal_access_tokens_methods_factory.rb +27 -0
  10. data/lib/contentful/management/client_snapshot_methods_factory.rb +16 -6
  11. data/lib/contentful/management/client_space_membership_methods_factory.rb +15 -0
  12. data/lib/contentful/management/client_ui_extension_methods_factory.rb +15 -0
  13. data/lib/contentful/management/client_user_methods_factory.rb +27 -0
  14. data/lib/contentful/management/client_webhook_call_methods_factory.rb +30 -0
  15. data/lib/contentful/management/client_webhook_health_methods_factory.rb +27 -0
  16. data/lib/contentful/management/content_type.rb +10 -0
  17. data/lib/contentful/management/content_type_snapshot_methods_factory.rb +35 -0
  18. data/lib/contentful/management/editor_interface.rb +1 -1
  19. data/lib/contentful/management/organization.rb +20 -0
  20. data/lib/contentful/management/personal_access_token.rb +45 -0
  21. data/lib/contentful/management/request.rb +0 -1
  22. data/lib/contentful/management/resource.rb +4 -2
  23. data/lib/contentful/management/resource_builder.rb +15 -0
  24. data/lib/contentful/management/snapshot.rb +31 -20
  25. data/lib/contentful/management/space.rb +32 -10
  26. data/lib/contentful/management/space_membership.rb +43 -0
  27. data/lib/contentful/management/space_space_membership_methods_factory.rb +15 -0
  28. data/lib/contentful/management/space_ui_extension_methods_factory.rb +15 -0
  29. data/lib/contentful/management/ui_extension.rb +106 -0
  30. data/lib/contentful/management/user.rb +28 -0
  31. data/lib/contentful/management/version.rb +1 -1
  32. data/lib/contentful/management/webhook.rb +20 -0
  33. data/lib/contentful/management/webhook_call.rb +77 -0
  34. data/lib/contentful/management/webhook_health.rb +79 -0
  35. data/lib/contentful/management/webhook_webhook_call_methods_factory.rb +30 -0
  36. data/lib/contentful/management/webhook_webhook_health_methods_factory.rb +28 -0
  37. data/spec/fixtures/vcr_cassettes/get_request.yml +34 -17
  38. data/spec/fixtures/vcr_cassettes/organization/all.yml +100 -0
  39. data/spec/fixtures/vcr_cassettes/personal_access_token/all.yml +101 -0
  40. data/spec/fixtures/vcr_cassettes/personal_access_token/create.yml +94 -0
  41. data/spec/fixtures/vcr_cassettes/personal_access_token/find.yml +91 -0
  42. data/spec/fixtures/vcr_cassettes/personal_access_token/find_not_found.yml +88 -0
  43. data/spec/fixtures/vcr_cassettes/personal_access_token/revoke.yml +179 -0
  44. data/spec/fixtures/vcr_cassettes/snapshot/ct_all.yml +207 -0
  45. data/spec/fixtures/vcr_cassettes/snapshot/ct_find.yml +198 -0
  46. data/spec/fixtures/vcr_cassettes/snapshot/ct_find_not_found.yml +94 -0
  47. data/spec/fixtures/vcr_cassettes/space/all_disabled_cache.yml +428 -0
  48. data/spec/fixtures/vcr_cassettes/space/disabled_cache.yml +120 -0
  49. data/spec/fixtures/vcr_cassettes/space_memberships/all.yml +190 -0
  50. data/spec/fixtures/vcr_cassettes/space_memberships/create.yml +143 -0
  51. data/spec/fixtures/vcr_cassettes/space_memberships/delete.yml +322 -0
  52. data/spec/fixtures/vcr_cassettes/space_memberships/find.yml +141 -0
  53. data/spec/fixtures/vcr_cassettes/ui_extension/all.yml +1020 -0
  54. data/spec/fixtures/vcr_cassettes/ui_extension/create.yml +133 -0
  55. data/spec/fixtures/vcr_cassettes/ui_extension/delete.yml +291 -0
  56. data/spec/fixtures/vcr_cassettes/ui_extension/find.yml +126 -0
  57. data/spec/fixtures/vcr_cassettes/user/find.yml +96 -0
  58. data/spec/fixtures/vcr_cassettes/webhook_call/all.yml +151 -0
  59. data/spec/fixtures/vcr_cassettes/webhook_call/find.yml +88 -0
  60. data/spec/fixtures/vcr_cassettes/webhook_call/find_not_found.yml +93 -0
  61. data/spec/fixtures/vcr_cassettes/webhook_health/find.yml +111 -0
  62. data/spec/lib/contentful/management/client_spec.rb +25 -26
  63. data/spec/lib/contentful/management/entry_spec.rb +48 -48
  64. data/spec/lib/contentful/management/organization_spec.rb +33 -0
  65. data/spec/lib/contentful/management/personal_access_token_spec.rb +85 -0
  66. data/spec/lib/contentful/management/snapshot_spec.rb +134 -47
  67. data/spec/lib/contentful/management/space_membership_spec.rb +147 -0
  68. data/spec/lib/contentful/management/space_spec.rb +35 -1
  69. data/spec/lib/contentful/management/ui_extension_spec.rb +276 -0
  70. data/spec/lib/contentful/management/user_spec.rb +52 -0
  71. data/spec/lib/contentful/management/webhook_calls_spec.rb +69 -0
  72. data/spec/lib/contentful/management/webhook_health_spec.rb +51 -0
  73. metadata +88 -8
  74. data/lib/contentful/management/http_client.rb +0 -89
@@ -0,0 +1,147 @@
1
+ require 'spec_helper'
2
+ require 'contentful/management/space'
3
+ require 'contentful/management/client'
4
+
5
+ module Contentful
6
+ module Management
7
+ describe SpaceMembership do
8
+ let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
9
+ let(:space_id) { 'facgnwwgj5fe' }
10
+ let(:membership_id) { '6RdRdobdQzh8zKe1Hogiz4' }
11
+ let(:client) { Client.new(token, raise_errors: true) }
12
+
13
+ subject { client.space_memberships }
14
+
15
+ describe 'class methods' do
16
+ describe '::create_attributes' do
17
+ it 'requires admin, roles and email keys to be present' do
18
+ expect { described_class.create_attributes(nil, {}) }.to raise_error KeyError
19
+ expect { described_class.create_attributes(nil, admin: true) }.to raise_error KeyError
20
+ expect { described_class.create_attributes(nil, admin: true, roles: []) }.to raise_error KeyError
21
+ expect { described_class.create_attributes(nil, roles: []) }.to raise_error KeyError
22
+ expect { described_class.create_attributes(nil, roles: [], email: 'foo@bar.com') }.to raise_error KeyError
23
+ expect { described_class.create_attributes(nil, email: 'foo@bar.com') }.to raise_error KeyError
24
+ expect { described_class.create_attributes(nil, admin: true, roles: [], email: 'foo@bar.com') }.not_to raise_error
25
+ end
26
+ it 'accepts also strings as keys' do
27
+ # Symbols were tested on the previous spec - testing strings here
28
+ expect { described_class.create_attributes(nil, 'admin' => true, 'roles' => [], 'email' => 'foo@bar.com') }.not_to raise_error
29
+ end
30
+ end
31
+
32
+ describe '::clean_roles' do
33
+ let(:json_role) { {
34
+ "sys": {
35
+ "id": "foo",
36
+ "type": "Link",
37
+ "linkType": "Role"
38
+ }
39
+ } }
40
+
41
+ let(:link_role) { Link.new(json_role, nil, client) }
42
+
43
+ it 'returns the json representation of the roles wether they are a Link or a Hash' do
44
+ expect(described_class.clean_roles([json_role, link_role])).to eq [json_role, json_role]
45
+ end
46
+ end
47
+ end
48
+
49
+ describe 'instance methods' do
50
+ let(:membership) { described_class.new({
51
+ "admin" => true,
52
+ "roles" => [{
53
+ "sys" => {
54
+ "id" => "foo",
55
+ "type" => "Link",
56
+ "linkType" => "Role"
57
+ }
58
+ }]
59
+ }) }
60
+
61
+ describe '#roles' do
62
+ it 'returns an array Link objects' do
63
+ expect(membership.roles.first).to be_a Link
64
+ expect(membership.roles.first.id).to eq 'foo'
65
+ end
66
+ end
67
+ end
68
+
69
+ describe '.all' do
70
+ it 'returns a Contentful::Array' do
71
+ vcr('space_memberships/all') { expect(subject.all(space_id)).to be_kind_of Contentful::Management::Array }
72
+ end
73
+
74
+ it 'builds a Contentful::Management::SpaceMembership' do
75
+ vcr('space_memberships/all') {
76
+ memberships = subject.all(space_id)
77
+
78
+ admin_membership, normal_membership = memberships.items
79
+
80
+ expect(admin_membership).to be_a Contentful::Management::SpaceMembership
81
+ expect(admin_membership.admin).to eq true
82
+ expect(admin_membership.roles).to eq []
83
+
84
+ expect(normal_membership).to be_a Contentful::Management::SpaceMembership
85
+ expect(normal_membership.admin).to eq false
86
+ expect(normal_membership.roles.first).to be_a Link
87
+ }
88
+ end
89
+
90
+ it 'class method also works' do
91
+ vcr('space_memberships/all') { expect(Contentful::Management::SpaceMembership.all(client, space_id)).to be_kind_of Contentful::Management::Array }
92
+ end
93
+ end
94
+
95
+ describe '.find' do
96
+ it 'returns a Contentful::Management::SpaceMembership' do
97
+ vcr('space_memberships/find') {
98
+ membership = subject.find(space_id, membership_id)
99
+
100
+ expect(membership).to be_a Contentful::Management::SpaceMembership
101
+ expect(membership.admin).to eq false
102
+ expect(membership.roles.first).to be_a Link
103
+ }
104
+ end
105
+ end
106
+
107
+ describe '.create' do
108
+ it 'creates a Contentful::Management::SpaceMembership' do
109
+ vcr('space_memberships/create') {
110
+ membership = subject.create(
111
+ space_id,
112
+ admin: false,
113
+ roles: [
114
+ {
115
+ "sys" => {
116
+ "type" => "Link",
117
+ "linkType" => "Role",
118
+ "id" => "1Nq88dKTNXNaxkbrRpEEw6"
119
+ }
120
+ }
121
+ ],
122
+ email: 'david.litvak+test_rcma@contentful.com'
123
+ )
124
+
125
+ expect(membership).to be_a Contentful::Management::SpaceMembership
126
+ expect(membership.admin).to eq false
127
+ expect(membership.roles.first).to be_a Link
128
+ }
129
+ end
130
+ end
131
+
132
+ describe '#destroy' do
133
+ it 'deletes the membership' do
134
+ vcr('space_memberships/delete') {
135
+ membership = subject.find(space_id, '7pcydolqtgMaSLwmXMvGqW')
136
+
137
+ expect(membership.id).to be_truthy
138
+
139
+ membership.destroy
140
+
141
+ expect { subject.find(space_id, '7pcydolqtgMaSLwmXMvGqW') }.to raise_error Contentful::Management::NotFound
142
+ }
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
@@ -5,7 +5,7 @@ require 'contentful/management/client'
5
5
  module Contentful
6
6
  module Management
7
7
  describe Space do
8
- let(:token) { '<ACCESS_TOKEN>' }
8
+ let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
9
9
  let(:space_id) { 'yr5m0jky5hsh' }
10
10
 
11
11
  let!(:client) { Client.new(token) }
@@ -22,6 +22,22 @@ module Contentful
22
22
  it 'builds a Contentful::Management::Space object' do
23
23
  vcr('space/all') { expect(subject.all.first).to be_kind_of Contentful::Management::Space }
24
24
  end
25
+ describe 'content type caching' do
26
+ it 'fetches all content types when finding a space' do
27
+ vcr('space/all') do
28
+ space = subject.all
29
+ expect(client.dynamic_entry_cache).not_to be_empty
30
+ end
31
+ end
32
+ it 'doesnt fetch content types when explicitly disabled' do
33
+ vcr('space/all_disabled_cache') do
34
+ client = Client.new(token, disable_content_type_caching: true)
35
+ subject = client.spaces
36
+ space = subject.all
37
+ expect(client.dynamic_entry_cache).to be_empty
38
+ end
39
+ end
40
+ end
25
41
  end
26
42
 
27
43
  describe '.find' do
@@ -50,6 +66,24 @@ module Contentful
50
66
  expect(space.default_locale).to eql 'en-US'
51
67
  end
52
68
  end
69
+ describe 'content type caching' do
70
+ it 'fetches all content types when finding a space' do
71
+ vcr('space/find') do
72
+ space = subject.find(space_id)
73
+ expect(client.dynamic_entry_cache).not_to be_empty
74
+ expect(client.dynamic_entry_cache.key?('5DSpuKrl04eMAGQoQckeIq'.to_sym)).to be_truthy
75
+ end
76
+ end
77
+ it 'does not fetch content types when explicitly disabled' do
78
+ vcr('space/disabled_cache') do
79
+ client = Client.new(token, disable_content_type_caching: true)
80
+ subject = client.spaces
81
+
82
+ space = subject.find('facgnwwgj5fe')
83
+ expect(client.dynamic_entry_cache).to be_empty
84
+ end
85
+ end
86
+ end
53
87
  end
54
88
 
55
89
  describe '#destroy' do
@@ -0,0 +1,276 @@
1
+ require 'spec_helper'
2
+ require 'contentful/management/space'
3
+ require 'contentful/management/client'
4
+
5
+ module Contentful
6
+ module Management
7
+ describe UIExtension do
8
+ let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
9
+ let(:space_id) { 'arqlnkt58eul' }
10
+ let(:playground_space_id) { 'facgnwwgj5fe' }
11
+ let(:extension_id) { '2ZJduY1pKEma6G8Y2ImqYU' }
12
+ let(:client) { Client.new(token, raise_errors: true) }
13
+
14
+ subject { client.ui_extensions }
15
+
16
+ describe 'class methods' do
17
+ describe '::valid_extension' do
18
+ it 'false when name is missing' do
19
+ extension = {}
20
+
21
+ expect(described_class.valid_extension(extension)).to be_falsey
22
+ end
23
+
24
+ it 'false when fieldTypes is missing' do
25
+ extension = {
26
+ 'name' => 'foobar'
27
+ }
28
+
29
+ expect(described_class.valid_extension(extension)).to be_falsey
30
+ end
31
+
32
+ it 'false when fieldTypes is present but not an array' do
33
+ extension = {
34
+ 'name' => 'foobar',
35
+ 'fieldTypes' => 'baz'
36
+ }
37
+
38
+ expect(described_class.valid_extension(extension)).to be_falsey
39
+ end
40
+
41
+ it 'false when both src and srcdoc missing' do
42
+ extension = {
43
+ 'name' => 'foobar',
44
+ 'fieldTypes' => ['Symbol']
45
+ }
46
+
47
+ expect(described_class.valid_extension(extension)).to be_falsey
48
+ end
49
+
50
+ it 'true when all of the above are passed' do
51
+ extension = {
52
+ 'name' => 'foobar',
53
+ 'fieldTypes' => ['Symbol'],
54
+ 'src' => 'foo'
55
+ }
56
+
57
+ expect(described_class.valid_extension(extension)).to be_truthy
58
+
59
+ extension = {
60
+ 'name' => 'foobar',
61
+ 'fieldTypes' => ['Symbol'],
62
+ 'srcdoc' => 'foo'
63
+ }
64
+
65
+ expect(described_class.valid_extension(extension)).to be_truthy
66
+ end
67
+
68
+ it 'false if sidebar is present but not boolean' do
69
+ extension = {
70
+ 'name' => 'foobar',
71
+ 'fieldTypes' => ['Symbol'],
72
+ 'srcdoc' => 'foo',
73
+ 'sidebar' => true
74
+ }
75
+
76
+ expect(described_class.valid_extension(extension)).to be_truthy
77
+
78
+ extension = {
79
+ 'name' => 'foobar',
80
+ 'fieldTypes' => ['Symbol'],
81
+ 'srcdoc' => 'foo',
82
+ 'sidebar' => false
83
+ }
84
+
85
+ expect(described_class.valid_extension(extension)).to be_truthy
86
+
87
+ extension = {
88
+ 'name' => 'foobar',
89
+ 'fieldTypes' => ['Symbol'],
90
+ 'srcdoc' => 'foo',
91
+ 'sidebar' => 'foobar'
92
+ }
93
+
94
+ expect(described_class.valid_extension(extension)).to be_falsey
95
+ end
96
+ end
97
+
98
+ describe '::create_attributes' do
99
+ it 'raises an error if extension sent is not valid' do
100
+ invalid_extension = {
101
+ extension: {
102
+ 'name' => 'foobar'
103
+ }
104
+ }
105
+
106
+ expect do
107
+ described_class.create_attributes(nil, invalid_extension)
108
+ end.to raise_error 'Invalid UI Extension attributes'
109
+ end
110
+
111
+ it 'does nothing otherwise' do
112
+ extension = {
113
+ 'extension' => {
114
+ 'name' => 'foobar',
115
+ 'fieldTypes' => ['Symbol'],
116
+ 'srcdoc' => 'foo',
117
+ 'sidebar' => false
118
+ }
119
+ }
120
+
121
+ expect(described_class.create_attributes(nil, extension)).to eq extension
122
+ end
123
+ end
124
+ end
125
+
126
+ describe 'instance methods' do
127
+ let(:extension) {
128
+ described_class.new(
129
+ 'extension' => {
130
+ 'name' => 'foobar',
131
+ 'fieldTypes' => ['Symbol'],
132
+ 'srcdoc' => 'foo',
133
+ 'sidebar' => false
134
+ }
135
+ )
136
+ }
137
+
138
+ let(:src_extension) {
139
+ described_class.new(
140
+ 'extension' => {
141
+ 'name' => 'foobar',
142
+ 'fieldTypes' => ['Symbol'],
143
+ 'src' => 'http://foo.com',
144
+ 'sidebar' => false
145
+ }
146
+ )
147
+ }
148
+
149
+ it '#name' do
150
+ expect(extension.name).to eq 'foobar'
151
+ extension.name = 'baz'
152
+
153
+ expect(extension.name).to eq 'baz'
154
+ expect(extension.extension['name']).to eq 'baz'
155
+ end
156
+
157
+ it '#field_types' do
158
+ expect(extension.field_types).to eq ['Symbol']
159
+
160
+ extension.field_types = ['Symbol', 'Text']
161
+
162
+ expect(extension.field_types).to eq ['Symbol', 'Text']
163
+ expect(extension.extension['fieldTypes']).to eq ['Symbol', 'Text']
164
+ end
165
+
166
+ describe '#source' do
167
+ it 'will get first available source' do
168
+ expect(extension.source).to eq 'foo'
169
+ expect(src_extension.source).to eq 'http://foo.com'
170
+ end
171
+
172
+ it 'if source is a url will set it to src' do
173
+ expect(extension.extension['srcdoc']).to eq 'foo'
174
+
175
+ extension.source = 'http://example.com'
176
+
177
+ expect(extension.extension['srcdoc']).to be_nil
178
+ expect(extension.source).to eq 'http://example.com'
179
+ expect(extension.extension['src']).to eq 'http://example.com'
180
+ end
181
+
182
+ it 'if source is a string will set it to srcdoc' do
183
+ expect(src_extension.extension['src']).to eq 'http://foo.com'
184
+
185
+ src_extension.source = 'foobar'
186
+
187
+ expect(src_extension.extension['src']).to be_nil
188
+ expect(src_extension.source).to eq 'foobar'
189
+ expect(src_extension.extension['srcdoc']).to eq 'foobar'
190
+ end
191
+ end
192
+
193
+ it '#sidebar' do
194
+ expect(extension.sidebar).to eq false
195
+
196
+ extension.sidebar = true
197
+
198
+ expect(extension.sidebar).to eq true
199
+ expect(extension.extension['sidebar']).to eq true
200
+ end
201
+ end
202
+
203
+ describe '.all' do
204
+ it 'returns a Contentful::Array' do
205
+ vcr('ui_extension/all') { expect(subject.all(space_id)).to be_kind_of Contentful::Management::Array }
206
+ end
207
+
208
+ it 'builds a Contentful::Management::UIExtension' do
209
+ vcr('ui_extension/all') {
210
+ extension = subject.all(space_id).first
211
+
212
+ expect(extension).to be_kind_of Contentful::Management::UIExtension
213
+ expect(extension.name).to eq 'My awesome extension by srcDoc'
214
+ expect(extension.field_types).to eq [{"type"=>"Symbol"}, {"type"=>"Text"}]
215
+ expect(extension.source).to eq "<!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>"
216
+ expect(extension.sidebar).to eq false
217
+ expect(extension.id).to be_truthy
218
+ }
219
+ end
220
+
221
+ it 'class method also works' do
222
+ vcr('ui_extension/all') { expect(Contentful::Management::UIExtension.all(client, space_id)).to be_kind_of Contentful::Management::Array }
223
+ end
224
+ end
225
+
226
+ describe '.find' do
227
+ it 'returns a Contentful::Management::UIExtension' do
228
+ vcr('ui_extension/find') {
229
+ extension = subject.find(space_id, extension_id)
230
+
231
+ expect(extension).to be_kind_of Contentful::Management::UIExtension
232
+ expect(extension.name).to eq 'My awesome extension by srcDoc'
233
+ expect(extension.field_types).to eq [{"type"=>"Symbol"}, {"type"=>"Text"}]
234
+ expect(extension.source).to eq "<!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>"
235
+ expect(extension.sidebar).to eq false
236
+ expect(extension.id).to be_truthy
237
+ }
238
+ end
239
+ end
240
+
241
+ describe '.create' do
242
+ it 'creates a Contentful::Management::UIExtension' do
243
+ vcr('ui_extension/create') {
244
+ extension = subject.create(playground_space_id, extension: {
245
+ 'name' => 'test extension',
246
+ 'fieldTypes' => [{"type"=>"Symbol"}, {"type"=>"Text"}],
247
+ '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>",
248
+ 'sidebar' => false
249
+ })
250
+
251
+ expect(extension).to be_kind_of Contentful::Management::UIExtension
252
+ expect(extension.name).to eq 'test extension'
253
+ expect(extension.field_types).to eq [{"type"=>"Symbol"}, {"type"=>"Text"}]
254
+ expect(extension.source).to eq "<!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>"
255
+ expect(extension.sidebar).to eq false
256
+ expect(extension.id).to be_truthy
257
+ }
258
+ end
259
+ end
260
+
261
+ describe '#destroy' do
262
+ it 'deletes the extension' do
263
+ vcr('ui_extension/delete') {
264
+ extension = subject.find(playground_space_id, '2rf6QdckyoECCsQeE6gIOg')
265
+
266
+ expect(extension.id).to be_truthy
267
+
268
+ extension.destroy
269
+
270
+ expect { subject.find(playground_space_id, '2rf6QdckyoECCsQeE6gIOg') }.to raise_error Contentful::Management::NotFound
271
+ }
272
+ end
273
+ end
274
+ end
275
+ end
276
+ end