|
1 | 1 | describe "Host Initiator Groups API" do
|
| 2 | + let(:provider) { FactoryBot.create(:ems_autosde, :name => 'Autosde') } |
| 3 | + let(:host_initiator_group_klass) { provider.class_by_ems('HostInitiatorGroup') } |
| 4 | + |
2 | 5 | include Spec::Support::SupportsHelper
|
3 | 6 | context "POST /api/host_initiator_groups" do
|
4 | 7 | it "with an invalid ems_id it responds with 404 Not Found" do
|
|
20 | 23 |
|
21 | 24 | it "creates new Host Initiator Group" do
|
22 | 25 | api_basic_authorize(collection_action_identifier(:host_initiator_groups, :create))
|
23 |
| - provider = FactoryBot.create(:ems_autosde, :name => 'Autosde') |
| 26 | + |
24 | 27 | request = {
|
25 | 28 | "action" => "create",
|
26 | 29 | "resource" => {
|
|
37 | 40 |
|
38 | 41 | it "Refuses to create without appropriate role" do
|
39 | 42 | api_basic_authorize
|
40 |
| - provider = FactoryBot.create(:ems_autosde, :name => 'Autosde') |
| 43 | + |
41 | 44 | request = {
|
42 | 45 | "action" => "create",
|
43 | 46 | "resource" => {
|
|
53 | 56 |
|
54 | 57 | it "Won't create for unsupported models" do
|
55 | 58 | api_basic_authorize(collection_action_identifier(:host_initiator_groups, :create))
|
56 |
| - provider = FactoryBot.create(:ems_autosde, :name => 'Autosde') |
57 | 59 |
|
58 |
| - stub_supports_not(ManageIQ::Providers::Autosde::StorageManager::HostInitiatorGroup, :create) |
| 60 | + stub_supports_not(host_initiator_group_klass, :create) |
59 | 61 |
|
60 | 62 | request = {
|
61 | 63 | "action" => "create",
|
|
73 | 75 | end
|
74 | 76 |
|
75 | 77 | it "deletes a single Host Initiator Group" do
|
76 |
| - provider = FactoryBot.create(:ems_autosde, :name => 'Autosde') |
77 |
| - host_initiator_group = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::HostInitiatorGroup", :name => 'test_host_initiator_group', :ext_management_system => provider) |
| 78 | + host_initiator_group = FactoryBot.create(host_initiator_group_klass.name, :name => 'test_host_initiator_group', :ext_management_system => provider) |
78 | 79 | api_basic_authorize('host_initiator_group_delete')
|
79 | 80 |
|
80 |
| - stub_supports(HostInitiatorGroup, :delete) |
| 81 | + stub_supports(host_initiator_group_klass, :delete) |
81 | 82 | post(api_host_initiator_group_url(nil, host_initiator_group), :params => gen_request(:delete))
|
82 | 83 |
|
83 | 84 | expect_single_action_result(:success => true, :message => /Deleting Host Initiator Group id: #{host_initiator_group.id} name: '#{host_initiator_group.name}'/)
|
84 | 85 | end
|
85 | 86 |
|
86 | 87 | it "deletes multiple Host Initiator Groups" do
|
87 |
| - provider = FactoryBot.create(:ems_autosde, :name => 'Autosde') |
88 |
| - host_initiator_group1 = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::HostInitiatorGroup", :name => 'test_host_initiator_group1', :ext_management_system => provider) |
89 |
| - host_initiator_group2 = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::HostInitiatorGroup", :name => 'test_host_initiator_group2', :ext_management_system => provider) |
| 88 | + host_initiator_group1 = FactoryBot.create(host_initiator_group_klass.name, :name => 'test_host_initiator_group1', :ext_management_system => provider) |
| 89 | + host_initiator_group2 = FactoryBot.create(host_initiator_group_klass.name, :name => 'test_host_initiator_group2', :ext_management_system => provider) |
90 | 90 | api_basic_authorize('host_initiator_group_delete')
|
91 | 91 |
|
92 |
| - stub_supports(HostInitiatorGroup, :delete) |
| 92 | + stub_supports(host_initiator_group_klass, :delete) |
93 | 93 | post(api_host_initiator_groups_url, :params => gen_request(:delete, [{"href" => api_host_initiator_group_url(nil, host_initiator_group1)}, {"href" => api_host_initiator_group_url(nil, host_initiator_group2)}]))
|
94 | 94 |
|
95 | 95 | results = response.parsed_body["results"]
|
|
0 commit comments