Show Connected Apps only to enterprise managers

Super-admins also saw that tab but connecting an app doesn't work unless
you are a manager of that enterprise.
This commit is contained in:
Maikel Linke
2024-01-11 12:18:13 +11:00
parent f480997754
commit 78e42ec664
3 changed files with 6 additions and 3 deletions

View File

@@ -21,7 +21,8 @@ module Admin
show_payment_methods = can?(:manage_payment_methods, enterprise) && is_shop
show_enterprise_fees = can?(:manage_enterprise_fees,
enterprise) && (is_shop || enterprise.is_primary_producer)
show_connected_apps = feature?(:connected_apps, spree_current_user, enterprise)
show_connected_apps = can?(:manage_connected_apps, enterprise) &&
feature?(:connected_apps, spree_current_user, enterprise)
build_enterprise_side_menu_items(
is_shop:,

View File

@@ -147,7 +147,8 @@ module Spree
end
can [:manage_payment_methods,
:manage_shipping_methods,
:manage_enterprise_fees], Enterprise do |enterprise|
:manage_enterprise_fees,
:manage_connected_apps], Enterprise do |enterprise|
user.enterprises.include? enterprise
end

View File

@@ -27,7 +27,8 @@ describe Admin::EnterprisesHelper, type: :helper do
]
end
it "lists enabled features", feature: :connected_apps do
it "lists enabled features when allowed", feature: :connected_apps do
user.enterprises << enterprise
expect(visible_items.pluck(:name)).to include "connected_apps"
end
end