闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. require 'pundit/rspec'
  4. RSpec.describe AccountModerationNotePolicy do
  5. let(:subject) { described_class }
  6. let(:admin) { Fabricate(:user, admin: true).account }
  7. let(:john) { Fabricate(:user).account }
  8. permissions :create? do
  9. context 'staff' do
  10. it 'grants to create' do
  11. expect(subject).to permit(admin, AccountModerationNotePolicy)
  12. end
  13. end
  14. context 'not staff' do
  15. it 'denies to create' do
  16. expect(subject).to_not permit(john, AccountModerationNotePolicy)
  17. end
  18. end
  19. end
  20. permissions :destroy? do
  21. let(:account_moderation_note) do
  22. Fabricate(:account_moderation_note,
  23. account: john,
  24. target_account: Fabricate(:account))
  25. end
  26. context 'admin' do
  27. it 'grants to destroy' do
  28. expect(subject).to permit(admin, AccountModerationNotePolicy)
  29. end
  30. end
  31. context 'owner' do
  32. it 'grants to destroy' do
  33. expect(subject).to permit(john, account_moderation_note)
  34. end
  35. end
  36. context 'neither admin nor owner' do
  37. let(:kevin) { Fabricate(:user).account }
  38. it 'denies to destroy' do
  39. expect(subject).to_not permit(kevin, account_moderation_note)
  40. end
  41. end
  42. end
  43. end