Project

General

Profile

Actions

Bug #18157

closed

Actions::Foreman::Report::Import.cleanup_after parses ActiveSupport::Duration#parts incorrectly

Added by Dominic Cleal about 7 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

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]:
Expected: "7d"
Actual: "d"

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 4.2.7.1 it returns [[:days, 7]] but under Rails 5.0.1 it returns [[:weeks, 1]].

It should use division of durations or .to_i to be more reliable.

Actions #1

Updated by The Foreman Bot about 7 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4209 added
Actions #2

Updated by Dominic Cleal about 7 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #3

Updated by Dominic Cleal about 7 years ago

  • translation missing: en.field_release set to 209
Actions

Also available in: Atom PDF