Skip to content

Commit

Permalink
Fix: テスト不備
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 10, 2023
1 parent f912770 commit 66c5301
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
7 changes: 7 additions & 0 deletions spec/lib/activitypub/activity/accept_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,12 @@
expect(friend.reload.they_are_idle?).to be true
expect(friend.i_am_accepted?).to be true
end

it 'when my server is not pending' do
friend.update(active_state: :idle)
subject.perform
expect(friend.reload.i_am_idle?).to be true
expect(friend.they_are_idle?).to be true
end
end
end
48 changes: 30 additions & 18 deletions spec/lib/status_reach_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

context 'with follower' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted)
bob.follow!(alice)
end

Expand All @@ -126,7 +126,7 @@

context 'with follower but not local-distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted, delivery_local: false)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, delivery_local: false)
bob.follow!(alice)
end

Expand All @@ -136,9 +136,9 @@
end
end

context 'with non-follower' do
context 'with non-follower and non-relay' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted)
end

it 'send status' do
Expand All @@ -149,7 +149,7 @@

context 'with pending' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :pending)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :pending)
bob.follow!(alice)
end

Expand All @@ -161,7 +161,7 @@

context 'with unidirection from them' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :idle, passive_state: :accepted)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :idle, passive_state: :accepted)
bob.follow!(alice)
end

Expand All @@ -173,7 +173,7 @@

context 'when unavailable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted, available: false)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, available: false)
bob.follow!(alice)
end

Expand All @@ -185,8 +185,7 @@

context 'when distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', passive_state: :accepted, pseudo_relay: true)
bob.follow!(alice)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
end

it 'send status' do
Expand All @@ -195,9 +194,9 @@
end
end

context 'when distributable, following reverse' do
context 'when distributable and following' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted, pseudo_relay: true)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
bob.follow!(alice)
end

Expand All @@ -207,10 +206,20 @@
end
end

context 'when distributable reverse' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, pseudo_relay: true)
end

it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
end
end

context 'when distributable but not local distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', passive_state: :accepted, pseudo_relay: true, delivery_local: false)
bob.follow!(alice)
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true, delivery_local: false)
end

it 'send status' do
Expand All @@ -219,20 +228,23 @@
end
end

context 'when distributable and not following' do
context 'when distributable and following but not local distributable' do
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, pseudo_relay: true)
Fabricate(:friend_domain, domain: 'foo.bar', passive_state: :accepted, pseudo_relay: true, delivery_local: false)
bob.follow!(alice)
end

it 'send status' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
expect(subject.inboxes).to include 'https://foo.bar/inbox'
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
end
end
end

context 'when it contains distributable friend server' do
before { Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', available: true, passive_state: :accepted, pseudo_relay: true) }
before do
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
end

it 'includes the inbox of the mentioned account' do
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
Expand Down

0 comments on commit 66c5301

Please sign in to comment.