Skip to content

Commit

Permalink
Merge pull request #5142 from lpichler/fix_parsing_from_params_id
Browse files Browse the repository at this point in the history
Fix usage of TreeBuilder.extract_node_model_and_id in OpcControler
  • Loading branch information
himdel authored Jan 9, 2019
2 parents 13fced0 + 16ee360 commit c10ecc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit c10ecc3

Please sign in to comment.