|
46 | 46 | described_class.new.perform(user.uuid) |
47 | 47 | end |
48 | 48 |
|
| 49 | + it 'falls back to 180 days when setting is nil' do |
| 50 | + allow(Settings.mhv.uhd).to receive(:imaging_logging_date_range_days).and_return(nil) |
| 51 | + |
| 52 | + end_date = Date.current |
| 53 | + start_date = end_date - 180.days |
| 54 | + |
| 55 | + expect(imaging_service).to receive(:get_imaging_studies).with( |
| 56 | + start_date: start_date.strftime('%Y-%m-%d'), |
| 57 | + end_date: end_date.strftime('%Y-%m-%d') |
| 58 | + ) |
| 59 | + |
| 60 | + described_class.new.perform(user.uuid) |
| 61 | + end |
| 62 | + |
| 63 | + it 'falls back to 180 days when setting is 0' do |
| 64 | + allow(Settings.mhv.uhd).to receive(:imaging_logging_date_range_days).and_return(0) |
| 65 | + |
| 66 | + end_date = Date.current |
| 67 | + start_date = end_date - 180.days |
| 68 | + |
| 69 | + expect(imaging_service).to receive(:get_imaging_studies).with( |
| 70 | + start_date: start_date.strftime('%Y-%m-%d'), |
| 71 | + end_date: end_date.strftime('%Y-%m-%d') |
| 72 | + ) |
| 73 | + |
| 74 | + described_class.new.perform(user.uuid) |
| 75 | + end |
| 76 | + |
| 77 | + it 'falls back to 180 days when setting is negative' do |
| 78 | + allow(Settings.mhv.uhd).to receive(:imaging_logging_date_range_days).and_return(-5) |
| 79 | + |
| 80 | + end_date = Date.current |
| 81 | + start_date = end_date - 180.days |
| 82 | + |
| 83 | + expect(imaging_service).to receive(:get_imaging_studies).with( |
| 84 | + start_date: start_date.strftime('%Y-%m-%d'), |
| 85 | + end_date: end_date.strftime('%Y-%m-%d') |
| 86 | + ) |
| 87 | + |
| 88 | + described_class.new.perform(user.uuid) |
| 89 | + end |
| 90 | + |
49 | 91 | it 'logs successful completion' do |
50 | 92 | expect(Rails.logger).to receive(:info).with( |
51 | 93 | 'UHD Imaging Refresh Job completed successfully', |
|
0 commit comments