Skip to content

Commit

Permalink
Merge pull request ManageIQ#16255 from imtayadeway/revert-a7597b65273…
Browse files Browse the repository at this point in the history
…b9c6089ee19a887cd85c72d1f8f08

Fix Expression builder argument error by reverting ManageIQ#5506
(cherry picked from commit 075ae85)

https://bugzilla.redhat.com/show_bug.cgi?id=1514258
  • Loading branch information
gtanzillo authored and d-m-u committed Jun 6, 2018
1 parent 39d9347 commit 9b8b26a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 31 deletions.
4 changes: 0 additions & 4 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ class Host < ApplicationRecord
end
end

def self.include_descendant_classes_in_expressions?
true
end

def self.non_clustered
where(:ems_cluster_id => nil)
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ def self.base_model
Vm
end

def self.include_descendant_classes_in_expressions?
true
end

def self.corresponding_model
if self == Vm
MiqTemplate
Expand Down
8 changes: 2 additions & 6 deletions lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class MiqExpression
storage_files
switches
tenant_quotas
tenants
users
vms
volumes
Expand Down Expand Up @@ -1293,12 +1294,7 @@ def self.build_relats(model, parent = {}, seen = [])
result = {:columns => model.attribute_names, :parent => parent}
result[:reflections] = {}

refs = model.reflections_with_virtual
if model.try(:include_descendant_classes_in_expressions?)
model.descendants.each { |desc| refs.reverse_merge!(desc.reflections_with_virtual) }
end

refs.each do |assoc, ref|
model.reflections_with_virtual.each do |assoc, ref|
next unless INCLUDE_TABLES.include?(assoc.to_s.pluralize)
next if assoc.to_s.pluralize == "event_logs" && parent[:root] == "Host" && !proto?
next if assoc.to_s.pluralize == "processes" && parent[:root] == "Host" # Process data not available yet for Host
Expand Down
17 changes: 0 additions & 17 deletions spec/lib/miq_expression_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2089,23 +2089,6 @@
end
end

context ".build_relats" do
it "includes reflections from descendant classes of Vm" do
relats = MiqExpression.get_relats(Vm)
expect(relats[:reflections][:cloud_tenant]).not_to be_blank
end

it "includes reflections from descendant classes of Host" do
relats = MiqExpression.get_relats(Host)
expect(relats[:reflections][:cloud_networks]).not_to be_blank
end

it "excludes reflections from descendant classes of VmOrTemplate " do
relats = MiqExpression.get_relats(VmOrTemplate)
expect(relats[:reflections][:cloud_tenant]).to be_blank
end
end

describe "#to_human" do
it "generates a human readable string for a 'FIELD' expression" do
exp = MiqExpression.new(">" => {"field" => "Vm-allocated_disk_storage", "value" => "5.megabytes"})
Expand Down

0 comments on commit 9b8b26a

Please sign in to comment.