Skip to content

Commit

Permalink
save/render flash message after Network Router delete is initiated.
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kataria committed Apr 16, 2018
1 parent 5018838 commit 0de86d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/network_router_controller.rb
Expand Up @@ -32,6 +32,7 @@ def button
javascript_redirect(:action => "add_interface_select", :id => checked_item_id)
when "network_router_delete"
delete_network_routers
javascript_redirect(previous_breadcrumb_url)
when "network_router_edit"
javascript_redirect(:action => "edit", :id => checked_item_id)
when "network_router_new"
Expand Down Expand Up @@ -189,6 +190,7 @@ def delete_network_routers
elsif @lastaction == "show" && @layout == "network_router"
@single_delete = true unless flash_errors?
add_flash(_("The selected Router was deleted")) if @flash_array.nil?
flash_to_session
else
drop_breadcrumb(:name => 'dummy', :url => " ") # missing a bc to get correctly back so here's a dummy
flash_to_session
Expand Down
14 changes: 13 additions & 1 deletion spec/controllers/network_router_controller_spec.rb
Expand Up @@ -211,7 +211,19 @@

it "queues the delete action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
post :button, :params => { :id => @router.id, :pressed => "network_router_delete", :format => :js }
controller.instance_variable_set(:@_params,
:pressed => "network_router_delete",
:id => @router.id)
controller.instance_variable_set(:@lastaction, "show")
controller.instance_variable_set(:@layout, "network_router")
allow(controller).to receive(:find_checked_ids_with_rbac).and_return([@router])
allow(controller).to receive(:find_id_with_rbac).and_return([@router])
controller.instance_variable_set(:@breadcrumbs, [{:name => "foo", :url => "network_router/show_list"}, {:name => "bar", :url => "network_router/show"}])
expect(controller).to receive(:render)
controller.send(:button)
flash_messages = assigns(:flash_array)
expect(flash_messages.first).to eq(:message => "Delete initiated for 1 Network Router.",
:level => :success)
end
end
end
Expand Down

0 comments on commit 0de86d0

Please sign in to comment.