|
22 | 22 | ) |
23 | 23 | end |
24 | 24 |
|
| 25 | + context 'without a request log retention policy' do |
| 26 | + let(:account) { create(:account, plan: build(:plan, :ent, request_log_retention_duration: nil)) } |
| 27 | + |
| 28 | + it 'should prune backlog' do |
| 29 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 91).days.ago) |
| 30 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 90).days.ago) |
| 31 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 31).days.ago) |
| 32 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 30).days.ago) |
| 33 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 1).days.ago) |
| 34 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS - 1).days.ago) |
| 35 | + |
| 36 | + expect { worker.perform_async }.to( |
| 37 | + change { account.request_logs.count }.from(300).to(50), |
| 38 | + ) |
| 39 | + end |
| 40 | + end |
| 41 | + |
25 | 42 | context 'with a request log retention policy' do |
26 | | - let(:account) { create(:account, plan: build(:plan, :ent, request_log_retention_duration: (worker::BACKLOG_DAYS + 30).days)) } |
| 43 | + let(:account) { create(:account, plan: build(:plan, :ent, request_log_retention_duration: (worker::BACKLOG_DAYS + 90).days)) } |
27 | 44 |
|
28 | 45 | it 'should prune according to retention policy' do |
| 46 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 91).days.ago) |
| 47 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 90).days.ago) |
29 | 48 | create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 31).days.ago) |
30 | | - create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 29).days.ago) |
| 49 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 30).days.ago) |
31 | 50 | create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 1).days.ago) |
32 | 51 | create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS - 1).days.ago) |
33 | 52 |
|
34 | 53 | expect { worker.perform_async }.to( |
35 | | - change { account.request_logs.count }.from(200).to(150), |
| 54 | + change { account.request_logs.count }.from(300).to(250), |
36 | 55 | ) |
37 | 56 | end |
38 | 57 | end |
|
51 | 70 | ) |
52 | 71 | end |
53 | 72 |
|
| 73 | + context 'without a request log retention policy' do |
| 74 | + let(:account) { create(:account, plan: build(:plan, :std, request_log_retention_duration: nil)) } |
| 75 | + |
| 76 | + it 'should prune backlog' do |
| 77 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 91).days.ago) |
| 78 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 90).days.ago) |
| 79 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 31).days.ago) |
| 80 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 29).days.ago) |
| 81 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 1).days.ago) |
| 82 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS - 1).days.ago) |
| 83 | + |
| 84 | + expect { worker.perform_async }.to( |
| 85 | + change { account.request_logs.count }.from(300).to(50), |
| 86 | + ) |
| 87 | + end |
| 88 | + end |
| 89 | + |
54 | 90 | context 'with a request log retention policy' do |
55 | | - let(:account) { create(:account, plan: build(:plan, :std, request_log_retention_duration: (worker::BACKLOG_DAYS + 3).days)) } |
| 91 | + let(:account) { create(:account, plan: build(:plan, :std, request_log_retention_duration: (worker::BACKLOG_DAYS + 30).days)) } |
56 | 92 |
|
57 | 93 | it 'should prune according to retention policy' do |
58 | | - create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 4).days.ago) |
59 | | - create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 3).days.ago) |
| 94 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 91).days.ago) |
| 95 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 90).days.ago) |
| 96 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 31).days.ago) |
| 97 | + create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 29).days.ago) |
60 | 98 | create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 1).days.ago) |
61 | 99 | create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS - 1).days.ago) |
62 | 100 |
|
63 | 101 | expect { worker.perform_async }.to( |
64 | | - change { account.request_logs.count }.from(200).to(50), |
| 102 | + change { account.request_logs.count }.from(300).to(150), |
65 | 103 | ) |
66 | 104 | end |
67 | 105 | end |
|
0 commit comments