Actions
Bug #18568
closedKeepParam helper returns Hash (WIA) instead of AC::Parameters on Rails 5
Description
Under Rails 5, the KeepParam controller concern isn't functioning correctly, causing test failures such as:
Error: ComputeAttributesControllerTest#test_0004_should update compute_attribute: ActiveRecord::SerializationTypeMismatch: Attribute was supposed to be a Hash, but was a ActionController::Parameters. -- <ActionController::Parameters {"flavor_id"=>"t2.medium"} permitted: true> app/controllers/compute_attributes_controller.rb:24:in `update' app/controllers/concerns/application_shared.rb:14:in `set_timezone' app/models/concerns/foreman/thread_session.rb:32:in `clear_thread' test/controllers/compute_attributes_controller_test.rb:37:in `block in <class:ComputeAttributesControllerTest>'
The return value of the keep_param
method has changed to a HWIA from AC::Parameters, as can be seen by extending its unit test:
Failure: KeepParamParametersTest#test_0001_retains parameter within top-level hash [/home/dcleal/code/foreman/foreman/test/unit/concerns/parameters/keep_param_test.rb:9]: Expected {"login"=>"foo"} to be a kind of ActionController::Parameters, not ActiveSupport::HashWithIndifferentAccess.
The root cause is a bug in Rails 5.0 (caused by https://github.com/rails/rails/commit/14a3bd5) where AC::Parameters#update now returns a HWIA instead of an AC::Parameters instance.
Since #update is deprecated in 5.0 (being a Hash method), refactoring this to use the #[]= setter will fix both the bug and future deprecation.
Updated by The Foreman Bot almost 8 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/4307 added
Updated by Dominic Cleal almost 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset e63d01231b411bb7fcc12875167d2d1bbeec8757.
Updated by Dominic Cleal almost 8 years ago
- Translation missing: en.field_release set to 209
Actions