account_warning_preset_policy_spec.rb 598 B

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