Add unlisted-public tag/circle/list tests

This commit is contained in:
KMY 2023-09-14 18:39:13 +09:00
parent 1e62ee4965
commit 258a29ffde
7 changed files with 360 additions and 3 deletions

View file

@ -7,9 +7,10 @@ RSpec.describe FanOutOnWriteService, type: :service do
let(:last_active_at) { Time.now.utc }
let(:searchability) { 'public' }
let(:dissubscribable) { false }
let(:status) { Fabricate(:status, account: alice, visibility: visibility, searchability: searchability, text: 'Hello @bob #hoge') }
let!(:alice) { Fabricate(:user, current_sign_in_at: last_active_at).account }
let!(:alice) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { dissubscribable: dissubscribable }).account }
let!(:bob) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { username: 'bob' }).account }
let!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account }
let!(:ohagi) { Fabricate(:user, current_sign_in_at: last_active_at).account }
@ -100,6 +101,14 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when dissubscribable is true' do
let(:dissubscribable) { true }
it 'is not added to the antenna feed' do
expect(antenna_feed_of(antenna)).to_not include status.id
end
end
end
context 'with STL antenna' do
@ -110,6 +119,14 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when dissubscribable is true' do
let(:dissubscribable) { true }
it 'is added to the antenna feed' do
expect(antenna_feed_of(antenna)).to include status.id
end
end
end
context 'with LTL antenna' do
@ -120,6 +137,14 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when dissubscribable is true' do
let(:dissubscribable) { true }
it 'is added to the antenna feed' do
expect(antenna_feed_of(antenna)).to include status.id
end
end
end
end
@ -238,6 +263,89 @@ RSpec.describe FanOutOnWriteService, type: :service do
end
end
context 'when status is public_unlisted' do
let(:visibility) { 'public_unlisted' }
it 'is added to the home feed of its author' do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of a follower' do
expect(home_feed_of(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id
end
it 'is broadcast publicly' do
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to have_received(:publish).with('timeline:public:local', anything)
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
context 'with list' do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { list_with_account(ohagi, bob) }
it 'is added to the list feed of list follower' do
expect(list_feed_of(list)).to include status.id
expect(list_feed_of(empty_list)).to_not include status.id
end
end
context 'with antenna' do
let!(:antenna) { antenna_with_account(bob, alice) }
let!(:empty_antenna) { antenna_with_account(tom, bob) }
it 'is added to the antenna feed of antenna follower' do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when dissubscribable is true' do
let(:dissubscribable) { true }
it 'is not added to the antenna feed' do
expect(antenna_feed_of(antenna)).to_not include status.id
end
end
end
context 'with STL antenna' do
let!(:antenna) { antenna_with_options(bob, stl: true) }
let!(:empty_antenna) { antenna_with_options(tom) }
it 'is added to the antenna feed of antenna follower' do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when dissubscribable is true' do
let(:dissubscribable) { true }
it 'is added to the antenna feed' do
expect(antenna_feed_of(antenna)).to include status.id
end
end
end
context 'with LTL antenna' do
let!(:antenna) { antenna_with_options(bob, ltl: true) }
let!(:empty_antenna) { antenna_with_options(tom) }
it 'is added to the antenna feed of antenna follower' do
expect(antenna_feed_of(antenna)).to include status.id
expect(antenna_feed_of(empty_antenna)).to_not include status.id
end
context 'when dissubscribable is true' do
let(:dissubscribable) { true }
it 'is added to the antenna feed' do
expect(antenna_feed_of(antenna)).to include status.id
end
end
end
end
context 'when status is unlisted' do
let(:visibility) { 'unlisted' }
@ -255,6 +363,15 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
context 'with searchability private' do
let(:searchability) { 'private' }
it 'is not broadcast to the hashtag stream' do
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything)
end
end
context 'with list' do
let!(:list) { list_with_account(bob, alice) }
let!(:empty_list) { list_with_account(ohagi, bob) }