forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathems_storage_controller_spec.rb
56 lines (48 loc) · 2.22 KB
/
ems_storage_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
describe EmsStorageController do
include_examples :shared_examples_for_ems_storage_controller, %w(openstack)
it_behaves_like "controller with custom buttons"
describe "#check_generic_rbac" do
let(:feature) { MiqProductFeature.find_all_by_identifier(%w(ems_block_storage_show ems_block_storage_show_list)) }
let(:role) { FactoryBot.create(:miq_user_role, :miq_product_features => feature) }
let(:group) { FactoryBot.create(:miq_group, :miq_user_role => role) }
let(:user) { FactoryBot.create(:user, :miq_groups => [group]) }
let(:object_storage) { FactoryBot.create(:ems_swift) }
let(:block_storage) { FactoryBot.create(:ems_cinder) }
before do
EvmSpecHelper.create_guid_miq_server_zone
EvmSpecHelper.seed_specific_product_features(%w(ems_block_storage_show ems_block_storage_show_list ems_object_storage_show))
login_as user
end
it "allows access for block_storage" do
controller.action_name = 'show'
controller.instance_variable_set(:@record, block_storage)
expect(controller.send(:type_feature_role_check)).to be_truthy
end
it "denies access for object_storage" do
controller.action_name = 'show'
allow(controller).to receive(:redirect_to)
controller.instance_variable_set(:@record, object_storage)
expect(controller.send(:type_feature_role_check)).to be_falsey
end
it "sets @ems in init_show for a selected record" do
controller.action_name = 'show'
ems_storage = FactoryBot.create(:ems_storage)
allow(controller).to receive(:type_feature_role_check).and_return(true)
controller.params = {:id => ems_storage.id}
controller.send(:init_show)
expect(assigns(:record).id).to eq(ems_storage.id)
expect(assigns(:ems).id).to eq(ems_storage.id)
end
end
describe '#button' do
context 'tagging Cloud Object Store Container' do
before do
controller.params = {:pressed => 'cloud_object_store_container_tag'}
controller.instance_variable_set(:@display, 'cloud_object_store_containers')
end
it 'returns proper record class' do
expect(controller.send(:record_class)).to eq(CloudObjectStoreContainer)
end
end
end
end