|
|
@ -261,19 +261,43 @@ RSpec.describe Account, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe '.triadic_closures' do |
|
|
|
describe '.triadic_closures' do |
|
|
|
it 'finds accounts you dont follow which are followed by accounts you do follow' do |
|
|
|
subject { described_class.triadic_closures(me) } |
|
|
|
me = Fabricate(:account) |
|
|
|
|
|
|
|
friend = Fabricate(:account) |
|
|
|
let!(:me) { Fabricate(:account) } |
|
|
|
friends_friend = Fabricate(:account) |
|
|
|
let!(:friend) { Fabricate(:account) } |
|
|
|
|
|
|
|
let!(:friends_friend) { Fabricate(:account) } |
|
|
|
|
|
|
|
let!(:both_follow) { Fabricate(:account) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
me.follow!(friend) |
|
|
|
me.follow!(friend) |
|
|
|
friend.follow!(friends_friend) |
|
|
|
friend.follow!(friends_friend) |
|
|
|
|
|
|
|
|
|
|
|
both_follow = Fabricate(:account) |
|
|
|
|
|
|
|
me.follow!(both_follow) |
|
|
|
me.follow!(both_follow) |
|
|
|
friend.follow!(both_follow) |
|
|
|
friend.follow!(both_follow) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'finds accounts you dont follow which are followed by accounts you do follow' do |
|
|
|
|
|
|
|
is_expected.to eq [friends_friend] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context 'when you block account' do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
me.block!(friends_friend) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'rejects blocked accounts' do |
|
|
|
|
|
|
|
is_expected.to be_empty |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
results = Account.triadic_closures(me) |
|
|
|
context 'when you mute account' do |
|
|
|
expect(results).to eq [friends_friend] |
|
|
|
before do |
|
|
|
|
|
|
|
me.mute!(friends_friend) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'rejects muted accounts' do |
|
|
|
|
|
|
|
is_expected.to be_empty |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|