Refactor #18982
closedRefactor params hash iteration in Api::CompatibilityChecker#check_create_host_nested
Description
Api::CompatibilityChecker#check_create_host_nested iterates over nested attributes in a params hash and should work for both arrays and hash styles of nested attrs, but it does so using a single each
call yielding a single argument.
This works on Rails 4 where ActionController::Parameters inherits each
from a Hash, as an array of [key, value]
would be yielded instead, which the block checks for (attribute[1] if attribute.is_a?(Array)
).
In Rails 5.0, AC::Parameters has its own each
implementation that only yields to two arguments. Using each do |attribute|
will instead be yielded only the key name. This causes:
Api::V2::HostsControllerTest#test_0010_should create host with host_parameters_attributes sent in a hash [test/controllers/api/v2/hosts_controller_test.rb:186]: "Host.count" didn't change by 1. Expected: 2 Actual: 1
The iteration should be handled differently for arrays and AC::Parameters/hashes.
Updated by The Foreman Bot over 7 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/4399 added
Updated by Dominic Cleal over 7 years ago
- Blocks Feature #19050: Add support for running under Ruby on Rails 5.0 added
Updated by Dominic Cleal over 7 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset c16852918b3ad15de4c51db3b4b38a91383d2375.
Updated by Marek Hulán almost 7 years ago
- Translation missing: en.field_release set to 240