Actions::Foreman::Report::Import.cleanup_after parses ActiveSupport::Duration#parts incorrectly
Under Rails 5.0.1, the
Actions::Foreman::Report::Import.cleanup_after method fails to return the correct number of days and fails the existing unit test:
cleanup#test_0001_derive the number of dates based on Report::DEFAULT_EXPIRATION [test/unit/actions/report/import_test.rb:39]:
The code attempts to do
Hash[1.week.parts][:days], but the ActiveSupport::Duration#parts method isn't a very reliable API to determine days from a duration, as it depends on how the duration was constructed. Under Rails 18.104.22.168 it returns
[[:days, 7]] but under Rails 5.0.1 it returns
It should use division of durations or .to_i to be more reliable.