I'm trying to run a strong parameters test for my Restaurant
model and am running into an error that's keeping from progressing in development . In its controller I have the CanCan method load_and_authorize_resource
to permit only admins to create, update, and destroy these model instances:
class RestaurantsController < ApplicationController
load_and_authorize_resource param_method: :restaurant_params, find_by: :slug
...
end
When it comes to running tests though I get the error:
1) RestaurantsController should permit POST #create to receive parameters :name
Failure/Error: should permit(:name).
CanCan::AccessDenied:
You are not authorized to access this page.
Is there simple way to bypass this authorization? I've looked all throughout SO and there doesn't seem to be a clear answer.
Test
describe RestaurantsController do
it { should permit(:name).for(:create) }
end
Aucun commentaire:
Enregistrer un commentaire