|
134 | 134 | end |
135 | 135 |
|
136 | 136 | describe '#export_submission_on_status_change' do |
137 | | - let(:export_location) { create(:export_location, :with_submissions_endpoint) } |
138 | | - let(:export_service) { instance_double(ExportSubmissionService) } |
139 | | - |
| 137 | + # CP-12761: ExportSubmissionService is disabled - submission sync migrated to webhooks. |
| 138 | + # These tests verify the service is not called on any status change. |
140 | 139 | before do |
141 | | - allow(ExportLocation).to receive(:default_location).and_return(export_location) |
142 | | - allow(ExportSubmissionService).to receive(:new).with(submission).and_return(export_service) |
143 | | - allow(export_service).to receive(:call).and_return(true) |
| 140 | + allow(ExportSubmissionService).to receive(:new) |
144 | 141 | end |
145 | 142 |
|
146 | | - context 'when status-related field changes' do |
147 | | - it 'calls ExportSubmissionService when completed_at changes' do |
148 | | - submitter.update!(completed_at: Time.current) |
149 | | - expect(ExportSubmissionService).to have_received(:new).with(submission) |
150 | | - expect(export_service).to have_received(:call) |
151 | | - end |
152 | | - |
153 | | - it 'calls ExportSubmissionService when declined_at changes' do |
154 | | - submitter.update!(declined_at: Time.current) |
155 | | - expect(ExportSubmissionService).to have_received(:new).with(submission) |
156 | | - expect(export_service).to have_received(:call) |
157 | | - end |
158 | | - |
159 | | - it 'calls ExportSubmissionService when opened_at changes' do |
160 | | - submitter.update!(opened_at: Time.current) |
161 | | - expect(ExportSubmissionService).to have_received(:new).with(submission) |
162 | | - expect(export_service).to have_received(:call) |
163 | | - end |
164 | | - |
165 | | - it 'calls ExportSubmissionService when sent_at changes' do |
166 | | - submitter.update!(sent_at: Time.current) |
167 | | - expect(ExportSubmissionService).to have_received(:new).with(submission) |
168 | | - expect(export_service).to have_received(:call) |
169 | | - end |
| 143 | + it 'does not call ExportSubmissionService when completed_at changes' do |
| 144 | + submitter.update!(completed_at: Time.current) |
| 145 | + expect(ExportSubmissionService).not_to have_received(:new) |
170 | 146 | end |
171 | 147 |
|
172 | | - context 'when non-status field changes' do |
173 | | - it 'does not call ExportSubmissionService when email changes' do |
174 | | - submitter.update!(email: 'new@example.com') |
175 | | - expect(ExportSubmissionService).not_to have_received(:new) |
176 | | - expect(export_service).not_to have_received(:call) |
177 | | - end |
178 | | - |
179 | | - it 'does not call ExportSubmissionService when name changes' do |
180 | | - submitter.update!(name: 'New Name') |
181 | | - expect(ExportSubmissionService).not_to have_received(:new) |
182 | | - expect(export_service).not_to have_received(:call) |
183 | | - end |
| 148 | + it 'does not call ExportSubmissionService when declined_at changes' do |
| 149 | + submitter.update!(declined_at: Time.current) |
| 150 | + expect(ExportSubmissionService).not_to have_received(:new) |
184 | 151 | end |
185 | 152 |
|
186 | | - context 'when export service raises an error' do |
187 | | - before do |
188 | | - allow(export_service).to receive(:call).and_raise(StandardError.new('Export failed')) |
189 | | - allow(Rails.logger).to receive(:error) |
190 | | - end |
191 | | - |
192 | | - it 'logs the error and does not re-raise' do |
193 | | - expect { submitter.update!(completed_at: Time.current) }.not_to raise_error |
194 | | - expect(Rails.logger).to have_received(:error).with( |
195 | | - 'Failed to export submission on status change: Export failed' |
196 | | - ) |
197 | | - end |
198 | | - end |
199 | | - |
200 | | - context 'when ExportLocation.default_location returns nil' do |
201 | | - before do |
202 | | - allow(ExportLocation).to receive(:default_location).and_return(nil) |
203 | | - allow(export_service).to receive(:call).and_return(false) |
204 | | - end |
205 | | - |
206 | | - it 'calls ExportSubmissionService but service handles nil export location' do |
207 | | - submitter.update!(completed_at: Time.current) |
208 | | - expect(ExportSubmissionService).to have_received(:new).with(submission) |
209 | | - expect(export_service).to have_received(:call) |
210 | | - end |
| 153 | + it 'does not call ExportSubmissionService when opened_at changes' do |
| 154 | + submitter.update!(opened_at: Time.current) |
| 155 | + expect(ExportSubmissionService).not_to have_received(:new) |
211 | 156 | end |
212 | 157 |
|
213 | | - context 'when export location has no submissions_endpoint' do |
214 | | - before do |
215 | | - allow(export_location).to receive(:submissions_endpoint).and_return(nil) |
216 | | - allow(export_service).to receive(:call).and_return(false) |
217 | | - end |
218 | | - |
219 | | - it 'calls ExportSubmissionService but service handles missing endpoint' do |
220 | | - submitter.update!(completed_at: Time.current) |
221 | | - expect(ExportSubmissionService).to have_received(:new).with(submission) |
222 | | - expect(export_service).to have_received(:call) |
223 | | - end |
| 158 | + it 'does not call ExportSubmissionService when sent_at changes' do |
| 159 | + submitter.update!(sent_at: Time.current) |
| 160 | + expect(ExportSubmissionService).not_to have_received(:new) |
224 | 161 | end |
225 | 162 | end |
226 | 163 |
|
|
0 commit comments