You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
576 B

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. require 'pundit/rspec'
  4. describe IpBlockPolicy 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?, :show?, :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