Skip to content

Commit

Permalink
Ne plus permettre aux super-admins de se propager (#4227)
Browse files Browse the repository at this point in the history
* Ne plus permettre aux super-admins de se propager

* Please rubocop
  • Loading branch information
francois-ferrandis committed Apr 18, 2024
1 parent 874c4dd commit 1b02620
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
17 changes: 2 additions & 15 deletions app/dashboards/super_admin_dashboard.rb
Expand Up @@ -34,25 +34,12 @@ class SuperAdminDashboard < Administrate::BaseDashboard

# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
id
email
role
first_name
last_name
created_at
updated_at
].freeze
SHOW_PAGE_ATTRIBUTES = %i[].freeze

# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
email
role
first_name
last_name
].freeze
FORM_ATTRIBUTES = %i[].freeze

# Overwrite this method to customize how super admins are displayed
# across all pages of the super_admin dashboard.
Expand Down
11 changes: 1 addition & 10 deletions app/policies/super_admin/super_admin_policy.rb
@@ -1,13 +1,4 @@
class SuperAdmin::SuperAdminPolicy < DefaultSuperAdminPolicy
def privileges_for_record?
legacy_admin_member? || (record.support_member? && support_member?)
end

alias index? team_member?
alias show? team_member?
alias new? team_member?
alias create? privileges_for_record?
alias edit? privileges_for_record?
alias update? privileges_for_record?
alias destroy? privileges_for_record?
alias destroy? team_member?
end
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -28,7 +28,7 @@
resources :agent_roles, only: %i[show edit update destroy]
resources :agent_services, only: %i[show destroy]
resources :user_profiles, only: %i[destroy]
resources :super_admins
resources :super_admins, only: %i[index destroy]
resources :organisations
resources :services
resources :motifs
Expand Down
7 changes: 3 additions & 4 deletions spec/policies/super_admin/super_admin_policy_spec.rb
Expand Up @@ -6,20 +6,19 @@
let!(:new_legacy_admin_member) { build(:super_admin) }

context "Permitted actions for super_admin" do
it_behaves_like "permit actions", :new_legacy_admin_member, :index?, :show?, :new?, :create?, :edit?, :update?, :destroy?
it_behaves_like "permit actions", :new_legacy_admin_member, :index?, :destroy?
end

context "permitted actions for support on super_admin role" do
let!(:pundit_context) { create(:super_admin, :support) }

it_behaves_like "permit actions", :new_legacy_admin_member, :index?, :show?, :new?
it_behaves_like "not permit actions", :new_legacy_admin_member, :create?, :edit?, :update?, :destroy?
it_behaves_like "permit actions", :new_legacy_admin_member, :index?, :destroy?
end

context "permitted actions for support on support role" do
let!(:pundit_context) { create(:super_admin, :support) }
let!(:new_support_member) { build(:super_admin, :support) }

it_behaves_like "permit actions", :new_support_member, :index?, :show?, :new?, :create?, :edit?, :update?, :destroy?
it_behaves_like "permit actions", :new_support_member, :index?, :destroy?
end
end

0 comments on commit 1b02620

Please sign in to comment.