Skip to content

Commit

Permalink
Merge pull request ManageIQ#19295 from kbrock/rbac_no_references_static
Browse files Browse the repository at this point in the history
Fix references pass 1
  • Loading branch information
jrafanie authored Sep 23, 2019
2 parents 96190f8 + 365fce0 commit 902ea31
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/models/flavor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def self.class_by_ems(ext_management_system)

def self.tenant_joins_clause(scope)
scope.includes(:cloud_tenants => "source_tenant", :ext_management_system => {})
.references(:cloud_tenants => "source_tenant", :ext_management_system => {})
.references(:cloud_tenants, :tenants, :ext_management_system)
end

def self.create_flavor_queue(userid, ext_management_system, options = {})
Expand Down
9 changes: 2 additions & 7 deletions app/models/mixins/cloud_tenancy_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
module CloudTenancyMixin
extend ActiveSupport::Concern

QUERY_REFERENCES = {
:cloud_tenant => "source_tenant",
:ext_management_system => {}
}.freeze

module ClassMethods
include TenancyCommonMixin

Expand All @@ -18,8 +13,8 @@ def tenant_id_clause_format(tenant_ids)
end

def tenant_joins_clause(scope)
scope.includes(QUERY_REFERENCES)
.references(QUERY_REFERENCES) # needed for the where to work
scope.includes(:cloud_tenant => "source_tenant", :ext_management_system => {})
.references(:cloud_tenants, :tenants, :ext_management_systems) # needed for the where to work
end
end
end
2 changes: 1 addition & 1 deletion app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def self.with_tenant(tenant_id)
end

def self.with_additional_tenants
includes(:service_template_tenants => :tenant)
references(table_name, :tenants).includes(:service_template_tenants => :tenant)
end

def self.catalog_item_types
Expand Down
2 changes: 1 addition & 1 deletion spec/models/container_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
it "preloads the conditions" do
condition_other
cr = condition_ready
cg = ContainerGroup.includes(:ready_condition_status).references(:ready_condition_status => {}).find_by(:id => container_group.id)
cg = ContainerGroup.includes(:ready_condition_status).references(:ready_condition_status).find_by(:id => container_group.id)

expect { expect(cg.ready_condition).to eq(cr) }.to match_query_limit_of(0)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/metric_rollup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# TODO: that causes the error "ActiveRecord::ConfigurationError: nil"
# TODO: instead of the expected "ActiveRecord::EagerLoadPolymorphicError" error.
expect do
Tagging.includes(:taggable => {}).where('bogus_table.column = 1').references(:bogus_table => {}).to_a
Tagging.includes(:taggable => {}).where('bogus_table.column = 1').references(:bogus_table).to_a
end.to raise_error ActiveRecord::EagerLoadPolymorphicError
end
end
Expand Down

0 comments on commit 902ea31

Please sign in to comment.