Skip to content

Commit

Permalink
Merge pull request #10497 from lgalis/delete_config_provider_from_tre…
Browse files Browse the repository at this point in the history
…e_fails

Delete configuration provider when selected from tree does not work
(cherry picked from commit e1742b5)
  • Loading branch information
mzazrivec authored and chessbyte committed Aug 23, 2016
1 parent 6235a83 commit 9efb1e9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/provider_foreman_controller.rb
Expand Up @@ -88,6 +88,7 @@ def edit
def delete
assert_privileges("provider_foreman_delete_provider") # TODO: Privelege name should match generic ways from Infra and Cloud
checked_items = find_checked_items # TODO: Checked items are managers, not providers. Make them providers
checked_items.push(params[:id]) if checked_items.empty? && params[:id]
providers = ManageIQ::Providers::ConfigurationManager.where(:id => checked_items).includes(:provider).collect(&:provider)
if providers.empty?
add_flash(_("No %{model} were selected for %{task}") % {:model => ui_lookup(:tables => "providers"), :task => "deletion"}, :error)
Expand Down
24 changes: 24 additions & 0 deletions spec/controllers/provider_foreman_controller_spec.rb
Expand Up @@ -232,6 +232,30 @@
end
end

context "#delete" do
before do
stub_user(:features => :all)
end

it "deletes the provider when the configuration manager id is supplied" do
allow(controller).to receive(:replace_right_cell)
post :delete, :params => { :id => @config_mgr.id }
expect(assigns(:flash_array).first[:message]).to include("Delete initiated for 1 Provider")
end

it "it deletes a provider when the configuration manager id is selected from a list view" do
allow(controller).to receive(:replace_right_cell)
post :delete, :params => { :miq_grid_checks => "#{@config_mgr.id}, #{@config_mgr2.id}"}
expect(assigns(:flash_array).first[:message]).to include("Delete initiated for 2 Providers")
end

it "it deletes a provider when the configuration manager id is selected from a grid/tile" do
allow(controller).to receive(:replace_right_cell)
post :delete, :params => { "check_#{ApplicationRecord.compress_id(@config_mgr.id)}" => "1" }
expect(assigns(:flash_array).first[:message]).to include("Delete initiated for 1 Provider")
end
end

context "renders right cell text" do
before do
right_cell_text = nil
Expand Down

0 comments on commit 9efb1e9

Please sign in to comment.