Bug 2002533

Summary: Child hostgroup shows wrong "inherit parent" value in the selection options
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Host GroupAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.9.0CC: inecas, jalviso, kgaikwad, satellite6-bugs
Target Milestone: UnspecifiedKeywords: EasyFix, Patch, Triaged
Target Release: UnusedFlags: jalviso: needinfo? (satellite6-bugs)
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Hao Chang Yu 2021-09-09 06:30:12 UTC
Description of problem:
If a child host group attribute is not currently inherit from the parent host group. The selection option will show the incorrect "inherit parent" value.


Steps to Reproduce:
1. In web ui, Create a parent host group and set the "Deploy On" to a compute resource. For example, "Brisbane Vcenter"
2. In web ui, Create a child host group and set the "Deploy On" to a different compute resource. For example, "Sydney Vcenter".
3. After creating the child host group. Edit the child host group, click the "Deploy on" select box

Actual results:
It is showing "Inherit parent (Sydney Vcenter)".

Expected results:
It should be showing "Inherit parent (Brisbane Vcenter)

Additional info:

Make the following change seems to fix the issue

--- a/helpers/form_helper.rb	2021-09-09 16:22:49.684921775 +1000
+++ b/helpers/form_helper.rb	2021-09-09 16:23:05.679076650 +1000
@@ -345,7 +345,7 @@
 
   def blank_or_inherit_f(f, attr, blank_value: _("no value"))
     return true unless f.object.respond_to?(:parent_id) && f.object.parent_id
-    inherited_value   = f.object.send(attr)
+    inherited_value   = f.object.respond_to?(:nested) ? f.object.nested(attr) : f.object.send(attr)
     inherited_value   = inherited_value.name_method if inherited_value.present? && inherited_value.respond_to?(:name_method)
     inherited_value ||= blank_value
     _("Inherit parent (%s)") % inherited_value