Project

General

Profile

Refactor #13039

Remove DB queries from class of UnattendedController

Added by Dominic Cleal over 3 years ago. Updated about 1 year ago.

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

Description

UnattendedController makes DB queries for TemplateKinds in the class scope to define methods and set up action filters. This bad style causes a problem in foreman_bootdisk which adds a method chain to the provision method in the class. When running tests under Rails 4, if the controller's instantiated too early, the right methods aren't defined.

  4) Error:
UnattendedControllerTest#test_0002_should get a kickstart even if not using the first NIC:
AbstractController::ActionNotFound: The action 'provision' could not be found for UnattendedController
    test/functional/unattended_controller_test.rb:43:in `block in <class:UnattendedControllerTest>'

Changing this to make queries when it's called would create more testable code both in core and the plugin.


Related issues

Related to Foreman - Refactor #13409: Remove maintain_test_schema! Rails initializerClosed2016-01-27
Related to Foreman - Bug #15490: CVE-2016-4995 - view_hosts permissions/filters not checked for provisioning template previewsClosed2016-06-22
Related to Foreman - Bug #10689: Unattended controller permission check does not workDuplicate2015-06-03

Associated revisions

Revision b1997f52 (diff)
Added by Dominic Cleal over 3 years ago

fixes #13039 - remove TemplateKind DB calls from UnattendedCtlr

UnattendedController created actions/methods during initialisation per
known TemplateKind, relying on the DB being populated. This caused
ordering issues when a plugin loaded the controller in a test
environment as the kinds weren't yet in the DB. The actions then were
not created.

The per-TemplateKind actions have been simplified to one fixed action
which is routed in the same way.

History

#1 Updated by The Foreman Bot over 3 years ago

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

#2 Updated by Dominic Cleal over 3 years ago

  • Legacy Backlogs Release (now unused) set to 71

#3 Updated by Dominic Cleal over 3 years ago

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

#4 Updated by Dominic Cleal over 3 years ago

  • Related to Refactor #13409: Remove maintain_test_schema! Rails initializer added

#5 Updated by Dominic Cleal about 3 years ago

  • Related to Bug #15490: CVE-2016-4995 - view_hosts permissions/filters not checked for provisioning template previews added

#6 Updated by Dominic Cleal about 3 years ago

  • Related to Bug #10689: Unattended controller permission check does not work added

#7 Updated by Bryan Kearney about 3 years ago

  • Bugzilla link set to 1201676

Also available in: Atom PDF