1
0

announcement_policy_spec.rb 574 B

1234567891011121314151617181920212223
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AnnouncementPolicy 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, Announcement)
  11. end
  12. end
  13. context 'with a non-admin' do
  14. it 'denies' do
  15. expect(policy).to_not permit(john, Announcement)
  16. end
  17. end
  18. end
  19. end