Created
October 11, 2022 18:39
-
-
Save jcreed/81f490239abf5690b016429adcb7d9f1 to your computer and use it in GitHub Desktop.
scheduler run_at
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it '#update_run_at' do | |
s1 = create :schedule, wanted_run_at: '2022-01-25 17:00', run_at: '2022-01-25 17:00', schedule_option: 'monthly' | |
s2 = create :schedule, wanted_run_at: '2022-01-29 17:00', run_at: '2022-01-29 17:00', schedule_option: 'monthly' | |
s3 = create :schedule, wanted_run_at: '2022-01-30 17:00', run_at: '2022-01-30 17:00', schedule_option: 'monthly' | |
s4 = create :schedule, wanted_run_at: '2022-01-31 17:00', run_at: '2022-01-31 17:00', schedule_option: 'monthly' | |
s5 = create :schedule, wanted_run_at: '2024-01-31 17:00', run_at: '2024-01-31 17:00', schedule_option: 'monthly' | |
s6 = create :schedule, wanted_run_at: '2024-01-30 17:00', run_at: '2024-01-30 17:00', schedule_option: 'monthly' | |
s7 = create :schedule, wanted_run_at: '2024-01-29 17:00', run_at: '2024-01-29 17:00', schedule_option: 'monthly' | |
s8 = create :schedule, wanted_run_at: '2024-01-28 17:00', run_at: '2024-01-28 17:00', schedule_option: 'monthly' | |
s9 = create :schedule, wanted_run_at: '2024-01-31 17:00', run_at: '2024-01-28 17:00', schedule_option: 'daily' | |
s10 = create :schedule, wanted_run_at: '2024-01-30 17:00', run_at: '2024-01-28 17:00', schedule_option: 'weekly' | |
s11 = create :schedule, wanted_run_at: '2023-01-30 17:00', run_at: '2023-01-30 17:00', schedule_option: 'monthly' | |
s1_results = %w(2022-02-25\ 17:00:00:000 2022-03-25\ 17:00:00:000 2022-04-25\ 17:00:00:000 | |
2022-05-25\ 17:00:00:000 2022-06-25\ 17:00:00:000 2022-07-25\ 17:00:00:000 2022-08-25\ 17:00:00:000 | |
2022-09-25\ 17:00:00:000 | |
2022-10-25\ 17:00:00:000 2022-11-25\ 17:00:00:000 2022-12-25\ 17:00:00:000 2023-01-25\ 17:00:00:000 | |
2023-02-25\ 17:00:00:000) | |
s1_results.each do |date| | |
s1.update_run_at | |
s1.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s2_results = %w(2022-02-28\ 17:00:00:000 2022-03-29\ 17:00:00:000 2022-04-29\ 17:00:00:000 | |
2022-05-29\ 17:00:00:000 2022-06-29\ 17:00:00:000 2022-07-29\ 17:00:00:000 2022-08-29\ 17:00:00:000 | |
2022-09-29\ 17:00:00:000 | |
2022-10-29\ 17:00:00:000 2022-11-29\ 17:00:00:000 2022-12-29\ 17:00:00:000 2023-01-29\ 17:00:00:000 | |
2023-02-28\ 17:00:00:000) | |
s2_results.each do |date| | |
s2.update_run_at | |
s2.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s3_results = %w(2022-02-28\ 17:00:00:000 2022-03-30\ 17:00:00:000 2022-04-30\ 17:00:00:000 | |
2022-05-30\ 17:00:00:000 2022-06-30\ 17:00:00:000 2022-07-30\ 17:00:00:000 2022-08-30\ 17:00:00:000 | |
2022-09-30\ 17:00:00:000 | |
2022-10-30\ 17:00:00:000 2022-11-30\ 17:00:00:000 2022-12-30\ 17:00:00:000 2023-01-30\ 17:00:00:000 | |
2023-02-28\ 17:00:00:000) | |
s3_results.each do |date| | |
s3.update_run_at | |
s3.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s4_results = %w(2022-02-28\ 17:00:00:000 2022-03-31\ 17:00:00:000 2022-04-30\ 17:00:00:000 | |
2022-05-31\ 17:00:00:000 2022-06-30\ 17:00:00:000 2022-07-31\ 17:00:00:000 2022-08-31\ 17:00:00:000 | |
2022-09-30\ 17:00:00:000 | |
2022-10-31\ 17:00:00:000 2022-11-30\ 17:00:00:000 2022-12-31\ 17:00:00:000 2023-01-31\ 17:00:00:000 | |
2023-02-28\ 17:00:00:000) | |
s4_results.each do |date| | |
s4.update_run_at | |
s4.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s5_results = %w(2024-02-29\ 17:00:00:000 2024-03-31\ 17:00:00:000 2024-04-30\ 17:00:00:000 | |
2024-05-31\ 17:00:00:000 2024-06-30\ 17:00:00:000 2024-07-31\ 17:00:00:000 2024-08-31\ 17:00:00:000 | |
2024-09-30\ 17:00:00:000 | |
2024-10-31\ 17:00:00:000 2024-11-30\ 17:00:00:000 2024-12-31\ 17:00:00:000 2025-01-31\ 17:00:00:000 | |
2025-02-28\ 17:00:00:000) | |
s5_results.each do |date| | |
s5.update_run_at | |
s5.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s6_results = %w(2024-02-29\ 17:00:00:000 2024-03-30\ 17:00:00:000 2024-04-30\ 17:00:00:000 | |
2024-05-30\ 17:00:00:000 2024-06-30\ 17:00:00:000 2024-07-30\ 17:00:00:000 2024-08-30\ 17:00:00:000 | |
2024-09-30\ 17:00:00:000 | |
2024-10-30\ 17:00:00:000 2024-11-30\ 17:00:00:000 2024-12-30\ 17:00:00:000 2025-01-30\ 17:00:00:000 | |
2025-02-28\ 17:00:00:000) | |
s6_results.each do |date| | |
s6.update_run_at | |
s6.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s7_results = %w(2024-02-29\ 17:00:00:000 2024-03-29\ 17:00:00:000 2024-04-29\ 17:00:00:000 | |
2024-05-29\ 17:00:00:000 2024-06-29\ 17:00:00:000 2024-07-29\ 17:00:00:000 2024-08-29\ 17:00:00:000 | |
2024-09-29\ 17:00:00:000 | |
2024-10-29\ 17:00:00:000 2024-11-29\ 17:00:00:000 2024-12-29\ 17:00:00:000 2025-01-29\ 17:00:00:000 | |
2025-02-28\ 17:00:00:000) | |
s7_results.each do |date| | |
s7.update_run_at | |
s7.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s8_results = %w(2024-02-28\ 17:00:00:000 2024-03-28\ 17:00:00:000 2024-04-28\ 17:00:00:000 | |
2024-05-28\ 17:00:00:000 2024-06-28\ 17:00:00:000 2024-07-28\ 17:00:00:000 2024-08-28\ 17:00:00:000 | |
2024-09-28\ 17:00:00:000 | |
2024-10-28\ 17:00:00:000 2024-11-28\ 17:00:00:000 2024-12-28\ 17:00:00:000 2025-01-28\ 17:00:00:000 | |
2025-02-28\ 17:00:00:000 2025-03-28\ 17:00:00:000) | |
s8_results.each do |date| | |
s8.update_run_at | |
s8.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s9_results = %w(2024-01-29\ 17:00:00:000 2024-01-30\ 17:00:00:000 2024-01-31\ 17:00:00:000 | |
2024-02-01\ 17:00:00:000) | |
s9_results.each do |date| | |
s9.update_run_at | |
s9.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s10_results = %w(2024-02-04\ 17:00:00:000 2024-02-11\ 17:00:00:000 2024-02-18\ 17:00:00:000 | |
2024-02-25\ 17:00:00:000 2024-03-03\ 17:00:00:000) | |
s10_results.each do |date| | |
s10.update_run_at | |
s10.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
s11_results = %w(2023-02-28\ 17:00:00:000 2023-03-30\ 17:00:00:000 2023-04-30\ 17:00:00:000 | |
2023-05-30\ 17:00:00:000 2023-06-30\ 17:00:00:000 2023-07-30\ 17:00:00:000 2023-08-30\ 17:00:00:000 | |
2023-09-30\ 17:00:00:000 | |
2023-10-30\ 17:00:00:000 2023-11-30\ 17:00:00:000 2023-12-30\ 17:00:00:000 2024-01-30\ 17:00:00:000 | |
2024-02-29\ 17:00:00:000) | |
s11_results.each do |date| | |
s11.update_run_at | |
s11.reload.run_at.strftime('%Y-%m-%d %H:%M:%S:%L').must_equal date | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment