contentful-management 3.10.1 → 3.12.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/.github/workflows/codeql.yml +32 -0
- data/CHANGELOG.md +6 -0
- data/README.md +127 -1
- data/lib/contentful/management/client.rb +27 -0
- data/lib/contentful/management/client_taxonomy_concept_methods_factory.rb +34 -0
- data/lib/contentful/management/client_taxonomy_concept_scheme_methods_factory.rb +34 -0
- data/lib/contentful/management/content_type.rb +3 -0
- data/lib/contentful/management/editor_interface.rb +7 -2
- data/lib/contentful/management/resource/metadata.rb +8 -1
- data/lib/contentful/management/resource_builder.rb +5 -1
- data/lib/contentful/management/resource_requester.rb +11 -0
- data/lib/contentful/management/taxonomy_concept.rb +144 -0
- data/lib/contentful/management/taxonomy_concept_scheme.rb +108 -0
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/asset/update_with_concepts.yml +137 -0
- data/spec/fixtures/vcr_cassettes/content_type/update_with_metadata.yml +171 -0
- data/spec/fixtures/vcr_cassettes/editor_interfaces/all.yml +85 -0
- data/spec/fixtures/vcr_cassettes/entry/update_with_concepts.yml +182 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/all.yml +83 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/ancestors.yml +155 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/create.yml +77 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/create_with_id.yml +78 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/descendants.yml +153 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/destroy.yml +152 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/find.yml +79 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/total.yml +77 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept/update.yml +158 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/all.yml +80 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/create.yml +78 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/destroy.yml +150 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/find.yml +78 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/total.yml +77 -0
- data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/update.yml +155 -0
- data/spec/lib/contentful/management/asset_spec.rb +20 -0
- data/spec/lib/contentful/management/content_type_spec.rb +22 -0
- data/spec/lib/contentful/management/editor_interface_spec.rb +9 -0
- data/spec/lib/contentful/management/entry_spec.rb +22 -1
- data/spec/lib/contentful/management/taxonomy_concept_scheme_spec.rb +85 -0
- data/spec/lib/contentful/management/taxonomy_concept_spec.rb +116 -0
- metadata +48 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'contentful/management/taxonomy_concept'
|
|
3
|
+
require 'contentful/management/client'
|
|
4
|
+
|
|
5
|
+
module Contentful
|
|
6
|
+
module Management
|
|
7
|
+
describe TaxonomyConcept do
|
|
8
|
+
let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
|
|
9
|
+
|
|
10
|
+
let(:organization_id) { '4kQeJmhUWIKtNNmMkketza' }
|
|
11
|
+
let(:concept_id) { '5KHXWlmxvntrrB09szapUp' }
|
|
12
|
+
let(:client) { Client.new(token) }
|
|
13
|
+
|
|
14
|
+
subject { client.taxonomy_concepts(organization_id) }
|
|
15
|
+
|
|
16
|
+
describe '.find' do
|
|
17
|
+
it 'returns a Contentful::Management::TaxonomyConcept' do
|
|
18
|
+
vcr('taxonomy_concept/find') do
|
|
19
|
+
concept = subject.find(concept_id)
|
|
20
|
+
expect(concept).to be_a Contentful::Management::TaxonomyConcept
|
|
21
|
+
expect(concept.id).to eq concept_id
|
|
22
|
+
expect(concept.pref_label['en-US']).to eq 'Sofas'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '.all' do
|
|
28
|
+
it 'returns an array of taxonomy concepts' do
|
|
29
|
+
vcr('taxonomy_concept/all') do
|
|
30
|
+
concepts = subject.all
|
|
31
|
+
expect(concepts).to be_a(Contentful::Management::Array)
|
|
32
|
+
expect(concepts.first).to be_a(Contentful::Management::TaxonomyConcept)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe '.total' do
|
|
38
|
+
it 'returns the total number of concepts' do
|
|
39
|
+
vcr('taxonomy_concept/total') do
|
|
40
|
+
total = subject.total
|
|
41
|
+
expect(total).to be_a(Integer)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '.create' do
|
|
47
|
+
it 'creates a taxonomy concept' do
|
|
48
|
+
vcr('taxonomy_concept/create') do
|
|
49
|
+
concept = subject.create(
|
|
50
|
+
prefLabel: { 'en-US' => 'Bicycles' }
|
|
51
|
+
)
|
|
52
|
+
expect(concept).to be_a(Contentful::Management::TaxonomyConcept)
|
|
53
|
+
expect(concept.pref_label['en-US']).to eq('Bicycles')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'creates a taxonomy concept with a user-defined id' do
|
|
58
|
+
vcr('taxonomy_concept/create_with_id') do
|
|
59
|
+
concept = subject.create(
|
|
60
|
+
id: 'my-custom-id',
|
|
61
|
+
prefLabel: { 'en-US' => 'Custom Bicycles' }
|
|
62
|
+
)
|
|
63
|
+
expect(concept).to be_a(Contentful::Management::TaxonomyConcept)
|
|
64
|
+
expect(concept.id).to eq('my-custom-id')
|
|
65
|
+
expect(concept.pref_label['en-US']).to eq('Custom Bicycles')
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#update' do
|
|
71
|
+
it 'updates a taxonomy concept' do
|
|
72
|
+
vcr('taxonomy_concept/update') do
|
|
73
|
+
concept = subject.find(concept_id)
|
|
74
|
+
updated_concept = concept.update([
|
|
75
|
+
{ op: 'add', path: '/prefLabel/en-US', value: 'New Label' }
|
|
76
|
+
])
|
|
77
|
+
expect(updated_concept).to be_a(Contentful::Management::TaxonomyConcept)
|
|
78
|
+
expect(updated_concept.pref_label['en-US']).to eq('New Label')
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '#ancestors' do
|
|
84
|
+
it 'returns an array of ancestor concepts' do
|
|
85
|
+
vcr('taxonomy_concept/ancestors') do
|
|
86
|
+
concept = subject.find('livingRoom')
|
|
87
|
+
ancestors = concept.ancestors
|
|
88
|
+
expect(ancestors).to be_a(Contentful::Management::Array)
|
|
89
|
+
expect(ancestors.first).to be_a(Contentful::Management::TaxonomyConcept)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe '#descendants' do
|
|
95
|
+
it 'returns an array of descendant concepts' do
|
|
96
|
+
vcr('taxonomy_concept/descendants') do
|
|
97
|
+
concept = subject.find('greenSofas')
|
|
98
|
+
descendants = concept.descendants
|
|
99
|
+
expect(descendants).to be_a(Contentful::Management::Array)
|
|
100
|
+
expect(descendants.first).to be_a(Contentful::Management::TaxonomyConcept)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#destroy' do
|
|
106
|
+
it 'deletes a taxonomy concept' do
|
|
107
|
+
vcr('taxonomy_concept/destroy') do
|
|
108
|
+
concept = subject.find(concept_id)
|
|
109
|
+
result = concept.destroy
|
|
110
|
+
expect(result).to be_truthy
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
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: 3.
|
|
4
|
+
version: 3.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Piotr Protas
|
|
@@ -281,6 +281,7 @@ extra_rdoc_files: []
|
|
|
281
281
|
files:
|
|
282
282
|
- ".circleci/config.yml"
|
|
283
283
|
- ".github/CODEOWNERS"
|
|
284
|
+
- ".github/workflows/codeql.yml"
|
|
284
285
|
- ".gitignore"
|
|
285
286
|
- ".reek"
|
|
286
287
|
- ".rspec"
|
|
@@ -324,6 +325,8 @@ files:
|
|
|
324
325
|
- lib/contentful/management/client_space_methods_factory.rb
|
|
325
326
|
- lib/contentful/management/client_space_periodic_usage_methods_factory.rb
|
|
326
327
|
- lib/contentful/management/client_tag_methods_factory.rb
|
|
328
|
+
- lib/contentful/management/client_taxonomy_concept_methods_factory.rb
|
|
329
|
+
- lib/contentful/management/client_taxonomy_concept_scheme_methods_factory.rb
|
|
327
330
|
- lib/contentful/management/client_ui_extension_methods_factory.rb
|
|
328
331
|
- lib/contentful/management/client_upload_methods_factory.rb
|
|
329
332
|
- lib/contentful/management/client_user_methods_factory.rb
|
|
@@ -391,6 +394,8 @@ files:
|
|
|
391
394
|
- lib/contentful/management/space_webhook_methods_factory.rb
|
|
392
395
|
- lib/contentful/management/support.rb
|
|
393
396
|
- lib/contentful/management/tag.rb
|
|
397
|
+
- lib/contentful/management/taxonomy_concept.rb
|
|
398
|
+
- lib/contentful/management/taxonomy_concept_scheme.rb
|
|
394
399
|
- lib/contentful/management/ui_extension.rb
|
|
395
400
|
- lib/contentful/management/upload.rb
|
|
396
401
|
- lib/contentful/management/user.rb
|
|
@@ -471,6 +476,7 @@ files:
|
|
|
471
476
|
- spec/fixtures/vcr_cassettes/asset/unpublish_already_unpublished.yml
|
|
472
477
|
- spec/fixtures/vcr_cassettes/asset/update_file.yml
|
|
473
478
|
- spec/fixtures/vcr_cassettes/asset/update_to_specified_locale.yml
|
|
479
|
+
- spec/fixtures/vcr_cassettes/asset/update_with_concepts.yml
|
|
474
480
|
- spec/fixtures/vcr_cassettes/asset/update_with_default_locale_without_file.yml
|
|
475
481
|
- spec/fixtures/vcr_cassettes/content_type/196_retain_environment_id.yml
|
|
476
482
|
- spec/fixtures/vcr_cassettes/content_type/activate.yml
|
|
@@ -529,6 +535,7 @@ files:
|
|
|
529
535
|
- spec/fixtures/vcr_cassettes/content_type/update_remove_field.yml
|
|
530
536
|
- spec/fixtures/vcr_cassettes/content_type/update_with_deleted_true.yml
|
|
531
537
|
- spec/fixtures/vcr_cassettes/content_type/update_with_fields.yml
|
|
538
|
+
- spec/fixtures/vcr_cassettes/content_type/update_with_metadata.yml
|
|
532
539
|
- spec/fixtures/vcr_cassettes/content_type/update_with_one_new_field.yml
|
|
533
540
|
- spec/fixtures/vcr_cassettes/content_type/validation/in.yml
|
|
534
541
|
- spec/fixtures/vcr_cassettes/content_type/validation/in_add.yml
|
|
@@ -544,6 +551,7 @@ files:
|
|
|
544
551
|
- spec/fixtures/vcr_cassettes/content_type/validation/size.yml
|
|
545
552
|
- spec/fixtures/vcr_cassettes/content_type/validation/unique.yml
|
|
546
553
|
- spec/fixtures/vcr_cassettes/delete_request.yml
|
|
554
|
+
- spec/fixtures/vcr_cassettes/editor_interfaces/all.yml
|
|
547
555
|
- spec/fixtures/vcr_cassettes/editor_interfaces/default_for_space.yml
|
|
548
556
|
- spec/fixtures/vcr_cassettes/editor_interfaces/update.yml
|
|
549
557
|
- spec/fixtures/vcr_cassettes/editor_interfaces/update_sidebar.yml
|
|
@@ -627,6 +635,7 @@ files:
|
|
|
627
635
|
- spec/fixtures/vcr_cassettes/entry/update.yml
|
|
628
636
|
- spec/fixtures/vcr_cassettes/entry/update_bool_field.yml
|
|
629
637
|
- spec/fixtures/vcr_cassettes/entry/update_unlocalized_field.yml
|
|
638
|
+
- spec/fixtures/vcr_cassettes/entry/update_with_concepts.yml
|
|
630
639
|
- spec/fixtures/vcr_cassettes/entry/update_with_custom_locale.yml
|
|
631
640
|
- spec/fixtures/vcr_cassettes/entry/updated_false.yml
|
|
632
641
|
- spec/fixtures/vcr_cassettes/entry/updated_true.yml
|
|
@@ -757,6 +766,21 @@ files:
|
|
|
757
766
|
- spec/fixtures/vcr_cassettes/tag/remove_tag_from_asset.yml
|
|
758
767
|
- spec/fixtures/vcr_cassettes/tag/remove_tag_from_entry.yml
|
|
759
768
|
- spec/fixtures/vcr_cassettes/tag/update.yml
|
|
769
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/all.yml
|
|
770
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/ancestors.yml
|
|
771
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/create.yml
|
|
772
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/create_with_id.yml
|
|
773
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/descendants.yml
|
|
774
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/destroy.yml
|
|
775
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/find.yml
|
|
776
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/total.yml
|
|
777
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/update.yml
|
|
778
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/all.yml
|
|
779
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/create.yml
|
|
780
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/destroy.yml
|
|
781
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/find.yml
|
|
782
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/total.yml
|
|
783
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/update.yml
|
|
760
784
|
- spec/fixtures/vcr_cassettes/ui_extension/all.yml
|
|
761
785
|
- spec/fixtures/vcr_cassettes/ui_extension/create.yml
|
|
762
786
|
- spec/fixtures/vcr_cassettes/ui_extension/create_parameters.yml
|
|
@@ -804,6 +828,8 @@ files:
|
|
|
804
828
|
- spec/lib/contentful/management/space_periodic_usage_spec.rb
|
|
805
829
|
- spec/lib/contentful/management/space_spec.rb
|
|
806
830
|
- spec/lib/contentful/management/tag_spec.rb
|
|
831
|
+
- spec/lib/contentful/management/taxonomy_concept_scheme_spec.rb
|
|
832
|
+
- spec/lib/contentful/management/taxonomy_concept_spec.rb
|
|
807
833
|
- spec/lib/contentful/management/ui_extension_spec.rb
|
|
808
834
|
- spec/lib/contentful/management/upload_spec.rb
|
|
809
835
|
- spec/lib/contentful/management/user_spec.rb
|
|
@@ -905,6 +931,7 @@ test_files:
|
|
|
905
931
|
- spec/fixtures/vcr_cassettes/asset/unpublish_already_unpublished.yml
|
|
906
932
|
- spec/fixtures/vcr_cassettes/asset/update_file.yml
|
|
907
933
|
- spec/fixtures/vcr_cassettes/asset/update_to_specified_locale.yml
|
|
934
|
+
- spec/fixtures/vcr_cassettes/asset/update_with_concepts.yml
|
|
908
935
|
- spec/fixtures/vcr_cassettes/asset/update_with_default_locale_without_file.yml
|
|
909
936
|
- spec/fixtures/vcr_cassettes/content_type/196_retain_environment_id.yml
|
|
910
937
|
- spec/fixtures/vcr_cassettes/content_type/activate.yml
|
|
@@ -963,6 +990,7 @@ test_files:
|
|
|
963
990
|
- spec/fixtures/vcr_cassettes/content_type/update_remove_field.yml
|
|
964
991
|
- spec/fixtures/vcr_cassettes/content_type/update_with_deleted_true.yml
|
|
965
992
|
- spec/fixtures/vcr_cassettes/content_type/update_with_fields.yml
|
|
993
|
+
- spec/fixtures/vcr_cassettes/content_type/update_with_metadata.yml
|
|
966
994
|
- spec/fixtures/vcr_cassettes/content_type/update_with_one_new_field.yml
|
|
967
995
|
- spec/fixtures/vcr_cassettes/content_type/validation/in.yml
|
|
968
996
|
- spec/fixtures/vcr_cassettes/content_type/validation/in_add.yml
|
|
@@ -978,6 +1006,7 @@ test_files:
|
|
|
978
1006
|
- spec/fixtures/vcr_cassettes/content_type/validation/size.yml
|
|
979
1007
|
- spec/fixtures/vcr_cassettes/content_type/validation/unique.yml
|
|
980
1008
|
- spec/fixtures/vcr_cassettes/delete_request.yml
|
|
1009
|
+
- spec/fixtures/vcr_cassettes/editor_interfaces/all.yml
|
|
981
1010
|
- spec/fixtures/vcr_cassettes/editor_interfaces/default_for_space.yml
|
|
982
1011
|
- spec/fixtures/vcr_cassettes/editor_interfaces/update.yml
|
|
983
1012
|
- spec/fixtures/vcr_cassettes/editor_interfaces/update_sidebar.yml
|
|
@@ -1061,6 +1090,7 @@ test_files:
|
|
|
1061
1090
|
- spec/fixtures/vcr_cassettes/entry/update.yml
|
|
1062
1091
|
- spec/fixtures/vcr_cassettes/entry/update_bool_field.yml
|
|
1063
1092
|
- spec/fixtures/vcr_cassettes/entry/update_unlocalized_field.yml
|
|
1093
|
+
- spec/fixtures/vcr_cassettes/entry/update_with_concepts.yml
|
|
1064
1094
|
- spec/fixtures/vcr_cassettes/entry/update_with_custom_locale.yml
|
|
1065
1095
|
- spec/fixtures/vcr_cassettes/entry/updated_false.yml
|
|
1066
1096
|
- spec/fixtures/vcr_cassettes/entry/updated_true.yml
|
|
@@ -1191,6 +1221,21 @@ test_files:
|
|
|
1191
1221
|
- spec/fixtures/vcr_cassettes/tag/remove_tag_from_asset.yml
|
|
1192
1222
|
- spec/fixtures/vcr_cassettes/tag/remove_tag_from_entry.yml
|
|
1193
1223
|
- spec/fixtures/vcr_cassettes/tag/update.yml
|
|
1224
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/all.yml
|
|
1225
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/ancestors.yml
|
|
1226
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/create.yml
|
|
1227
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/create_with_id.yml
|
|
1228
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/descendants.yml
|
|
1229
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/destroy.yml
|
|
1230
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/find.yml
|
|
1231
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/total.yml
|
|
1232
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept/update.yml
|
|
1233
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/all.yml
|
|
1234
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/create.yml
|
|
1235
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/destroy.yml
|
|
1236
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/find.yml
|
|
1237
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/total.yml
|
|
1238
|
+
- spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/update.yml
|
|
1194
1239
|
- spec/fixtures/vcr_cassettes/ui_extension/all.yml
|
|
1195
1240
|
- spec/fixtures/vcr_cassettes/ui_extension/create.yml
|
|
1196
1241
|
- spec/fixtures/vcr_cassettes/ui_extension/create_parameters.yml
|
|
@@ -1238,6 +1283,8 @@ test_files:
|
|
|
1238
1283
|
- spec/lib/contentful/management/space_periodic_usage_spec.rb
|
|
1239
1284
|
- spec/lib/contentful/management/space_spec.rb
|
|
1240
1285
|
- spec/lib/contentful/management/tag_spec.rb
|
|
1286
|
+
- spec/lib/contentful/management/taxonomy_concept_scheme_spec.rb
|
|
1287
|
+
- spec/lib/contentful/management/taxonomy_concept_spec.rb
|
|
1241
1288
|
- spec/lib/contentful/management/ui_extension_spec.rb
|
|
1242
1289
|
- spec/lib/contentful/management/upload_spec.rb
|
|
1243
1290
|
- spec/lib/contentful/management/user_spec.rb
|