account_warning_preset_policy_spec.rb 581 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. require 'pundit/rspec'
  4. describe AccountWarningPresetPolicy do
  5. let(:policy) { described_class }
  6. let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
  7. let(:john) { Fabricate(:account) }
  8. permissions :index?, :create?, :update?, :destroy? do
  9. context 'with an admin' do
  10. it 'permits' do
  11. expect(policy).to permit(admin, Tag)
  12. end
  13. end
  14. context 'with a non-admin' do
  15. it 'denies' do
  16. expect(policy).to_not permit(john, Tag)
  17. end
  18. end
  19. end
  20. end