settings_policy_spec.rb 543 B

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