Project

General

Profile

Refactor #18665

Foreman::Controller::Parameters tests should ignore hash/AC::Parameters differences

Added by Dominic Cleal over 5 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Tests
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Under Rails 5.0, the ActionController::Parameters class no longer inherits from Hash and is now its own class that delegates some methods to an internal Hash.

This causes failures in tests for the Foreman::Controller::Parameters::* concerns which have equality assertions on AC::Parameters and hashes, to check the expected filtered output, e.g.

--- expected
+++ actual
@@ -1 +1 @@
-{"plugin_ext"=>"b"}
+<ActionController::Parameters {"plugin_ext"=>"b"} permitted: true>

AC::Parameters has a #to_h method that returns a hash (in both 4.2 and 5.0), so these tests can trivially be updated to call #to_h before comparing the filtered object to a hash.

Associated revisions

Revision 0a54c7f8 (diff)
Added by Dominic Cleal over 5 years ago

fixes #18665 - call #to_h before comparing AC::Parameters to hash

Allows comparisons when ActionController::Parameters is separated from
Hash in Rails 5.0. #permit! is now called on inner hashes sent through
KeepParam (similar to rails/rails@e86524c in 5.1) so they are included
in the #to_h permitted output.

History

#1 Updated by The Foreman Bot over 5 years ago

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

#2 Updated by Dominic Cleal over 5 years ago

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

#3 Updated by Dominic Cleal over 5 years ago

  • Legacy Backlogs Release (now unused) set to 209

Also available in: Atom PDF