|
65 | 65 | let!(:bounced_submission) { create :submission, :bounced, form_id: } |
66 | 66 | let!(:another_bounced_submission) { create :submission, :bounced, form_id: } |
67 | 67 | let!(:bounced_daily_delivery) { create :delivery, :failed, :daily_scheduled_delivery, submissions: [bounced_submission, another_bounced_submission] } |
| 68 | + let!(:bounced_weekly_delivery) { create :delivery, :failed, :weekly_scheduled_delivery, submissions: [bounced_submission, another_bounced_submission] } |
68 | 69 |
|
69 | 70 | before do |
70 | 71 | # create some submissions that won't be matched |
|
73 | 74 | end |
74 | 75 |
|
75 | 76 | it "logs the bounced submissions" do |
76 | | - expect(Rails.logger).to receive(:info).with("Found 3 bounced submission deliveries for form with ID #{form_id}") |
| 77 | + expect(Rails.logger).to receive(:info).with("Found 4 bounced submission deliveries for form with ID #{form_id}") |
77 | 78 | expect(Rails.logger).to receive(:info).with "Immediate delivery - submission reference: #{bounced_submission.reference}, created_at: #{bounced_submission.created_at}, last_attempt_at: #{bounced_submission.single_submission_delivery.last_attempt_at}" |
78 | 79 | expect(Rails.logger).to receive(:info).with "Immediate delivery - submission reference: #{another_bounced_submission.reference}, created_at: #{another_bounced_submission.created_at}, last_attempt_at: #{another_bounced_submission.single_submission_delivery.last_attempt_at}" |
79 | 80 | expect(Rails.logger).to receive(:info).with "Daily batch delivery - delivery_reference: #{bounced_daily_delivery.delivery_reference}, created_at: #{bounced_daily_delivery.created_at}, last_attempt_at: #{bounced_daily_delivery.last_attempt_at}" |
| 81 | + expect(Rails.logger).to receive(:info).with "Weekly batch delivery - delivery_reference: #{bounced_weekly_delivery.delivery_reference}, created_at: #{bounced_weekly_delivery.created_at}, last_attempt_at: #{bounced_weekly_delivery.last_attempt_at}" |
80 | 82 | task.invoke(form_id) |
81 | 83 | end |
82 | 84 | end |
|
91 | 93 | let(:other_form_id) { 2 } |
92 | 94 | let!(:bounced_submission) { create :submission, :bounced, form_id: } |
93 | 95 | let!(:pending_submission) { create :submission, :sent, form_id: } |
94 | | - let!(:bounced_delivery) { create :delivery, :daily_scheduled_delivery, :failed, submissions: [bounced_submission] } |
| 96 | + let!(:bounced_daily_delivery) { create :delivery, :daily_scheduled_delivery, :failed, submissions: [bounced_submission] } |
| 97 | + let!(:bounced_weekly_delivery) { create :delivery, :weekly_scheduled_delivery, :failed, submissions: [bounced_submission] } |
95 | 98 |
|
96 | 99 | before do |
97 | 100 | create :submission, :sent, form_id: other_form_id |
|
102 | 105 |
|
103 | 106 | it "logs how many deliveries to retry" do |
104 | 107 | allow(Rails.logger).to receive(:info) |
105 | | - expect(Rails.logger).to receive(:info).with("2 deliveries to retry for form with ID: #{form_id}") |
| 108 | + expect(Rails.logger).to receive(:info).with("3 deliveries to retry for form with ID: #{form_id}") |
106 | 109 |
|
107 | 110 | task.invoke(*valid_args) |
108 | 111 | end |
|
111 | 114 | it "logs submissions that are being retried" do |
112 | 115 | allow(Rails.logger).to receive(:info) |
113 | 116 | expect(Rails.logger).to receive(:info).with("Retrying submission with reference #{bounced_submission.reference} for form with ID: #{form_id}") |
114 | | - expect(Rails.logger).to receive(:info).with("Retrying daily batch delivery with delivery_id: #{bounced_delivery.id} for date: #{bounced_submission.submission_time.to_date} for form with ID: #{form_id}") |
| 117 | + expect(Rails.logger).to receive(:info).with("Retrying daily batch delivery with delivery_id: #{bounced_daily_delivery.id} for date: #{bounced_daily_delivery.batch_begin_at.to_date} for form with ID: #{form_id}") |
| 118 | + expect(Rails.logger).to receive(:info).with("Retrying weekly batch delivery with delivery_id: #{bounced_weekly_delivery.id} for week starting: #{bounced_weekly_delivery.batch_begin_at.to_date} for form with ID: #{form_id}") |
115 | 119 |
|
116 | 120 | task.invoke(*valid_args) |
117 | 121 | end |
|
125 | 129 | it "enqueues bounced daily deliveries for retrying" do |
126 | 130 | expect { |
127 | 131 | task.invoke(*valid_args) |
128 | | - }.to have_enqueued_job.with(delivery: bounced_delivery) |
| 132 | + }.to have_enqueued_job.with(delivery: bounced_daily_delivery) |
129 | 133 | end |
130 | 134 |
|
131 | 135 | it "does not enqueue pending submissions for retrying" do |
|
0 commit comments