Bug #14458
closedTaxonomy search should search with STI base class
Description
When searching with taxonomy scope, We are looking by model name. This may cause no results if the model is an STI child as the inner_select method adds the model.name (ArfReport) and not the base class name ("Report", which is what is saved in the taxable_taxonomies).
https://github.com/theforeman/foreman/blob/develop/app/models/concerns/taxonomix.rb#L99-L113
A possible solution: condition should change to self.base_class.name
If it is an STI it will call the parent name. If not an STI, it will call itself (current behavior).
Example: https://github.com/theforeman/foreman_openscap/pull/157/files#diff-219a837adc650cf4c4ceae3c8a76eb7dR176
Updated by Marek Hulán over 8 years ago
- Tracker changed from Refactor to Bug
- Status changed from New to Assigned
- Assignee set to Marek Hulán
This was found in foreman_openscap plugin to get an idea you could imagine the issue with core models like this
User.current = User.first
Organization.current = Organization.first
Location.current = Location.first
# loads all libvirts associated with first org and loc
# through TaxableTaxonomy which has column taxable_type that
# specifies object class - Foreman::Model::Libvirt in this case
Foreman::Model::Libvirt.all
supposing you have some libvirt associated to selected orgs and locs you'll still see [] as result since it uses Foreman::Model::Libvirt for taxable_type column in SQL query. Well, in this case it actually works because Taxonomix is included in ComputeResource directly so the same name is stored in taxable_type but if you think about model that is inherited in a plugin and adds taxonomies, it does not work.
Updated by The Foreman Bot over 8 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/3389 added
Updated by Marek Hulán over 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset d96297b17f55469e3c49c90979cbd004d80f461c.
Updated by Dominic Cleal over 8 years ago
- Translation missing: en.field_release set to 141
Updated by Marek Hulán over 8 years ago
- Related to Bug #14446: compliance reports from a particular org should be visible when org context is set added