Project

General

Profile

Actions

Bug #14458

closed

Taxonomy search should search with STI base class

Added by Shlomi Zadok over 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Organizations and Locations
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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


Related issues 1 (0 open1 closed)

Related to OpenSCAP - Bug #14446: compliance reports from a particular org should be visible when org context is setResolvedShlomi Zadok04/04/2016Actions
Actions #1

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.

Actions #2

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
Actions #3

Updated by Marek Hulán over 8 years ago

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

Updated by Dominic Cleal over 8 years ago

  • Translation missing: en.field_release set to 141
Actions #5

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
Actions

Also available in: Atom PDF