summaryrefslogtreecommitdiff
path: root/spec/config/settings_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/config/settings_spec.rb')
-rw-r--r--spec/config/settings_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/config/settings_spec.rb b/spec/config/settings_spec.rb
index 9db3d35cbe5..ed873478fc9 100644
--- a/spec/config/settings_spec.rb
+++ b/spec/config/settings_spec.rb
@@ -112,4 +112,26 @@ RSpec.describe Settings do
end
end
end
+
+ describe '.cron_for_usage_ping' do
+ it 'returns correct crontab for some manually calculated example' do
+ allow(Gitlab::CurrentSettings)
+ .to receive(:uuid) { 'd9e2f4e8-db1f-4e51-b03d-f427e1965c4a'}
+
+ expect(described_class.send(:cron_for_usage_ping)).to eq('21 18 * * 4')
+ end
+
+ it 'returns min, hour, day in the valid range' do
+ allow(Gitlab::CurrentSettings)
+ .to receive(:uuid) { SecureRandom.uuid }
+
+ 10.times do
+ cron = described_class.send(:cron_for_usage_ping).split(/\s/)
+
+ expect(cron[0].to_i).to be_between(0, 59)
+ expect(cron[1].to_i).to be_between(0, 23)
+ expect(cron[4].to_i).to be_between(0, 6)
+ end
+ end
+ end
end