Fixes virtual_totals when a default_scope exists
Fixes virtual_totals when a default_scope exists

When a has_many relation of a model that is used in a virtual_total and
has a default scope, it was not getting applied to the arel query when
the virtual_total column was being used in the select.  An example in
CloudTenant:

    class CloudTenant < ApplicationRecord

      has_many   :vms, -> { active }

      virtual_total :total_vms, :vms

      # ...
    end

Then flowing ActiveRecord query:

    CloudTenant.where(:name => 'DEV').select(:total_vms)

Would produce:

    SELECT (
      (SELECT COUNT(*)
       FROM "vms"
       WHERE "cloud_tenants"."id" = "vms"."cloud_tenant_id")
      ) AS total_vms
    FROM "cloud_tenants"
    WHERE "cloud_tenants"."name" = 'DEV'

Which doesn't take into account the `active` scope, which will filter
out any VM without an `ems_id` (so templates.

With this change, the SQL executed then gets updated to the following:

    SELECT (
      (SELECT COUNT(*)
       FROM "vms"
       WHERE "cloud_tenants"."id" = "vms"."cloud_tenant_id"
         AND "vms"."type" IN ('Vm', 'ManageIQ::Providers::CloudManager::Vm',
                              'ManageIQ::Providers::InfraManager::Vm', 'VmServer',
                              'ManageIQ::Providers::Amazon::CloudManager::Vm',
                              'ManageIQ::Providers::Azure::CloudManager::Vm',
                              'ManageIQ::Providers::Google::CloudManager::Vm',
                              'ManageIQ::Providers::Openstack::CloudManager::Vm',
                              'ManageIQ::Providers::Vmware::CloudManager::Vm', 'VmXen',
                              'ManageIQ::Providers::Redhat::InfraManager::Vm',
                              'ManageIQ::Providers::Microsoft::InfraManager::Vm',
                              'ManageIQ::Providers::Vmware::InfraManager::Vm')
         AND ("vms"."ems_id" IS NOT NULL))
       ) AS total_vms
    FROM "cloud_tenants"
    WHERE "cloud_tenants"."name" = 'DEV'

Which properly includes the default scopes for both the `Vm` model, and
the `:vm` relation in `CloudTenant`.

syncrou/manageiq,pkomanek/manageiq,skateman/manageiq,chessbyte/manageiq,gmcculloug/manageiq,pkomanek/manageiq,agrare/manageiq,gmcculloug/manageiq,borod108/manageiq,lpichler/manageiq,ailisp/manageiq,lpichler/manageiq,josejulio/manageiq,jvlcek/manageiq,branic/manageiq,ManageIQ/manageiq,gerikis/manageiq,mkanoor/manageiq,tinaafitz/manageiq,juliancheal/manageiq,israel-hdez/manageiq,jameswnl/manageiq,hstastna/manageiq,jameswnl/manageiq,jvlcek/manageiq,jrafanie/manageiq,aufi/manageiq,tzumainn/manageiq,mzazrivec/manageiq,borod108/manageiq,gerikis/manageiq,agrare/manageiq,mzazrivec/manageiq,kbrock/manageiq,kbrock/manageiq,kbrock/manageiq,yaacov/manageiq,hstastna/manageiq,mkanoor/manageiq,ailisp/manageiq,agrare/manageiq,syncrou/manageiq,billfitzgerald0120/manageiq,NickLaMuro/manageiq,jrafanie/manageiq,israel-hdez/manageiq,jameswnl/manageiq,josejulio/manageiq,borod108/manageiq,gmcculloug/manageiq,aufi/manageiq,ailisp/manageiq,josejulio/manageiq,jameswnl/manageiq,NickLaMuro/manageiq,tzumainn/manageiq,gerikis/manageiq,d-m-u/manageiq,ailisp/manageiq,djberg96/manageiq,jrafanie/manageiq,mkanoor/manageiq,aufi/manageiq,djberg96/manageiq,skateman/manageiq,d-m-u/manageiq,d-m-u/manageiq,kbrock/manageiq,billfitzgerald0120/manageiq,gerikis/manageiq,israel-hdez/manageiq,djberg96/manageiq,billfitzgerald0120/manageiq,romanblanco/manageiq,borod108/manageiq,hstastna/manageiq,skateman/manageiq,pkomanek/manageiq,lpichler/manageiq,mkanoor/manageiq,yaacov/manageiq,ManageIQ/manageiq,chessbyte/manageiq,pkomanek/manageiq,romanblanco/manageiq,chessbyte/manageiq,juliancheal/manageiq,tzumainn/manageiq,andyvesel/manageiq,branic/manageiq,israel-hdez/manageiq,jvlcek/manageiq,mzazrivec/manageiq,billfitzgerald0120/manageiq,syncrou/manageiq,ManageIQ/manageiq,branic/manageiq,jvlcek/manageiq,romanblanco/manageiq,aufi/manageiq,djberg96/manageiq,NickLaMuro/manageiq,d-m-u/manageiq,tinaafitz/manageiq,agrare/manageiq,hstastna/manageiq,tzumainn/manageiq,andyvesel/manageiq,juliancheal/manageiq,romanblanco/manageiq,juliancheal/manageiq,josejulio/manageiq,branic/manageiq,jrafanie/manageiq,chessbyte/manageiq,yaacov/manageiq,skateman/manageiq,tinaafitz/manageiq,lpichler/manageiq,yaacov/manageiq,gmcculloug/manageiq,mzazrivec/manageiq,syncrou/manageiq,NickLaMuro/manageiq,andyvesel/manageiq,andyvesel/manageiq,tinaafitz/manageiq,ManageIQ/manageiq