contentful-management 3.4.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -456,7 +456,12 @@ describe Contentful::Management::Entry do
456
456
  end
457
457
 
458
458
  it 'too many requests auto-retry' do
459
- vcr('entry/too_many_requests_retry') do
459
+ # Testing that the header versions are not cleared between retries
460
+ header_matcher = lambda do |request_1, request_2|
461
+ request_1.headers["X-Contentful-Version"] == request_2.headers["X-Contentful-Version"]
462
+ end
463
+
464
+ VCR.use_cassette('entry/too_many_requests_retry', match_requests_on: [:method, :uri, header_matcher]) do
460
465
  logger = RetryLoggerMock.new(STDOUT)
461
466
  space = Contentful::Management::Client.new(token, raise_errors: true, logger: logger).spaces.find('286arvy86ry9')
462
467
  invalid_entry = client.entries(space.id, 'master').find('1YNepnMpXGiMWikaKC4GG0')
@@ -1239,4 +1244,15 @@ describe Contentful::Management::Entry do
1239
1244
  end
1240
1245
  end
1241
1246
  end
1247
+
1248
+ describe '#references' do
1249
+ it 'can fetch references' do
1250
+ vcr('entry/references') do
1251
+ result = subject.find(entry_id).references(include: 1)
1252
+
1253
+ expect(result).to be_kind_of Contentful::Management::Array
1254
+ expect(result)
1255
+ end
1256
+ end
1257
+ end
1242
1258
  end
@@ -10,22 +10,62 @@ describe Contentful::Management::Environment do
10
10
  subject { client.environments(space_id) }
11
11
 
12
12
  describe '.all' do
13
- it 'fetches all environments for a space' do
14
- vcr('environment/all') {
15
- environments = subject.all
13
+ context 'given no params' do
14
+ it 'fetches the first 25 environments for a space' do
15
+ vcr('environment/all') {
16
+ environments = subject.all
17
+
18
+ expect(environments.size).to eq 25
19
+ expect(environments.total).to eq 26
20
+ expect(environments.first).to be_a ::Contentful::Management::Environment
21
+ }
22
+ end
16
23
 
17
- expect(environments.size).to eq 2
18
- expect(environments.first).to be_a ::Contentful::Management::Environment
19
- }
24
+ it 'class method also works' do
25
+ vcr('environment/all') {
26
+ environments = described_class.all(client, space_id)
27
+
28
+ expect(environments.size).to eq 25
29
+ expect(environments.total).to eq 26
30
+ expect(environments.first).to be_a ::Contentful::Management::Environment
31
+ }
32
+ end
20
33
  end
21
34
 
22
- it 'class method also works' do
23
- vcr('environment/all') {
24
- environments = described_class.all(client, space_id)
35
+ context 'given params for limit' do
36
+ let(:params) do
37
+ {
38
+ limit: 100,
39
+ }
40
+ end
25
41
 
26
- expect(environments.size).to eq 2
27
- expect(environments.first).to be_a ::Contentful::Management::Environment
28
- }
42
+ it 'fetches all environments' do
43
+ vcr('environment/all/limit_100') {
44
+ environments = subject.all(params)
45
+
46
+ expect(environments.total).to eq 26
47
+ expect(environments.size).to eq 26
48
+ expect(environments.first).to be_a ::Contentful::Management::Environment
49
+ }
50
+ end
51
+ end
52
+
53
+ context 'given params for pagination offset' do
54
+ let(:params) do
55
+ {
56
+ skip: 25,
57
+ }
58
+ end
59
+
60
+ it 'fetches the second page of environments' do
61
+ vcr('environment/all/skip_25') {
62
+ environments = subject.all(params)
63
+
64
+ expect(environments.size).to eq 1
65
+ expect(environments.total).to eq 26
66
+ expect(environments.first).to be_a ::Contentful::Management::Environment
67
+ }
68
+ end
29
69
  end
30
70
  end
31
71
 
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.0
4
+ version: 3.6.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: 2022-04-26 00:00:00.000000000 Z
13
+ date: 2022-09-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http
@@ -599,6 +599,7 @@ files:
599
599
  - spec/fixtures/vcr_cassettes/entry/publish_already_published.yml
600
600
  - spec/fixtures/vcr_cassettes/entry/published_false.yml
601
601
  - spec/fixtures/vcr_cassettes/entry/published_true.yml
602
+ - spec/fixtures/vcr_cassettes/entry/references.yml
602
603
  - spec/fixtures/vcr_cassettes/entry/reload.yml
603
604
  - spec/fixtures/vcr_cassettes/entry/save_update.yml
604
605
  - spec/fixtures/vcr_cassettes/entry/search_filter/equality_operator.yml
@@ -632,6 +633,8 @@ files:
632
633
  - spec/fixtures/vcr_cassettes/entry/updated_false.yml
633
634
  - spec/fixtures/vcr_cassettes/entry/updated_true.yml
634
635
  - spec/fixtures/vcr_cassettes/environment/all.yml
636
+ - spec/fixtures/vcr_cassettes/environment/all/limit_100.yml
637
+ - spec/fixtures/vcr_cassettes/environment/all/skip_25.yml
635
638
  - spec/fixtures/vcr_cassettes/environment/create.yml
636
639
  - spec/fixtures/vcr_cassettes/environment/create_with_different_source.yml
637
640
  - spec/fixtures/vcr_cassettes/environment/destroy.yml
@@ -1029,6 +1032,7 @@ test_files:
1029
1032
  - spec/fixtures/vcr_cassettes/entry/publish_already_published.yml
1030
1033
  - spec/fixtures/vcr_cassettes/entry/published_false.yml
1031
1034
  - spec/fixtures/vcr_cassettes/entry/published_true.yml
1035
+ - spec/fixtures/vcr_cassettes/entry/references.yml
1032
1036
  - spec/fixtures/vcr_cassettes/entry/reload.yml
1033
1037
  - spec/fixtures/vcr_cassettes/entry/save_update.yml
1034
1038
  - spec/fixtures/vcr_cassettes/entry/search_filter/equality_operator.yml
@@ -1062,6 +1066,8 @@ test_files:
1062
1066
  - spec/fixtures/vcr_cassettes/entry/updated_false.yml
1063
1067
  - spec/fixtures/vcr_cassettes/entry/updated_true.yml
1064
1068
  - spec/fixtures/vcr_cassettes/environment/all.yml
1069
+ - spec/fixtures/vcr_cassettes/environment/all/limit_100.yml
1070
+ - spec/fixtures/vcr_cassettes/environment/all/skip_25.yml
1065
1071
  - spec/fixtures/vcr_cassettes/environment/create.yml
1066
1072
  - spec/fixtures/vcr_cassettes/environment/create_with_different_source.yml
1067
1073
  - spec/fixtures/vcr_cassettes/environment/destroy.yml