Skip to content

Commit

Permalink
Merge pull request #18152 from d-m-u/bz1644320
Browse files Browse the repository at this point in the history
Include resource_action type and ID in linked components error message

(cherry picked from commit e018bc6)

https://bugzilla.redhat.com/show_bug.cgi?id=1644320
  • Loading branch information
gmcculloug authored and simaishi committed Nov 2, 2018
1 parent e565704 commit b8e41be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/models/dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def dialog_field_hash

def reject_if_has_resource_actions
if resource_actions.length > 0
raise _("Dialog cannot be deleted because it is connected to other components.")
connected_components = resource_actions.collect { |ra| ra.resource_type.constantize.find(ra.resource_id) }
raise _("Dialog cannot be deleted because it is connected to other components: #{connected_components.map { |cc| cc.class.name + ":" + cc.id.to_s + " - " + cc.try(:name) }}")
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/models/dialog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@

it "destroy with resource_action association" do
dialog = FactoryGirl.create(:dialog)
FactoryGirl.create(:resource_action, :action => "Provision", :dialog => dialog)
FactoryGirl.create(:resource_action, :action => "Provision", :dialog => dialog, :resource_type => Dialog, :resource_id => dialog.id)
expect { dialog.destroy }
.to raise_error(RuntimeError, /Dialog cannot be deleted.*connected to other components/)
.to raise_error(RuntimeError, "Dialog cannot be deleted because it is connected to other components: [\"Dialog:#{dialog.id} - #{dialog.name}\"]")
expect(Dialog.count).to eq(1)
end
end
Expand Down

0 comments on commit b8e41be

Please sign in to comment.