Skip to content

Commit

Permalink
Add specs for miq_ae_class#replace_right_cell tree building.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed Oct 16, 2017
1 parent dcb4496 commit cb7bb0a
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions spec/controllers/miq_ae_class_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
include CompressedIds
context "#set_record_vars" do
it "Namespace remains unchanged when a class is edited" do
ns = FactoryGirl.create(:miq_ae_namespace)
cls = FactoryGirl.create(:miq_ae_class, :namespace_id => ns.id)
ns = factorygirl.create(:miq_ae_namespace)
cls = factorygirl.create(:miq_ae_class, :namespace_id => ns.id)
ns_id = cls.namespace_id
new = {:name => "New Name", :description => "New Description", :display_name => "Display Name", :inherits => "Some_Class"}
new = {:name => "new name", :description => "new description", :display_name => "display name", :inherits => "some_class"}
controller.instance_variable_set(:@sb,
:trees => {
:ae_tree => {:active_node => "aec-#{cls.id}"}
Expand Down Expand Up @@ -854,4 +854,29 @@
expect(assigns(:edit)[:new][:fields_list]).to match_array(["(name02)", "(name01)"])
end
end

context "#replace_right_cell" do
before do
ns = FactoryGirl.create(:miq_ae_namespace)
cls = FactoryGirl.create(:miq_ae_class, :namespace_id => ns.id)
seed_session_trees('miq_ae_class', :ae, "aec-#{cls.id}")
session_to_sb
end

it "Can build the AE tree" do
allow(User).to receive(:current_tenant).and_return(Tenant.first)
allow(User.current_tenant).to receive(:visible_domains).and_return([])
allow(controller).to receive(:domain_overrides)

expect(controller).to receive(:reload_trees_by_presenter).with(
instance_of(ExplorerPresenter),
array_including(
instance_of(TreeBuilderAeClass),
)
)
expect(controller).to receive(:render)

controller.send(:replace_right_cell, :replace_trees => %i(ae))
end
end
end

0 comments on commit cb7bb0a

Please sign in to comment.