Project

General

Profile

Actions

Bug #18568

closed

KeepParam helper returns Hash (WIA) instead of AC::Parameters on Rails 5

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, 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.

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/4307 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