search_spec.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Account::Search do
  4. describe 'a non-discoverable account becoming discoverable' do
  5. let(:account) { Account.find_by(username: 'search_test_account_1') }
  6. context 'when picking a non-discoverable account' do
  7. it 'its bio is not in the AccountsIndex' do
  8. results = AccountsIndex.filter(term: { username: account.username })
  9. expect(results.count).to eq(1)
  10. expect(results.first.text).to be_nil
  11. end
  12. end
  13. context 'when the non-discoverable account becomes discoverable' do
  14. it 'its bio is added to the AccountsIndex' do
  15. account.discoverable = true
  16. account.save!
  17. results = AccountsIndex.filter(term: { username: account.username })
  18. expect(results.count).to eq(1)
  19. expect(results.first.text).to eq(account.note)
  20. end
  21. end
  22. end
  23. describe 'a discoverable account becoming non-discoverable' do
  24. let(:account) { Account.find_by(username: 'search_test_account_0') }
  25. context 'when picking an discoverable account' do
  26. it 'has its bio in the AccountsIndex' do
  27. results = AccountsIndex.filter(term: { username: account.username })
  28. expect(results.count).to eq(1)
  29. expect(results.first.text).to eq(account.note)
  30. end
  31. end
  32. context 'when the discoverable account becomes non-discoverable' do
  33. it 'its bio is removed from the AccountsIndex' do
  34. account.discoverable = false
  35. account.save!
  36. results = AccountsIndex.filter(term: { username: account.username })
  37. expect(results.count).to eq(1)
  38. expect(results.first.text).to be_nil
  39. end
  40. end
  41. end
  42. end