canonical_email_block_policy_spec.rb 601 B

1234567891011121314151617181920212223
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe CanonicalEmailBlockPolicy 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?, :show?, :test?, :create?, :destroy? do
  8. context 'with an admin' do
  9. it 'permits' do
  10. expect(policy).to permit(admin, CanonicalEmailBlock)
  11. end
  12. end
  13. context 'with a non-admin' do
  14. it 'denies' do
  15. expect(policy).to_not permit(john, CanonicalEmailBlock)
  16. end
  17. end
  18. end
  19. end