poll_policy_spec.rb 971 B

123456789101112131415161718192021222324252627282930313233343536
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PollPolicy do
  4. subject { described_class }
  5. let(:account) { Fabricate(:account) }
  6. let(:poll) { Fabricate :poll }
  7. permissions :vote? do
  8. context 'when account cannot view status' do
  9. before { poll.status.update(visibility: :private) }
  10. it { is_expected.to_not permit(account, poll) }
  11. end
  12. context 'when account can view status' do
  13. context 'when accounts do not block each other' do
  14. it { is_expected.to permit(account, poll) }
  15. end
  16. context 'when view blocks poll creator' do
  17. before { Fabricate :block, account: account, target_account: poll.account }
  18. it { is_expected.to_not permit(account, poll) }
  19. end
  20. context 'when poll creator blocks viewer' do
  21. before { Fabricate :block, account: poll.account, target_account: account }
  22. it { is_expected.to_not permit(account, poll) }
  23. end
  24. end
  25. end
  26. end