Skip to content

Commit

Permalink
Changed find_by back to find_by_fqname
Browse files Browse the repository at this point in the history
Issue was introduced in ManageIQ#2004, commit c281edf find_by_fqname was changed to use rails find_by but in this case fqname is not an actual column, find_by_fqname is an actual method in MiqAeNamespace class https://github.com/ManageIQ/manageiq/blob/cb5e0de1766fa363ecfd19715316e17053925d1e/app/models/miq_ae_namespace.rb#L20

https://bugzilla.redhat.com/show_bug.cgi?id=1510463
  • Loading branch information
h-kataria committed Nov 16, 2017
1 parent 84f889a commit 0175e3c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/miq_ae_class_controller.rb
Expand Up @@ -217,7 +217,7 @@ def open_parent_nodes(record)
self.x_node = "#{selected_node[0]}-#{to_cid(record.id)}"
parents.push(record)
else
ns = MiqAeNamespace.find_by(:fqname => nodes[0..i].join("/"))
ns = MiqAeNamespace.find_by_fqname(nodes[0..i].join("/"))
parents.push(ns) if ns
end
end
Expand Down
34 changes: 34 additions & 0 deletions spec/controllers/miq_ae_class_controller_spec.rb
Expand Up @@ -911,4 +911,38 @@
expect(assigns(:edit)[:new][:data]).to eq("exit MIQ_OK...")
end
end

context "#open_parent_nodes" do
it "returns parent nodes hash for newly added item in tree" do
ns = FactoryGirl.create(:miq_ae_namespace)
cls = FactoryGirl.create(:miq_ae_class, :namespace_id => ns.id)
method = FactoryGirl.create(:miq_ae_method, :name => "method01", :scope => "class",
:language => "ruby", :class_id => cls.id, :data => "exit MIQ_OK", :location => "inline")
controller.instance_variable_set(:@record, cls)
controller.instance_variable_set(
:@sb,
:trees => {:ae_tree => {:active_node => "aec-#{cls.id}", :open_nodes => [], :klass_name => "TreeBuilderAeClass",}},
:active_tree => :ae_tree
)
tree_node = controller.send(:open_parent_nodes, method)
ns_id = ApplicationRecord.compress_id(ns.id)
node_to_add = {
:key => "aen-#{ns_id}",
:nodes =>
[
{
:key => "aec-#{ns_id}",
:text => "miq_ae_class_0000000000001",
:tooltip => "Automate Class: miq_ae_class_0000000000001",
:icon => "ff ff-class",
:selectable => true,
:lazyLoad => true,
:state => {:expanded => false},
:class => "",
}
]
}
expect(tree_node).to eq(node_to_add)
end
end
end

0 comments on commit 0175e3c

Please sign in to comment.