logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

status_filter_spec.rb (2135B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe StatusFilter do
  4. describe '#filtered?' do
  5. let(:status) { Fabricate(:status) }
  6. context 'without an account' do
  7. subject { described_class.new(status, nil) }
  8. context 'when there are no connections' do
  9. it { is_expected.not_to be_filtered }
  10. end
  11. context 'when status account is silenced' do
  12. before do
  13. status.account.update(silenced: true)
  14. end
  15. it { is_expected.to be_filtered }
  16. end
  17. context 'when status policy does not allow show' do
  18. before do
  19. expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
  20. end
  21. it { is_expected.to be_filtered }
  22. end
  23. end
  24. context 'with real account' do
  25. let(:account) { Fabricate(:account) }
  26. subject { described_class.new(status, account) }
  27. context 'when there are no connections' do
  28. it { is_expected.not_to be_filtered }
  29. end
  30. context 'when status account is blocked' do
  31. before do
  32. Fabricate(:block, account: account, target_account: status.account)
  33. end
  34. it { is_expected.to be_filtered }
  35. end
  36. context 'when status account domain is blocked' do
  37. before do
  38. status.account.update(domain: 'example.com')
  39. Fabricate(:account_domain_block, account: account, domain: status.account_domain)
  40. end
  41. it { is_expected.to be_filtered }
  42. end
  43. context 'when status account is muted' do
  44. before do
  45. Fabricate(:mute, account: account, target_account: status.account)
  46. end
  47. it { is_expected.to be_filtered }
  48. end
  49. context 'when status account is silenced' do
  50. before do
  51. status.account.update(silenced: true)
  52. end
  53. it { is_expected.to be_filtered }
  54. end
  55. context 'when status policy does not allow show' do
  56. before do
  57. expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
  58. end
  59. it { is_expected.to be_filtered }
  60. end
  61. end
  62. end
  63. end