Skip to content

Commit

Permalink
Opening URLs through automate: fix specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed Jul 21, 2019
1 parent cb9cb9a commit 19c957e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('dialogUserController', function() {
resourceActionId: '789',
targetId: '987',
targetType: 'targettype',
realTargetType: 'targettype',
openUrl: false,
});
}));
Expand Down Expand Up @@ -85,7 +86,7 @@ describe('dialogUserController', function() {
'dialogData',
['dialogName'],
'/api/service_dialogs/',
{dialogId: '1234', resourceActionId: '789', targetId: '987', targetType: 'targettype'}
{dialogId: '1234', resourceActionId: '789', targetId: '987', targetType: 'targettype', realTargetType: 'targettype'}
);
});
});
Expand Down Expand Up @@ -119,6 +120,7 @@ describe('dialogUserController', function() {
resourceActionId: '789',
targetId: '987',
targetType: 'targettype',
realTargetType: 'targettype',
saveable: true,
openUrl: false,
});
Expand Down Expand Up @@ -153,6 +155,7 @@ describe('dialogUserController', function() {
resourceActionId: '789',
targetId: '987',
targetType: 'targettype',
realTargetType: 'targettype',
saveable: true,
openUrl: false,
});
Expand Down
82 changes: 42 additions & 40 deletions spec/services/dialog_local_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:resource_action_id => 456,
:target_id => 321,
:target_type => 'service_template',
:real_target_type => "ServiceTemplate",
:dialog_id => 654,
:force_old_dialog_use => false,
:api_submit_endpoint => "/api/service_catalogs/123/service_templates/321",
Expand All @@ -29,6 +30,7 @@
expect(service.determine_dialog_locals_for_svc_catalog_provision(resource_action, target_ansible, finish_submit_endpoint)).to eq(:resource_action_id => 456,
:target_id => 987,
:target_type => 'service_template',
:real_target_type => "ServiceTemplate",
:dialog_id => 654,
:force_old_dialog_use => false,
:api_submit_endpoint => "/api/service_catalogs/798/service_templates/987",
Expand All @@ -44,13 +46,14 @@
let(:resource_action) { instance_double("ResourceAction", :id => 321, :dialog_id => 654) }
let(:display_options) { {} }

shared_examples_for "DialogLocalService#determine_dialog_locals_for_custom_button return value" do |target_type, collection_name, finish_endpoint|
shared_examples_for "DialogLocalService#determine_dialog_locals_for_custom_button return value" do |target_type, real_target_type, collection_name, finish_endpoint|
it "returns a hash with the proper parameters" do
expect(service.determine_dialog_locals_for_custom_button(obj, button_name, resource_action, display_options))
.to eq(
:resource_action_id => 321,
:target_id => 123,
:target_type => target_type,
:real_target_type => real_target_type,
:dialog_id => 654,
:force_old_dialog_use => false,
:api_submit_endpoint => "/api/#{collection_name}/123",
Expand All @@ -66,238 +69,237 @@
let(:obj) { double(:class => ManageIQ::Providers::Vmware::CloudManager::AvailabilityZone, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"availability_zone", "availability_zones", "/availability_zone"
"availability_zone", "AvailabilityZone", "availability_zones", "/availability_zone"
end

context "when the object is a CloudNetwork" do
let(:obj) { double(:class => ManageIQ::Providers::Amazon::NetworkManager::CloudNetwork, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"cloud_network", "cloud_networks", "/cloud_network"
"cloud_network", "CloudNetwork", "cloud_networks", "/cloud_network"
end

context "when the object is a private CloudNetwork" do
let(:obj) { double(:class => ManageIQ::Providers::Openstack::NetworkManager::CloudNetwork::Private, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"cloud_network", "cloud_networks", "/cloud_network"
"cloud_network", "CloudNetwork", "cloud_networks", "/cloud_network"
end

context "when the object is a CloudObjectStoreContainer" do
let(:obj) { double(:class => ManageIQ::Providers::Amazon::StorageManager::S3::CloudObjectStoreContainer, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"cloud_object_store_container", "cloud_object_store_containers", "/cloud_object_store_container"
"cloud_object_store_container", "CloudObjectStoreContainer", "cloud_object_store_containers", "/cloud_object_store_container"
end

context "when the object is a CloudSubnet" do
let(:obj) { double(:class => ManageIQ::Providers::Amazon::NetworkManager::CloudSubnet, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"cloud_subnet", "cloud_subnets", "/cloud_subnet"
"cloud_subnet", "CloudSubnet", "cloud_subnets", "/cloud_subnet"
end

context "when the object is an EmsStorage" do
let(:obj) { double(:class => ManageIQ::Providers::StorageManager, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"ext_management_system", "providers", "/ems_infra"
"ext_management_system", "ExtManagementSystem", "providers", "/ems_infra"
end

context "when the object is an Ebs" do
let(:obj) { double(:class => ManageIQ::Providers::Amazon::StorageManager::Ebs, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"ems_storage", "providers", "/ems_infra"
"ems_storage", "ExtManagementSystem", "providers", "/ems_infra"
end

context "when the object is an CinderManager" do
let(:obj) { double(:class => ManageIQ::Providers::StorageManager::CinderManager, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"ext_management_system", "providers", "/ems_block_storage"
"ext_management_system", "ExtManagementSystem", "providers", "/ems_block_storage"
end

context "when the object is an SwiftManager" do
let(:obj) { double(:class => ManageIQ::Providers::StorageManager::SwiftManager, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"ext_management_system", "providers", "/ems_object_storage"
"ext_management_system", "ExtManagementSystem", "providers", "/ems_object_storage"
end

context "when the object is a CloudTenant" do
let(:obj) { double(:class => ManageIQ::Providers::Openstack::CloudManager::CloudTenant, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"cloud_tenant", "cloud_tenants", "/cloud_tenant"
"cloud_tenant", "CloudTenant", "cloud_tenants", "/cloud_tenant"
end

context "when the object is a CloudVolume" do
let(:obj) { double(:class => ManageIQ::Providers::Openstack::CloudManager::CloudVolume, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"cloud_volume", "cloud_volumes", "/cloud_volume"
"cloud_volume", "CloudVolume", "cloud_volumes", "/cloud_volume"
end

context "when the object is a ContainerGroup" do
let(:obj) { double(:class => ManageIQ::Providers::Kubernetes::ContainerManager::ContainerGroup, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"container_group", "container_groups", "/container_group"
"container_group", "ContainerGroup", "container_groups", "/container_group"
end

context "when the object is a ContainerImage" do
let(:obj) { double(:class => ManageIQ::Providers::Openshift::ContainerManager::ContainerImage, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"container_image", "container_images", "/container_image"
"container_image", "ContainerImage", "container_images", "/container_image"
end

context "when the object is a ContainerNode" do
let(:obj) { double(:class => ManageIQ::Providers::Kubernetes::ContainerManager::ContainerNode, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"container_node", "container_nodes", "/container_node"
"container_node", "ContainerNode", "container_nodes", "/container_node"
end

context "when the object is a ContainerProject" do
let(:obj) { double(:class => ContainerProject, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"container_project", "container_projects", "/container_project"
"container_project", "ContainerProject", "container_projects", "/container_project"
end

context "when the object is a ContainerTemplate" do
let(:obj) { double(:class => ManageIQ::Providers::Kubernetes::ContainerManager::ContainerTemplate, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"container_template", "container_templates", "/container_template"
"container_template", "ContainerTemplate", "container_templates", "/container_template"
end

context "when the object is a ContainerVolume" do
let(:obj) { double(:class => ContainerVolume, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"container_volume", "container_volumes", "/persistent_volume/show/123"
"container_volume", "ContainerVolume", "container_volumes", "/persistent_volume/show/123"
end

context "when the object is an EmsCluster" do
let(:obj) { double(:class => ManageIQ::Providers::Openstack::InfraManager::EmsCluster, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"ems_cluster", "clusters", "/ems_cluster"
"ems_cluster", "EmsCluster", "clusters", "/ems_cluster"
end

context "when the object is a GenericObject" do
let(:obj) { double(:class => GenericObject, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"generic_object", "generic_objects", "/service/explorer"
"generic_object", "GenericObject", "generic_objects", "/service/explorer"
end

context "when the object is a Host" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::Host, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"host", "hosts", "/host"
"host", "Host", "hosts", "/host"
end

context "when the object is a HostEsx" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::HostEsx, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"host", "hosts", "/host"
"host", "Host", "hosts", "/host"
end

context "when the object is an InfraManager" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"ext_management_system", "providers", "/ems_infra"
"ext_management_system", "ExtManagementSystem", "providers", "/ems_infra"
end

context "when the object is a CloudManager" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::CloudManager, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"ext_management_system", "providers", "/ems_cloud"
"ext_management_system", "ExtManagementSystem", "providers", "/ems_cloud"
end

context "when the object is a NetworkRouter" do
let(:obj) { double(:class => ManageIQ::Providers::Amazon::NetworkManager::NetworkRouter, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"network_router", "network_routers", "/network_router"
"network_router", "NetworkRouter", "network_routers", "/network_router"
end

context "when the object is an OrchestrationStack" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::CloudManager::OrchestrationStack, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"orchestration_stack", "orchestration_stacks", "/orchestration_stack"
"orchestration_stack", "OrchestrationStack", "orchestration_stacks", "/orchestration_stack"
end

context "when the object is a SecurityGroup" do
let(:obj) { double(:class => ManageIQ::Providers::Amazon::NetworkManager::SecurityGroup, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"security_group", "security_groups", "/security_group"
"security_group", "SecurityGroup", "security_groups", "/security_group"
end

context "when the object is a Service" do
let(:obj) { double(:class => Service, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"service", "services", "/service/explorer"
"service", "Service", "services", "/service/explorer"
end

context "when the object is a ServiceAnsiblePlaybook" do
let(:obj) { double(:class => ServiceAnsiblePlaybook, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"service", "services", "/service/explorer"
"service", "Service", "services", "/service/explorer"
end

context "when the object is a ServiceAnsibleTower" do
let(:obj) { double(:class => ServiceAnsibleTower, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"service", "services", "/service/explorer"
"service", "Service", "services", "/service/explorer"
end

context "when the object is a ServiceContainerTemplate" do
let(:obj) { double(:class => ServiceContainerTemplate, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"service", "services", "/service/explorer"
"service", "Service", "services", "/service/explorer"
end

context "when the object is a ServiceGeneric" do
let(:obj) { double(:class => ServiceGeneric, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"service", "services", "/service/explorer"
"service", "Service", "services", "/service/explorer"
end

context "when the object is a ServiceOrchestration" do
let(:obj) { double(:class => ServiceOrchestration, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"service", "services", "/service/explorer"
"service", "Service", "services", "/service/explorer"
end

context "when the object is a Storage" do
let(:obj) { double(:class => Storage, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"storage", "data_stores", "/storage/explorer"
"storage", "Storage", "data_stores", "/storage/explorer"
end

context "when the object is a Switch" do
let(:obj) { double(:class => Switch, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"switch", "switches", "/infra_networking/explorer"
"switch", "Switch", "switches", "/infra_networking/explorer"
end

context "when the object is a Template" do
Expand All @@ -306,14 +308,14 @@
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"
"miq_template", "VmOrTemplate", "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"
"miq_template", "VmOrTemplate", "templates", "/vm_or_template/explorer"
end
end

Expand All @@ -323,14 +325,14 @@
let(:display_options) { {:cancel_endpoint => "/vm_cloud/explorer"} }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"vm", "vms", "/vm_cloud/explorer"
"vm", "VmOrTemplate", "vms", "/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::Vm, :id => 123) }

include_examples "DialogLocalService#determine_dialog_locals_for_custom_button return value",
"vm", "vms", "/vm_infra/explorer"
"vm", "VmOrTemplate", "vms", "/vm_infra/explorer"
end
end
end
Expand Down

0 comments on commit 19c957e

Please sign in to comment.