Skip to content

Commit

Permalink
Fix vm_cloud image custom button return and cancel endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
eclarizio committed Nov 5, 2018
1 parent 1cacaf3 commit 6fdbe57
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
6 changes: 4 additions & 2 deletions app/services/dialog_local_service.rb
Expand Up @@ -113,8 +113,10 @@ def determine_api_endpoints(obj, display_options = {})
cancel_endpoint = "/storage/explorer"
when /Template/
api_collection_name = "templates"
cancel_endpoint = "/vm_or_template/explorer"
when /Tenant/
cancel_endpoint = display_options[:cancel_endpoint] || "/vm_or_template/explorer"

# ^ is necessary otherwise we match CloudTenant
when /^Tenant/
api_collection_name = "tenants"
cancel_endpoint = "/ops/explorer"
when /User/
Expand Down
31 changes: 18 additions & 13 deletions spec/services/dialog_local_service_spec.rb
Expand Up @@ -296,19 +296,24 @@
context "when the object is a Storage" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::Storage, :id => 123) }

it "returns a hash" do
expect(service.determine_dialog_locals_for_custom_button(obj, button_name, resource_action)).to eq(
:resource_action_id => 321,
:target_id => 123,
:target_type => 'storage',
:dialog_id => 654,
:force_old_dialog_use => false,
:api_submit_endpoint => "/api/datastores/123",
:api_action => "custom-button-name",
:finish_submit_endpoint => "/storage/explorer",
:cancel_endpoint => "/storage/explorer",
:open_url => false,
)
include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"storage", "datastores", "/storage/explorer"
end

context "when the object is a Template" do
context "when there is a cancel endpoint in the display options" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::Template, :id => 123) }
let(:display_options) { {:cancel_endpoint => "/vm_cloud/explorer"} }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"miq_template", "templates", "/vm_cloud/explorer"
end

context "when there is not a cancel endpoint in the display options" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::Template, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"miq_template", "templates", "/vm_or_template/explorer"
end
end

Expand Down

0 comments on commit 6fdbe57

Please sign in to comment.