forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'parent/main' into upstream-20240306
- Loading branch information
Showing
9 changed files
with
509 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@mastodon/mastodon", | ||
"license": "AGPL-3.0-or-later", | ||
"packageManager": "[email protected].0", | ||
"packageManager": "[email protected].1", | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
|
82 changes: 82 additions & 0 deletions
82
spec/models/account_suggestions/friends_of_friends_source_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe AccountSuggestions::FriendsOfFriendsSource do | ||
describe '#get' do | ||
subject { described_class.new } | ||
|
||
let!(:bob) { Fabricate(:account, discoverable: true, hide_collections: false) } | ||
let!(:alice) { Fabricate(:account, discoverable: true, hide_collections: true) } | ||
let!(:eve) { Fabricate(:account, discoverable: true, hide_collections: false) } | ||
let!(:mallory) { Fabricate(:account, discoverable: false, hide_collections: false) } | ||
let!(:eugen) { Fabricate(:account, discoverable: true, hide_collections: false) } | ||
let!(:john) { Fabricate(:account, discoverable: true, hide_collections: false) } | ||
let!(:jerk) { Fabricate(:account, discoverable: true, hide_collections: false) } | ||
let!(:neil) { Fabricate(:account, discoverable: true, hide_collections: false) } | ||
let!(:larry) { Fabricate(:account, discoverable: true, hide_collections: false) } | ||
|
||
context 'with follows and blocks' do | ||
before do | ||
bob.block!(jerk) | ||
FollowRecommendationMute.create!(account: bob, target_account: neil) | ||
|
||
# bob follows eugen, alice and larry | ||
[eugen, alice, larry].each { |account| bob.follow!(account) } | ||
|
||
# alice follows eve and mallory | ||
[john, mallory].each { |account| alice.follow!(account) } | ||
|
||
# eugen follows eve, john, jerk, larry and neil | ||
[eve, mallory, jerk, larry, neil].each { |account| eugen.follow!(account) } | ||
end | ||
|
||
it 'returns eligible accounts', :aggregate_failures do | ||
results = subject.get(bob) | ||
|
||
# eve is returned through eugen | ||
expect(results).to include([eve.id, :friends_of_friends]) | ||
|
||
# john is not reachable because alice hides who she follows | ||
expect(results).to_not include([john.id, :friends_of_friends]) | ||
|
||
# mallory is not discoverable | ||
expect(results).to_not include([mallory.id, :friends_of_friends]) | ||
|
||
# larry is not included because he's followed already | ||
expect(results).to_not include([larry.id, :friends_of_friends]) | ||
|
||
# jerk is blocked | ||
expect(results).to_not include([jerk.id, :friends_of_friends]) | ||
|
||
# the suggestion for neil has already been rejected | ||
expect(results).to_not include([neil.id, :friends_of_friends]) | ||
end | ||
end | ||
|
||
context 'with deterministic order' do | ||
before do | ||
# bob follows eve and mallory | ||
[eve, mallory].each { |account| bob.follow!(account) } | ||
|
||
# eve follows eugen, john, and jerk | ||
[jerk, eugen, john].each { |account| eve.follow!(account) } | ||
|
||
# mallory follows eugen, john, and neil | ||
[neil, eugen, john].each { |account| mallory.follow!(account) } | ||
|
||
john.follow!(eugen) | ||
john.follow!(neil) | ||
end | ||
|
||
it 'returns eligible accounts in the expected order' do | ||
expect(subject.get(bob)).to eq [ | ||
[eugen.id, :friends_of_friends], # followed by 2 friends, 3 followers total | ||
[john.id, :friends_of_friends], # followed by 2 friends, 2 followers total | ||
[neil.id, :friends_of_friends], # followed by 1 friend, 2 followers total | ||
[jerk.id, :friends_of_friends], # followed by 1 friend, 1 follower total | ||
] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@mastodon/streaming", | ||
"license": "AGPL-3.0-or-later", | ||
"packageManager": "[email protected].0", | ||
"packageManager": "[email protected].1", | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
|
Oops, something went wrong.