report_policy_spec.rb 532 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. require 'pundit/rspec'
  4. RSpec.describe ReportPolicy do
  5. let(:subject) { described_class }
  6. let(:admin) { Fabricate(:user, admin: true).account }
  7. let(:john) { Fabricate(:user).account }
  8. permissions :update?, :index?, :show? do
  9. context 'staff?' do
  10. it 'permits' do
  11. expect(subject).to permit(admin, Report)
  12. end
  13. end
  14. context '!staff?' do
  15. it 'denies' do
  16. expect(subject).to_not permit(john, Report)
  17. end
  18. end
  19. end
  20. end