1
0

custom_emoji_policy_spec.rb 867 B

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