From acb29e5b114899573a93e098f7c1c9788342b7a5 Mon Sep 17 00:00:00 2001 From: KMY Date: Sun, 8 Oct 2023 19:14:41 +0900 Subject: [PATCH] =?UTF-8?q?Test:=20=E5=8F=82=E7=85=A7=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E5=8F=96=E5=BE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../concerns/status_threading_concern_spec.rb | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/spec/models/concerns/status_threading_concern_spec.rb b/spec/models/concerns/status_threading_concern_spec.rb index 2eac1ca6e5ceb4..d0f517955067e0 100644 --- a/spec/models/concerns/status_threading_concern_spec.rb +++ b/spec/models/concerns/status_threading_concern_spec.rb @@ -129,4 +129,56 @@ expect(a.descendants(20)).to eq [c, d, e, f] end end + + describe '#readable_references' do + subject { status.readable_references(account).pluck(:id) } + + let(:visibility) { :public } + let(:alice) { Fabricate(:account) } + let(:referred_account) { Fabricate(:account) } + let(:status) { Fabricate(:status, account: account) } + let(:referred_status) { Fabricate(:status, account: referred_account, visibility: visibility) } + let(:referred_follower) { Fabricate(:account) } + let(:follower) { Fabricate(:account) } + let(:third_account) { Fabricate(:account) } + let(:account) { third_account } + + before do + referred_follower.follow!(referred_account) + follower.follow!(alice) + Fabricate(:status_reference, status: status, target_status: referred_status) + end + + it 'with a simple case' do + expect(subject).to include referred_status.id + end + + context 'when private post' do + let(:visibility) { :private } + + context 'with referred post follower' do + let(:account) { referred_follower } + + it 'can show' do + expect(subject).to include referred_status.id + end + end + + context 'with original post follower' do + let(:account) { follower } + + it 'can show' do + expect(subject).to_not include referred_status.id + end + end + + context 'with other account' do + let(:account) { third_account } + + it 'can show' do + expect(subject).to_not include referred_status.id + end + end + end + end end