Add load_and_authorize_resource to answers controller

This commit is contained in:
taitus
2022-09-09 16:29:04 +02:00
parent 405b37f605
commit cb2958e1b0
3 changed files with 7 additions and 4 deletions

View File

@@ -3,10 +3,10 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
include DocumentAttributes include DocumentAttributes
load_and_authorize_resource :question, class: "::Poll::Question" load_and_authorize_resource :question, class: "::Poll::Question"
load_resource class: "::Poll::Question::Answer", load_and_authorize_resource class: "::Poll::Question::Answer",
through: :question, through: :question,
through_association: :question_answers, through_association: :question_answers,
except: :documents except: :documents
def new def new
end end

View File

@@ -90,6 +90,7 @@ module Abilities
can [:create, :destroy], ::Poll::OfficerAssignment can [:create, :destroy], ::Poll::OfficerAssignment
can [:read, :create, :update], Poll::Question can [:read, :create, :update], Poll::Question
can :destroy, Poll::Question can :destroy, Poll::Question
can :manage, Poll::Question::Answer
can :manage, SiteCustomization::Page can :manage, SiteCustomization::Page
can :manage, SiteCustomization::Image can :manage, SiteCustomization::Image

View File

@@ -114,6 +114,8 @@ describe Abilities::Administrator do
it { should be_able_to(:create, Poll::Question) } it { should be_able_to(:create, Poll::Question) }
it { should be_able_to(:update, Poll::Question) } it { should be_able_to(:update, Poll::Question) }
it { should be_able_to(:manage, Poll::Question::Answer) }
it { is_expected.to be_able_to :manage, Dashboard::AdministratorTask } it { is_expected.to be_able_to :manage, Dashboard::AdministratorTask }
it { is_expected.to be_able_to :manage, dashboard_administrator_task } it { is_expected.to be_able_to :manage, dashboard_administrator_task }