Skip to content

Commit

Permalink
Add #tenant_identity to OrchestrationStack.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu authored and alongoldboim committed Mar 15, 2016
1 parent 3412372 commit 91be954
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/orchestration_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class OrchestrationStack < ApplicationRecord
virtual_column :total_security_groups, :type => :integer
virtual_column :total_cloud_networks, :type => :integer

def tenant_identity
if ext_management_system
ext_management_system.tenant_identity
else
User.super_admin.tap { |u| u.current_group = Tenant.root_tenant.default_miq_group }
end
end

def total_vms
vms.size
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,28 @@
end
end
end

context '#tenant_identity' do
let(:admin) { FactoryGirl.create(:user_with_group, :userid => "admin") }
let(:tenant) { FactoryGirl.create(:tenant) }
before { admin }

subject { @stack.tenant_identity }

it "has tenant from provider" do
@stack = FactoryGirl.create(:orchestration_stack, :ems_id => ems.id)

expect(subject).to eq(admin)
expect(subject.current_group).to eq(ems.tenant.default_miq_group)
expect(subject.current_tenant).to eq(ems.tenant)
end

it "without a provider, has tenant from root tenant" do
@stack = FactoryGirl.create(:orchestration_stack)

expect(subject).to eq(admin)
expect(subject.current_group).to eq(Tenant.root_tenant.default_miq_group)
expect(subject.current_tenant).to eq(Tenant.root_tenant)
end
end
end

0 comments on commit 91be954

Please sign in to comment.