1
0

custom_emoji_policy_spec.rb 890 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. require 'pundit/rspec'
  4. RSpec.describe CustomEmojiPolicy do
  5. subject { described_class }
  6. let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
  7. let(:john) { Fabricate(:account) }
  8. permissions :index?, :enable?, :disable? do
  9. context 'when staff' do
  10. it 'permits' do
  11. expect(subject).to permit(admin, CustomEmoji)
  12. end
  13. end
  14. context 'when not staff' do
  15. it 'denies' do
  16. expect(subject).to_not permit(john, CustomEmoji)
  17. end
  18. end
  19. end
  20. permissions :create?, :update?, :copy?, :destroy? do
  21. context 'when admin' do
  22. it 'permits' do
  23. expect(subject).to permit(admin, CustomEmoji)
  24. end
  25. end
  26. context 'when not admin' do
  27. it 'denies' do
  28. expect(subject).to_not permit(john, CustomEmoji)
  29. end
  30. end
  31. end
  32. end