statuses_search_spec.rb 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Account::StatusesSearch, :inline_jobs do
  4. describe 'a non-indexable account becoming indexable' do
  5. let(:account) { Account.find_by(username: 'search_test_account_1') }
  6. context 'when picking a non-indexable account' do
  7. it 'has no statuses in the PublicStatusesIndex' do
  8. expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(0)
  9. end
  10. it 'has statuses in the StatusesIndex' do
  11. expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count)
  12. end
  13. end
  14. context 'when the non-indexable account becomes indexable' do
  15. it 'adds the public statuses to the PublicStatusesIndex' do
  16. account.indexable = true
  17. account.save!
  18. expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.public_visibility.count)
  19. expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count)
  20. end
  21. end
  22. end
  23. describe 'an indexable account becoming non-indexable' do
  24. let(:account) { Account.find_by(username: 'search_test_account_0') }
  25. context 'when picking an indexable account' do
  26. it 'has statuses in the PublicStatusesIndex' do
  27. expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.public_visibility.count)
  28. end
  29. it 'has statuses in the StatusesIndex' do
  30. expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count)
  31. end
  32. end
  33. context 'when the indexable account becomes non-indexable' do
  34. it 'removes the statuses from the PublicStatusesIndex' do
  35. account.indexable = false
  36. account.save!
  37. expect(PublicStatusesIndex.filter(term: { account_id: account.id }).count).to eq(0)
  38. expect(StatusesIndex.filter(term: { account_id: account.id }).count).to eq(account.statuses.count)
  39. end
  40. end
  41. end
  42. end