Skip to content

Commit d58a21f

Browse files
committed
Add date_range fallback tests for nil, 0, and negative settings
1 parent cd90c3a commit d58a21f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

spec/sidekiq/unified_health_data/imaging_refresh_job_spec.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,48 @@
4646
described_class.new.perform(user.uuid)
4747
end
4848

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+
4991
it 'logs successful completion' do
5092
expect(Rails.logger).to receive(:info).with(
5193
'UHD Imaging Refresh Job completed successfully',

0 commit comments

Comments
 (0)