I have two users, admin and local, i have assign update and delete method access to admin user only. Now i am trying to rspec my methods od active admin.
controller
def action_methods
if current_admin_user.admin?
super
elsif current_admin_user.local?
super - ['edit', 'destroy']
else
super
end
end
Rspec
it "should not allow agency admin to delete global tag" do
@user.add_as_admin_of(@agency)
delete admin_tag_path(@tag)
expect(response).to have_http_status(404)#anything as per our requirment this is for show sample.
end
rspec is passing for admin as they can access all the CRUD operation, where as on local user it throws `Failure/Error: delete admin_tag_path(@tag)
AbstractController::ActionNotFound:
AbstractController::ActionNotFound`
which is correct because it can't access those method but how can i Test them in rails.
Aucun commentaire:
Enregistrer un commentaire