@ -17,6 +17,7 @@ RSpec.describe ActivityPub::Activity::Follow do
describe '#perform' do
describe '#perform' do
subject { described_class . new ( json , sender ) }
subject { described_class . new ( json , sender ) }
context 'with no prior follow' do
context 'unlocked account' do
context 'unlocked account' do
before do
before do
subject . perform
subject . perform
@ -24,6 +25,7 @@ RSpec.describe ActivityPub::Activity::Follow do
it 'creates a follow from sender to recipient' do
it 'creates a follow from sender to recipient' do
expect ( sender . following? ( recipient ) ) . to be true
expect ( sender . following? ( recipient ) ) . to be true
expect ( sender . active_relationships . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
end
it 'does not create a follow request' do
it 'does not create a follow request' do
@ -43,6 +45,7 @@ RSpec.describe ActivityPub::Activity::Follow do
it 'creates a follow request' do
it 'creates a follow request' do
expect ( sender . requested? ( recipient ) ) . to be true
expect ( sender . requested? ( recipient ) ) . to be true
expect ( sender . follow_requests . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
end
end
end
@ -54,6 +57,7 @@ RSpec.describe ActivityPub::Activity::Follow do
it 'creates a follow from sender to recipient' do
it 'creates a follow from sender to recipient' do
expect ( sender . following? ( recipient ) ) . to be true
expect ( sender . following? ( recipient ) ) . to be true
expect ( sender . active_relationships . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
end
it 'does not create a follow request' do
it 'does not create a follow request' do
@ -73,6 +77,111 @@ RSpec.describe ActivityPub::Activity::Follow do
it 'creates a follow request' do
it 'creates a follow request' do
expect ( sender . requested? ( recipient ) ) . to be true
expect ( sender . requested? ( recipient ) ) . to be true
expect ( sender . follow_requests . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
end
end
context 'when a follow relationship already exists' do
before do
sender . active_relationships . create! ( target_account : recipient , uri : 'bar' )
end
context 'unlocked account' do
before do
subject . perform
end
it 'correctly sets the new URI' do
expect ( sender . active_relationships . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
it 'does not create a follow request' do
expect ( sender . requested? ( recipient ) ) . to be false
end
end
context 'silenced account following an unlocked account' do
before do
sender . touch ( :silenced_at )
subject . perform
end
it 'correctly sets the new URI' do
expect ( sender . active_relationships . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
it 'does not create a follow request' do
expect ( sender . requested? ( recipient ) ) . to be false
end
end
context 'unlocked account muting the sender' do
before do
recipient . mute! ( sender )
subject . perform
end
it 'correctly sets the new URI' do
expect ( sender . active_relationships . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
it 'does not create a follow request' do
expect ( sender . requested? ( recipient ) ) . to be false
end
end
context 'locked account' do
before do
recipient . update ( locked : true )
subject . perform
end
it 'correctly sets the new URI' do
expect ( sender . active_relationships . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
it 'does not create a follow request' do
expect ( sender . requested? ( recipient ) ) . to be false
end
end
end
context 'when a follow request already exists' do
before do
sender . follow_requests . create! ( target_account : recipient , uri : 'bar' )
end
context 'silenced account following an unlocked account' do
before do
sender . touch ( :silenced_at )
subject . perform
end
it 'does not create a follow from sender to recipient' do
expect ( sender . following? ( recipient ) ) . to be false
end
it 'correctly sets the new URI' do
expect ( sender . requested? ( recipient ) ) . to be true
expect ( sender . follow_requests . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
end
context 'locked account' do
before do
recipient . update ( locked : true )
subject . perform
end
it 'does not create a follow from sender to recipient' do
expect ( sender . following? ( recipient ) ) . to be false
end
it 'correctly sets the new URI' do
expect ( sender . requested? ( recipient ) ) . to be true
expect ( sender . follow_requests . find_by ( target_account : recipient ) . uri ) . to eq 'foo'
end
end
end
end
end
end
end