Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of TreeBuilder.extract_node_model_and_id in OpcControler #5142

Merged
merged 1 commit into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/controllers/ops_controller/ops_rbac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ module OpsController::OpsRbac

def role_allows?(**options)
if MiqProductFeature.my_root_tenant_identifier?(options[:feature]) && params.key?(:id)
_, _, id = TreeBuilder.extract_node_model_and_id(params[:id].to_s)
if params[:id].to_s.include?('tn')
_, id, _ = TreeBuilder.extract_node_model_and_id(params[:id].to_s)
else
id = params[:id].to_s
end

options[:feature] = MiqProductFeature.tenant_identifier(options[:feature], id)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/application_helper/buttons/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
end

it "doesn't displays button Manage Tenant Quota for alpha tenant without tenant product permission for alpha tenant" do
controller.instance_variable_set(:@_params, :id => "tn_#{tenant_alpha.id}")
controller.instance_variable_set(:@_params, :id => "tn-#{tenant_alpha.id}")

expect(button.role_allows_feature?).to be_falsey
end

it "displays button Manage Tenant Quota from a tenant omega with tenant product permission for omega tenant" do
controller.instance_variable_set(:@_params, :id => "tn_#{tenant_omega.id}")
controller.instance_variable_set(:@_params, :id => "tn-#{tenant_omega.id}")

expect(button.role_allows_feature?).to be_truthy
end
Expand Down