Refactor #16243
Remove required `options` argument to Host::Managed.new
Description
The second "options" hash argument to a model .new method no longer exists on Rails 5 (due to no protected_attrs support?), so Host::Managed#initialize should handle it being present or not.
The hash isn't used directly by initialize, only Rails. Host::Base already does this using a splat operator.
ArgumentError: wrong number of arguments (given 2, expected 0..1) activerecord (5.0.0) lib/active_record/core.rb:312:in `initialize' app/models/host/base.rb:82:in `initialize' actionpack (5.0.0) lib/action_dispatch/routing/url_for.rb:106:in `initialize' app/models/host/managed.rb:47:in `initialize' activerecord (5.0.0) lib/active_record/inheritance.rb:65:in `new' activerecord (5.0.0) lib/active_record/inheritance.rb:65:in `new' app/models/concerns/foreman/sti.rb:22:in `new_with_cast' app/models/host.rb:15:in `method_missing' factory_girl (4.7.0) lib/factory_girl/decorator/new_constructor.rb:9:in `new'
Associated revisions
History
#1
Updated by The Foreman Bot almost 6 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/3768 added
#2
Updated by Dominic Cleal almost 6 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 8e780e97b1651e778722a82a9a8d2d8e5cdb351b.
#3
Updated by Dominic Cleal almost 6 years ago
- Legacy Backlogs Release (now unused) set to 160
fixes #16243 - make Host::Managed.new's options arg optional
The options argument no longer exists on Rails 5 as it was part of the
support for protected_attrs. The argument list to .new should be handled
more defensively, like Host::Base.