contentful-management 3.5.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')
@@ -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.5.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-06-15 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
@@ -633,6 +633,8 @@ files:
633
633
  - spec/fixtures/vcr_cassettes/entry/updated_false.yml
634
634
  - spec/fixtures/vcr_cassettes/entry/updated_true.yml
635
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
636
638
  - spec/fixtures/vcr_cassettes/environment/create.yml
637
639
  - spec/fixtures/vcr_cassettes/environment/create_with_different_source.yml
638
640
  - spec/fixtures/vcr_cassettes/environment/destroy.yml
@@ -1064,6 +1066,8 @@ test_files:
1064
1066
  - spec/fixtures/vcr_cassettes/entry/updated_false.yml
1065
1067
  - spec/fixtures/vcr_cassettes/entry/updated_true.yml
1066
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
1067
1071
  - spec/fixtures/vcr_cassettes/environment/create.yml
1068
1072
  - spec/fixtures/vcr_cassettes/environment/create_with_different_source.yml
1069
1073
  - spec/fixtures/vcr_cassettes/environment/destroy.yml