Add context and before to lengthy tag manager spec examples (#29129)

This commit is contained in:
Matt Jankowski 2024-02-08 05:03:04 -05:00 committed by GitHub
parent 5271131658
commit 15437e4ad9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,20 +52,27 @@ RSpec.describe ActivityPub::TagManager do
expect(subject.to(status)).to include(subject.followers_uri_for(mentioned))
end
it "returns URIs of mentions for direct silenced author's status only if they are followers or requesting to be" do
bob = Fabricate(:account, username: 'bob')
alice = Fabricate(:account, username: 'alice')
foo = Fabricate(:account)
author = Fabricate(:account, username: 'author', silenced: true)
status = Fabricate(:status, visibility: :direct, account: author)
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
expect(subject.to(status)).to include(subject.uri_for(bob))
expect(subject.to(status)).to include(subject.uri_for(foo))
expect(subject.to(status)).to_not include(subject.uri_for(alice))
context 'with followers and requested followers' do
let!(:bob) { Fabricate(:account, username: 'bob') }
let!(:alice) { Fabricate(:account, username: 'alice') }
let!(:foo) { Fabricate(:account) }
let!(:author) { Fabricate(:account, username: 'author', silenced: true) }
let!(:status) { Fabricate(:status, visibility: :direct, account: author) }
before do
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
end
it "returns URIs of mentions for direct silenced author's status only if they are followers or requesting to be" do
expect(subject.to(status))
.to include(subject.uri_for(bob))
.and include(subject.uri_for(foo))
.and not_include(subject.uri_for(alice))
end
end
end
@ -97,20 +104,27 @@ RSpec.describe ActivityPub::TagManager do
expect(subject.cc(status)).to include(subject.uri_for(mentioned))
end
it "returns URIs of mentions for silenced author's non-direct status only if they are followers or requesting to be" do
bob = Fabricate(:account, username: 'bob')
alice = Fabricate(:account, username: 'alice')
foo = Fabricate(:account)
author = Fabricate(:account, username: 'author', silenced: true)
status = Fabricate(:status, visibility: :public, account: author)
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
expect(subject.cc(status)).to include(subject.uri_for(bob))
expect(subject.cc(status)).to include(subject.uri_for(foo))
expect(subject.cc(status)).to_not include(subject.uri_for(alice))
context 'with followers and requested followers' do
let!(:bob) { Fabricate(:account, username: 'bob') }
let!(:alice) { Fabricate(:account, username: 'alice') }
let!(:foo) { Fabricate(:account) }
let!(:author) { Fabricate(:account, username: 'author', silenced: true) }
let!(:status) { Fabricate(:status, visibility: :public, account: author) }
before do
bob.follow!(author)
FollowRequest.create!(account: foo, target_account: author)
status.mentions.create(account: alice)
status.mentions.create(account: bob)
status.mentions.create(account: foo)
end
it "returns URIs of mentions for silenced author's non-direct status only if they are followers or requesting to be" do
expect(subject.cc(status))
.to include(subject.uri_for(bob))
.and include(subject.uri_for(foo))
.and not_include(subject.uri_for(alice))
end
end
it 'returns poster of reblogged post, if reblog' do