1
0

instance_policy_spec.rb 543 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe InstancePolicy do
  4. subject { described_class }
  5. let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
  6. let(:john) { Fabricate(:account) }
  7. permissions :index?, :show?, :destroy? do
  8. context 'when admin' do
  9. it 'permits' do
  10. expect(subject).to permit(admin, Instance)
  11. end
  12. end
  13. context 'when not admin' do
  14. it 'denies' do
  15. expect(subject).to_not permit(john, Instance)
  16. end
  17. end
  18. end
  19. end