Add: #744 in:library のテストコード (#758)

This commit is contained in:
KMY(雪あすか) 2024-06-10 23:19:00 +09:00 committed by GitHub
parent 23f2e17d66
commit 3d0f5697a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -221,14 +221,16 @@ describe StatusesSearchService do
let(:search_keyword) { 'ohagi' }
let(:status_text) { 'I ate an apple.' }
let(:searchability) { :public }
let(:alice) { Fabricate(:user).account }
let(:account) { alice }
let!(:status) { Fabricate(:status, text: status_text, account: alice, searchability: :public) }
let!(:status) { Fabricate(:status, text: status_text, account: alice, searchability: searchability) }
before do
alice.update!(username: 'alice')
StatusesIndex.import!
PublicStatusesIndex.import!
end
shared_examples 'hit status' do |name, keyword|
@ -263,6 +265,22 @@ describe StatusesSearchService do
it_behaves_like 'hit status', 'when specify user name', 'apple from:alice'
it_behaves_like 'does not hit status', 'when specify not existing user name', 'apple from:ohagi'
context 'when indexable is enabled' do
let(:account) { Fabricate(:user).account }
let(:alice) { Fabricate(:user, account: Fabricate(:account, indexable: true)).account }
let(:searchability) { nil }
it_behaves_like 'hit status', 'when scope is all statuses', 'apple'
it_behaves_like 'does not hit status', 'when in:library is specified', 'apple in:library'
it_behaves_like 'hit status', 'when in:public is specified', 'apple in:public'
context 'with public searchability' do
let(:searchability) { :public }
it_behaves_like 'hit status', 'when scope is all public_searchability statuses', 'apple in:library'
end
end
context 'when in:following is specified' do
let(:following) { Fabricate(:user).account }
let(:other) { Fabricate(:user).account }