Project

General

Profile

« Previous | Next » 

Revision 77cb9ca9

Added by Marek Hulán over 7 years ago

Fixes #15498 - removes scopes from includes in taxonomix

View differences:

app/models/concerns/taxonomix.rb
def taxable_ids(loc = which_location, org = which_organization, inner_method = which_ancestry_method)
if SETTINGS[:locations_enabled] && loc.present?
inner_ids_loc = if Location.ignore?(self.to_s)
self.pluck("#{table_name}.id")
self.unscoped.pluck("#{table_name}.id")
else
inner_select(loc, inner_method)
end
end
if SETTINGS[:organizations_enabled] && org.present?
inner_ids_org = if Organization.ignore?(self.to_s)
self.pluck("#{table_name}.id")
self.unscoped.pluck("#{table_name}.id")
else
inner_select(org, inner_method)
end
test/models/taxonomix_test.rb
new_dom.taxable_taxonomies.must_be :present?
assert new_dom.taxable_taxonomies.all?(&:valid?)
end
test "#taxable_ids works even if the resources uses eager loading on through associations" do
user = FactoryGirl.create(:user)
filter = FactoryGirl.create(:filter)
filter.permissions = Permission.where(:name => [ 'view_provisioning_templates' ])
role = FactoryGirl.create(:role, :filters => [ filter ])
user = FactoryGirl.create(:user)
user.roles = [ role ]
org = FactoryGirl.create :organization, :ignore_types => [ 'Hostgroup' ]
user.organizations = [ org ]
in_taxonomy org do
as_user user do
assert_nothing_raised do
ProvisioningTemplate.includes([:template_combinations => [:hostgroup, :environment]]).search_for('something').first
end
end
end
end
end

Also available in: Unified diff