Skip to content

Commit

Permalink
Add specs for custom buttons on nested lists
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalis committed Nov 7, 2017
1 parent 9492299 commit 2d165d4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/controllers/service_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@
expect(assigns(:breadcrumbs)).to eq([{:name => "Abc (All Generic Objects)", :url => "/service/show/#{service.id}?display=generic_objects"}])
end

it 'displays one generic object from the nested list' do
EvmSpecHelper.create_guid_miq_server_zone
login_as FactoryGirl.create(:user)
controller.instance_variable_set(:@breadcrumbs, [])
service = FactoryGirl.create(:service, :name => "Abc")
definition = FactoryGirl.create(:generic_object_definition,
:properties => {:associations => {"vms" => "Vm", "services" => "Service"}})
go = FactoryGirl.create(
:generic_object,
:generic_object_definition => definition,
:name => 'go_assoc',
:services => [service]
)
service.add_resource(go)

get :show, :params => { :id => service.id, :display => 'generic_objects', :show => go.id}
expect(response.status).to eq(200)
expect(assigns(:breadcrumbs)).to eq([{:name => "Abc (All Generic Objects)", :url => "/service/show/#{service.id}?display=generic_objects"}])
end

context "#button" do
render_views

Expand Down
25 changes: 25 additions & 0 deletions spec/shared/controllers/shared_example_for_custom_buttons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,29 @@

expect(controller.custom_toolbar).to be_a_kind_of Mixins::CustomButtons::Result
end

it "has custom toolbar when showing nested list if nested list custom buttons are enabled" do
controller.instance_variable_set(:@display, 'generic_objects')
controller.instance_variable_set(:@layout, 'generic_objects')
controller.instance_variable_set(:@record, true)
controller.instance_variable_set(
:@sb,
:active_tree => "my_tree",
:trees => {"my_tree" => {:active_node => 's-1r35'}}
)

expect(controller.custom_toolbar).to be_a_kind_of Mixins::CustomButtons::Result
end

it "has custom toolbar when showing an item in a nested list if nested list custom buttons are enabled" do
controller.instance_variable_set(:@display, 'generic_objects')
controller.instance_variable_set(:@layout, 'generic_object')
controller.instance_variable_set(:@record, true)
controller.instance_variable_set(
:@sb,
:active_tree => "my_tree",
:trees => {"my_tree" => {:active_node => 's-1r35'}}
)
expect(controller.custom_toolbar).to be_a_kind_of Mixins::CustomButtons::Result
end
end

0 comments on commit 2d165d4

Please sign in to comment.