delivery_policy_spec.rb 574 B

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