contentful-management 2.12.0 → 3.1.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 +29 -0
- data/README.md +24 -0
- data/contentful-management.gemspec +1 -1
- data/lib/contentful/management/asset.rb +2 -0
- data/lib/contentful/management/entry.rb +16 -12
- data/lib/contentful/management/field.rb +3 -1
- data/lib/contentful/management/organization.rb +10 -0
- data/lib/contentful/management/organization_user_methods_factory.rb +22 -0
- data/lib/contentful/management/resource.rb +7 -4
- data/lib/contentful/management/resource/metadata.rb +44 -0
- data/lib/contentful/management/resource_builder.rb +4 -2
- data/lib/contentful/management/space.rb +10 -0
- data/lib/contentful/management/space_user_methods_factory.rb +23 -0
- data/lib/contentful/management/tag.rb +14 -0
- data/lib/contentful/management/user.rb +7 -1
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/asset/issue_219.yml +442 -0
- data/spec/fixtures/vcr_cassettes/entry/issue_215_1.yml +905 -0
- data/spec/fixtures/vcr_cassettes/entry/issue_215_2.yml +899 -0
- data/spec/fixtures/vcr_cassettes/entry/issue_215_3.yml +893 -0
- data/spec/fixtures/vcr_cassettes/entry/issue_219.yml +535 -0
- data/spec/fixtures/vcr_cassettes/organization/user.yml +238 -0
- data/spec/fixtures/vcr_cassettes/organization/users.yml +233 -0
- data/spec/fixtures/vcr_cassettes/space/user.yml +254 -0
- data/spec/fixtures/vcr_cassettes/space/users.yml +236 -0
- data/spec/lib/contentful/management/asset_spec.rb +31 -0
- data/spec/lib/contentful/management/entry_spec.rb +77 -0
- data/spec/lib/contentful/management/organization_spec.rb +30 -0
- data/spec/lib/contentful/management/space_spec.rb +30 -0
- metadata +31 -9
@@ -457,6 +457,37 @@ module Contentful
|
|
457
457
|
end
|
458
458
|
|
459
459
|
describe 'issues' do
|
460
|
+
describe 'metadata and tags do not break entry fetching - #219' do
|
461
|
+
let(:space_id) { '2l3j7k267g9k' }
|
462
|
+
let(:space) { client.spaces.find(space_id) }
|
463
|
+
let(:environment) { space.environments.find('master') }
|
464
|
+
let(:asset_id) { '2lxYoWv3LWHe0yhO3w2Yid' }
|
465
|
+
|
466
|
+
it 'can load an entry with tags' do
|
467
|
+
vcr('asset/issue_219') {
|
468
|
+
expect {
|
469
|
+
entry = environment.assets.find(asset_id)
|
470
|
+
}.not_to raise_error
|
471
|
+
}
|
472
|
+
end
|
473
|
+
|
474
|
+
it 'hydrates tags' do
|
475
|
+
vcr('asset/issue_219') {
|
476
|
+
asset = environment.assets.find(asset_id)
|
477
|
+
expect(asset._metadata[:tags].first).to be_a Contentful::Management::Link
|
478
|
+
}
|
479
|
+
end
|
480
|
+
|
481
|
+
it 'loads tag links with their proper attributes' do
|
482
|
+
vcr('asset/issue_219') {
|
483
|
+
asset = environment.assets.find(asset_id)
|
484
|
+
tag = asset._metadata[:tags].first
|
485
|
+
expect(tag.id).to eq 'mobQa'
|
486
|
+
expect(tag.link_type).to eq 'Tag'
|
487
|
+
}
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
460
491
|
describe "Pagination on assets doesn't work without first calling limit - #143" do
|
461
492
|
it 'shouldnt break on next page without parameters on original query' do
|
462
493
|
vcr('asset/143_assets_next_page') do
|
@@ -866,6 +866,83 @@ describe Contentful::Management::Entry do
|
|
866
866
|
end
|
867
867
|
|
868
868
|
describe 'issues' do
|
869
|
+
let(:space_id) { 'vuo79u060fmw' }
|
870
|
+
let(:space) { client.spaces.find(space_id) }
|
871
|
+
let(:environment) { space.environments.find('master') }
|
872
|
+
|
873
|
+
describe 'metadata and tags do not break entry fetching - #219' do
|
874
|
+
let(:space_id) { '2l3j7k267g9k' }
|
875
|
+
let(:entry_id) { '2AtqG09C50s7kE66POudAV' }
|
876
|
+
|
877
|
+
it 'can load an entry with tags' do
|
878
|
+
vcr('entry/issue_219') {
|
879
|
+
expect {
|
880
|
+
entry = environment.entries.find(entry_id)
|
881
|
+
}.not_to raise_error
|
882
|
+
}
|
883
|
+
end
|
884
|
+
|
885
|
+
it 'hydrates tags' do
|
886
|
+
vcr('entry/issue_219') {
|
887
|
+
entry = environment.entries.find(entry_id)
|
888
|
+
expect(entry._metadata[:tags].first).to be_a Contentful::Management::Link
|
889
|
+
}
|
890
|
+
end
|
891
|
+
|
892
|
+
it 'loads tag links with their proper attributes' do
|
893
|
+
vcr('entry/issue_219') {
|
894
|
+
entry = environment.entries.find(entry_id)
|
895
|
+
tag = entry._metadata[:tags].first
|
896
|
+
expect(tag.id).to eq 'mobQa'
|
897
|
+
expect(tag.link_type).to eq 'Tag'
|
898
|
+
}
|
899
|
+
end
|
900
|
+
end
|
901
|
+
|
902
|
+
describe 'json fields do not get reset on save - #215' do
|
903
|
+
it 'can load a json array, modify it, save it, and retrieve it' do
|
904
|
+
vcr('entry/issue_215_1') {
|
905
|
+
entry = environment.entries.find('30QNJFxJQwLpdqZn8CHsHf')
|
906
|
+
expect(entry.json).to eq([1, 2, 3])
|
907
|
+
|
908
|
+
entry.json = entry.json.map { |e| e + 1 }
|
909
|
+
entry.save
|
910
|
+
|
911
|
+
entry.reload
|
912
|
+
|
913
|
+
expect(entry.json).to eq([2, 3, 4])
|
914
|
+
}
|
915
|
+
end
|
916
|
+
|
917
|
+
it 'can load a json object, modify it, save it, and retrieve it' do
|
918
|
+
vcr('entry/issue_215_2') {
|
919
|
+
entry = environment.entries.find('6kcaBzW7xgjVr825PmGCvP')
|
920
|
+
expect(entry.json).to eq({ "a" => 1 })
|
921
|
+
|
922
|
+
entry.json["a"] = 2
|
923
|
+
entry.save
|
924
|
+
|
925
|
+
entry.reload
|
926
|
+
|
927
|
+
expect(entry.json).to eq({ "a" => 2 })
|
928
|
+
}
|
929
|
+
end
|
930
|
+
|
931
|
+
it 'can load an empty json object, set it, save it, and retrieve it' do
|
932
|
+
vcr('entry/issue_215_3') {
|
933
|
+
entry = environment.entries.find('4aVBlJajh2rZb7ybW2tY2X')
|
934
|
+
expect(entry.json).to be_nil
|
935
|
+
|
936
|
+
entry.json = { "a" => 1 }
|
937
|
+
entry.save
|
938
|
+
|
939
|
+
entry.reload
|
940
|
+
|
941
|
+
expect(entry.json).to eq({ "a" => 1 })
|
942
|
+
}
|
943
|
+
end
|
944
|
+
end
|
945
|
+
|
869
946
|
describe 'can send query parameters when requesting through environment proxy - #160' do
|
870
947
|
it 'can filter by content type and set a limit different than 100' do
|
871
948
|
vcr('entry/issue_160') {
|
@@ -28,6 +28,36 @@ module Contentful
|
|
28
28
|
expect { subject.find }.to raise_error 'Not supported'
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
describe "users" do
|
33
|
+
describe '.find' do
|
34
|
+
it "should fetch the user if under the organizaton id" do
|
35
|
+
vcr('organization/user') {
|
36
|
+
organization = subject.all.first
|
37
|
+
user = organization.users.find('user_id')
|
38
|
+
|
39
|
+
expect(user).to be_a Contentful::Management::User
|
40
|
+
expect(user.first_name).to eq 'Bhushan'
|
41
|
+
expect(user.last_name).to eq 'Lodha'
|
42
|
+
expect(user.email).to eq 'bhushanlodha@gmail.com'
|
43
|
+
expect(user.activated).to eq true
|
44
|
+
expect(user.confirmed).to eq true
|
45
|
+
expect(user.sign_in_count).to eq 42
|
46
|
+
expect(user.avatar_url).to be_truthy
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "all" do
|
51
|
+
it 'returns a Contentful::Array' do
|
52
|
+
vcr('organization/users') { expect(subject.all.first.users.all).to be_kind_of Contentful::Management::Array }
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'builds a Contentful::Management::Space object' do
|
56
|
+
vcr('organization/users') { expect(subject.all.first.users.all.first).to be_kind_of Contentful::Management::User }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
31
61
|
end
|
32
62
|
end
|
33
63
|
end
|
@@ -240,6 +240,36 @@ module Contentful
|
|
240
240
|
}
|
241
241
|
end
|
242
242
|
end
|
243
|
+
|
244
|
+
describe "users" do
|
245
|
+
describe "find" do
|
246
|
+
it "should fetch the user if under the space id" do
|
247
|
+
vcr('space/user') {
|
248
|
+
space = subject.find('space_id')
|
249
|
+
user = space.users.find('user_id')
|
250
|
+
|
251
|
+
expect(user).to be_a Contentful::Management::User
|
252
|
+
expect(user.first_name).to eq 'Bhushan'
|
253
|
+
expect(user.last_name).to eq 'Test'
|
254
|
+
expect(user.email).to eq 'bhushanlodha@gmail.com'
|
255
|
+
expect(user.activated).to eq true
|
256
|
+
expect(user.confirmed).to eq true
|
257
|
+
expect(user.sign_in_count).to eq 42
|
258
|
+
expect(user.avatar_url).to be_truthy
|
259
|
+
}
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe "all" do
|
264
|
+
it 'returns a Contentful::Array' do
|
265
|
+
vcr('space/users') { expect(subject.find('space_id').users.all).to be_kind_of Contentful::Management::Array }
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'builds a Contentful::Management::Space object' do
|
269
|
+
vcr('space/users') { expect(subject.find('space_id').users.all.first).to be_kind_of Contentful::Management::User }
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
243
273
|
end
|
244
274
|
end
|
245
275
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Protas
|
8
8
|
- Tomasz Warkocki
|
9
9
|
- Contentful GmbH (Andreas Tiefenthaler)
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 12.3.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 12.3.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: public_suffix
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -359,6 +359,7 @@ files:
|
|
359
359
|
- lib/contentful/management/location.rb
|
360
360
|
- lib/contentful/management/organization.rb
|
361
361
|
- lib/contentful/management/organization_periodic_usage.rb
|
362
|
+
- lib/contentful/management/organization_user_methods_factory.rb
|
362
363
|
- lib/contentful/management/personal_access_token.rb
|
363
364
|
- lib/contentful/management/preview_api_key.rb
|
364
365
|
- lib/contentful/management/request.rb
|
@@ -371,6 +372,7 @@ files:
|
|
371
372
|
- lib/contentful/management/resource/environment_aware.rb
|
372
373
|
- lib/contentful/management/resource/field_aware.rb
|
373
374
|
- lib/contentful/management/resource/fields.rb
|
375
|
+
- lib/contentful/management/resource/metadata.rb
|
374
376
|
- lib/contentful/management/resource/publisher.rb
|
375
377
|
- lib/contentful/management/resource/refresher.rb
|
376
378
|
- lib/contentful/management/resource/system_properties.rb
|
@@ -388,8 +390,10 @@ files:
|
|
388
390
|
- lib/contentful/management/space_preview_api_key_methods_factory.rb
|
389
391
|
- lib/contentful/management/space_role_methods_factory.rb
|
390
392
|
- lib/contentful/management/space_space_membership_methods_factory.rb
|
393
|
+
- lib/contentful/management/space_user_methods_factory.rb
|
391
394
|
- lib/contentful/management/space_webhook_methods_factory.rb
|
392
395
|
- lib/contentful/management/support.rb
|
396
|
+
- lib/contentful/management/tag.rb
|
393
397
|
- lib/contentful/management/ui_extension.rb
|
394
398
|
- lib/contentful/management/upload.rb
|
395
399
|
- lib/contentful/management/user.rb
|
@@ -449,6 +453,7 @@ files:
|
|
449
453
|
- spec/fixtures/vcr_cassettes/asset/destroy_published.yml
|
450
454
|
- spec/fixtures/vcr_cassettes/asset/find.yml
|
451
455
|
- spec/fixtures/vcr_cassettes/asset/find_not_found.yml
|
456
|
+
- spec/fixtures/vcr_cassettes/asset/issue_219.yml
|
452
457
|
- spec/fixtures/vcr_cassettes/asset/limited_assets_next_page.yml
|
453
458
|
- spec/fixtures/vcr_cassettes/asset/locale.yml
|
454
459
|
- spec/fixtures/vcr_cassettes/asset/process.yml
|
@@ -566,6 +571,10 @@ files:
|
|
566
571
|
- spec/fixtures/vcr_cassettes/entry/find.yml
|
567
572
|
- spec/fixtures/vcr_cassettes/entry/find_not_found.yml
|
568
573
|
- spec/fixtures/vcr_cassettes/entry/issue_160.yml
|
574
|
+
- spec/fixtures/vcr_cassettes/entry/issue_215_1.yml
|
575
|
+
- spec/fixtures/vcr_cassettes/entry/issue_215_2.yml
|
576
|
+
- spec/fixtures/vcr_cassettes/entry/issue_215_3.yml
|
577
|
+
- spec/fixtures/vcr_cassettes/entry/issue_219.yml
|
569
578
|
- spec/fixtures/vcr_cassettes/entry/issue_61_1.yml
|
570
579
|
- spec/fixtures/vcr_cassettes/entry/issue_61_2.yml
|
571
580
|
- spec/fixtures/vcr_cassettes/entry/issue_61_3.yml
|
@@ -646,6 +655,8 @@ files:
|
|
646
655
|
- spec/fixtures/vcr_cassettes/locale/update_code.yml
|
647
656
|
- spec/fixtures/vcr_cassettes/locale/update_name.yml
|
648
657
|
- spec/fixtures/vcr_cassettes/organization/all.yml
|
658
|
+
- spec/fixtures/vcr_cassettes/organization/user.yml
|
659
|
+
- spec/fixtures/vcr_cassettes/organization/users.yml
|
649
660
|
- spec/fixtures/vcr_cassettes/organization_periodic_usage/all.yml
|
650
661
|
- spec/fixtures/vcr_cassettes/organization_periodic_usage/filters.yml
|
651
662
|
- spec/fixtures/vcr_cassettes/personal_access_token/all.yml
|
@@ -715,6 +726,8 @@ files:
|
|
715
726
|
- spec/fixtures/vcr_cassettes/space/save_update_space.yml
|
716
727
|
- spec/fixtures/vcr_cassettes/space/update.yml
|
717
728
|
- spec/fixtures/vcr_cassettes/space/update_with_the_same_data.yml
|
729
|
+
- spec/fixtures/vcr_cassettes/space/user.yml
|
730
|
+
- spec/fixtures/vcr_cassettes/space/users.yml
|
718
731
|
- spec/fixtures/vcr_cassettes/space/webhook/all.yml
|
719
732
|
- spec/fixtures/vcr_cassettes/space/webhook/create.yml
|
720
733
|
- spec/fixtures/vcr_cassettes/space/webhook/find.yml
|
@@ -784,7 +797,7 @@ homepage: https://github.com/contentful/contentful-management.rb
|
|
784
797
|
licenses:
|
785
798
|
- MIT
|
786
799
|
metadata: {}
|
787
|
-
post_install_message:
|
800
|
+
post_install_message:
|
788
801
|
rdoc_options: []
|
789
802
|
require_paths:
|
790
803
|
- lib
|
@@ -800,7 +813,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
800
813
|
version: '0'
|
801
814
|
requirements: []
|
802
815
|
rubygems_version: 3.0.3
|
803
|
-
signing_key:
|
816
|
+
signing_key:
|
804
817
|
specification_version: 4
|
805
818
|
summary: contentful management api
|
806
819
|
test_files:
|
@@ -853,6 +866,7 @@ test_files:
|
|
853
866
|
- spec/fixtures/vcr_cassettes/asset/destroy_published.yml
|
854
867
|
- spec/fixtures/vcr_cassettes/asset/find.yml
|
855
868
|
- spec/fixtures/vcr_cassettes/asset/find_not_found.yml
|
869
|
+
- spec/fixtures/vcr_cassettes/asset/issue_219.yml
|
856
870
|
- spec/fixtures/vcr_cassettes/asset/limited_assets_next_page.yml
|
857
871
|
- spec/fixtures/vcr_cassettes/asset/locale.yml
|
858
872
|
- spec/fixtures/vcr_cassettes/asset/process.yml
|
@@ -970,6 +984,10 @@ test_files:
|
|
970
984
|
- spec/fixtures/vcr_cassettes/entry/find.yml
|
971
985
|
- spec/fixtures/vcr_cassettes/entry/find_not_found.yml
|
972
986
|
- spec/fixtures/vcr_cassettes/entry/issue_160.yml
|
987
|
+
- spec/fixtures/vcr_cassettes/entry/issue_215_1.yml
|
988
|
+
- spec/fixtures/vcr_cassettes/entry/issue_215_2.yml
|
989
|
+
- spec/fixtures/vcr_cassettes/entry/issue_215_3.yml
|
990
|
+
- spec/fixtures/vcr_cassettes/entry/issue_219.yml
|
973
991
|
- spec/fixtures/vcr_cassettes/entry/issue_61_1.yml
|
974
992
|
- spec/fixtures/vcr_cassettes/entry/issue_61_2.yml
|
975
993
|
- spec/fixtures/vcr_cassettes/entry/issue_61_3.yml
|
@@ -1050,6 +1068,8 @@ test_files:
|
|
1050
1068
|
- spec/fixtures/vcr_cassettes/locale/update_code.yml
|
1051
1069
|
- spec/fixtures/vcr_cassettes/locale/update_name.yml
|
1052
1070
|
- spec/fixtures/vcr_cassettes/organization/all.yml
|
1071
|
+
- spec/fixtures/vcr_cassettes/organization/user.yml
|
1072
|
+
- spec/fixtures/vcr_cassettes/organization/users.yml
|
1053
1073
|
- spec/fixtures/vcr_cassettes/organization_periodic_usage/all.yml
|
1054
1074
|
- spec/fixtures/vcr_cassettes/organization_periodic_usage/filters.yml
|
1055
1075
|
- spec/fixtures/vcr_cassettes/personal_access_token/all.yml
|
@@ -1119,6 +1139,8 @@ test_files:
|
|
1119
1139
|
- spec/fixtures/vcr_cassettes/space/save_update_space.yml
|
1120
1140
|
- spec/fixtures/vcr_cassettes/space/update.yml
|
1121
1141
|
- spec/fixtures/vcr_cassettes/space/update_with_the_same_data.yml
|
1142
|
+
- spec/fixtures/vcr_cassettes/space/user.yml
|
1143
|
+
- spec/fixtures/vcr_cassettes/space/users.yml
|
1122
1144
|
- spec/fixtures/vcr_cassettes/space/webhook/all.yml
|
1123
1145
|
- spec/fixtures/vcr_cassettes/space/webhook/create.yml
|
1124
1146
|
- spec/fixtures/vcr_cassettes/space/webhook/find.yml
|