-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] fix association between EMS and ConfigurationSystem #16798
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is good, but are you going to move the rest of the relations as well? I would have expected that in the same PR.
@bdunne yes, that's what I am looking, seems like all the following,
|
Checked commits jameswnl/manageiq@7207258~...832f547 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 app/models/ext_management_system.rb
|
@@ -29,6 +29,11 @@ def self.supported_types_and_descriptions_hash | |||
|
|||
belongs_to :provider | |||
has_many :child_managers, :class_name => 'ExtManagementSystem', :foreign_key => 'parent_ems_id' | |||
has_many :configured_systems, :dependent => :destroy, :foreign_key => "manager_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it was on purpose, that the relations were only on automation_manager, we do the same for cloud_manager, etc.
I think the base of you failing specs is that the mock data are not valid. Each model has to have a correctly filled STI type, like it always has when it comes from a refresh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, true that the failing specs can be fixed by using the corresponding factory for automation_manager
.
But what I have question about is that, why on one side we define the relationship in base class ExtManagementSystem
and the other side in the subclass AutomationManager
? Is this a proper practice in rails?
The other point is that: If the concept of a EMS
has many ConfiguredSystem
is valid at base class level, we should be able to test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm so I think the idea was to have manager specific relations only under the specific manager, e.g. cloud manager https://github.com/Ladas/manageiq/blob/be7d05ca1089fa0c06802c2bfa666d5b9e10f455/app/models/manageiq/providers/cloud_manager.rb#L17
Then the relations would not work, unless the proper STI types are set, so all specs have to set them right.
But I've seen that e.g. if relation is shared by more types of managers, it goes to ext_management_system.rb. Which is your case, so this should be acceptable.
Or e.g. for complex virtual attributes, it easier to have the relation on base class, otherwise it might give unexpected results.
I think the consensus is that this is not needed in the base model since configured_system makes no sense for infra/cloud/physical/network/etc... managers. |
The association is wrong and should be all set in their own base classes.