Commit c5885cc5 authored by hellekin's avatar hellekin

Cover all in Pundit policies

parent 38730cb5
......@@ -10,6 +10,7 @@ class Api::V0::CategoriesController < ApplicationController
def show
@category = policy_scope(Category).find(params[:id])
authorize @category
render jsonapi: @category,
fields: params[:fields],
include: include_from_params
......
......@@ -8,7 +8,8 @@ class Api::V0::MapsController < ApplicationController
end
def show
@map = Map.includes(:collection, :taxonomy).find_by(uuid: params[:id])
@map = policy_scope(Map).includes(:collection, :taxonomy).find_by(uuid: params[:id])
authorize @map
render jsonapi: @map,
include: include_from_params
end
......
......@@ -2,14 +2,15 @@
class Api::V0::RolesController < ApplicationController
def index
@roles = Role.all
@roles = policy_scope(Role)
render jsonapi: @roles,
fields: params[:fields],
include: include_from_params
end
def show
@role = Role.find(params[:id])
@role = policy_scope(Role).find(params[:id])
authorize @role
render jsonapi: @role,
include: include_from_params,
fields: params[:fields]
......
......@@ -2,21 +2,18 @@
class Api::V0::SectionsController < ApplicationController
def index
@sections = Section.all
@sections = policy_scope(Section)
render jsonapi: @sections,
fields: params[:fields],
include: include_from_params
rescue INCOMMON::API::UnknownRelationshipError => e
render_jsonapi_error_unknown_relationship(e.message, model_types)
end
def show
@section = Section.find(params[:id])
@section = policy_scope(Section).find(params[:id])
authorize @section
render jsonapi: @section,
include: include_from_params,
fields: params[:fields]
rescue INCOMMON::API::UnknownRelationshipError => e
render_jsonapi_error_unknown_relationship(e.message, model_types)
end
private
......
......@@ -2,23 +2,20 @@
class Api::V0::TaxonomiesController < ApplicationController
def index
@taxonomies = Taxonomy.all
@taxonomies = policy_scope(Taxonomy)
render jsonapi: @taxonomies,
fields: params[:fields],
include: include_from_params
# expose: [current_user, current_agent]
rescue INCOMMON::API::UnknownRelationshipError => e
render_jsonapi_error_unknown_relationship(e.message, model_types)
end
def show
@taxonomy = Taxonomy.find_by(uuid: params[:id])
@taxonomy = policy_scope(Taxonomy).find_by(uuid: params[:id])
authorize @taxonomy
render jsonapi: @taxonomy,
include: include_from_params,
fields: params[:fields],
links: { agent: api_agent_url(@taxonomy.agent) }
rescue INCOMMON::API::UnknownRelationshipError => e
render_jsonapi_error_unknown_relationship(e.message, model_types)
end
private
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment