Corrige 500 em Configurações e Usuários

- ConfiguracaoPolicy (e UserPolicy) chamavam admin_ou_gerente?/admin? que não
  existiam -> helpers movidos para ApplicationPolicy (toda policy herda)
- View de usuários usava helper badge_role inexistente -> criado em
  ApplicationHelper (badge por papel, cores do navbar)

Spec: ConfiguracaoPolicy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-16 02:02:44 -03:00
parent e89122c6dd
commit ffcae12d0b
4 changed files with 44 additions and 12 deletions

View File

@@ -29,6 +29,20 @@ module ApplicationHelper
end
end
# Badge de papel do usuário (admin/gerente/operador/motorista)
def badge_role(role)
cfg = case role.to_s
when 'admin' then { cor: 'bg-orange-500 text-black' }
when 'gerente' then { cor: 'bg-orange-800 text-white' }
when 'operador' then { cor: 'bg-gray-700 text-white' }
when 'motorista' then { cor: 'bg-gray-900 text-orange-400 border border-orange-500' }
else { cor: 'bg-gray-800 text-gray-400' }
end
label = User::ROLES_LABEL[role.to_s] || role.to_s.humanize
tag.span label, class: "inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold #{cfg[:cor]}"
end
# Barra de progresso laranja
def progress_bar(percentual, label: nil)
pct = percentual.to_i.clamp(0, 100)