Project

General

Profile

Refactor #16243

Remove required `options` argument to Host::Managed.new

Added by Dominic Cleal almost 4 years ago. Updated about 2 years ago.

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

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

Revision 8e780e97 (diff)
Added by Dominic Cleal almost 4 years ago

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.

History

#1 Updated by The Foreman Bot almost 4 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 4 years ago

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

#3 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) set to 160

Also available in: Atom PDF