@ -13,8 +13,6 @@ RSpec.describe ActivityPub::Activity::Create do
} . with_indifferent_access
end
subject { described_class . new ( json , sender ) }
before do
sender . update ( uri : ActivityPub :: TagManager . instance . uri_for ( sender ) )
@ -23,6 +21,9 @@ RSpec.describe ActivityPub::Activity::Create do
end
describe '#perform' do
context 'when fetching' do
subject { described_class . new ( json , sender ) }
before do
subject . perform
end
@ -407,4 +408,127 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
end
context 'when sender is followed by local users' do
subject { described_class . new ( json , sender , delivery : true ) }
before do
Fabricate ( :account ) . follow! ( sender )
subject . perform
end
let ( :object_json ) do
{
id : [ ActivityPub :: TagManager . instance . uri_for ( sender ) , '#bar' ] . join ,
type : 'Note' ,
content : 'Lorem ipsum' ,
}
end
it 'creates status' do
status = sender . statuses . first
expect ( status ) . to_not be_nil
expect ( status . text ) . to eq 'Lorem ipsum'
end
end
context 'when sender replies to local status' do
let! ( :local_status ) { Fabricate ( :status ) }
subject { described_class . new ( json , sender , delivery : true ) }
before do
subject . perform
end
let ( :object_json ) do
{
id : [ ActivityPub :: TagManager . instance . uri_for ( sender ) , '#bar' ] . join ,
type : 'Note' ,
content : 'Lorem ipsum' ,
inReplyTo : ActivityPub :: TagManager . instance . uri_for ( local_status ) ,
}
end
it 'creates status' do
status = sender . statuses . first
expect ( status ) . to_not be_nil
expect ( status . text ) . to eq 'Lorem ipsum'
end
end
context 'when sender targets a local user' do
let! ( :local_account ) { Fabricate ( :account ) }
subject { described_class . new ( json , sender , delivery : true ) }
before do
subject . perform
end
let ( :object_json ) do
{
id : [ ActivityPub :: TagManager . instance . uri_for ( sender ) , '#bar' ] . join ,
type : 'Note' ,
content : 'Lorem ipsum' ,
to : ActivityPub :: TagManager . instance . uri_for ( local_account ) ,
}
end
it 'creates status' do
status = sender . statuses . first
expect ( status ) . to_not be_nil
expect ( status . text ) . to eq 'Lorem ipsum'
end
end
context 'when sender cc\'s a local user' do
let! ( :local_account ) { Fabricate ( :account ) }
subject { described_class . new ( json , sender , delivery : true ) }
before do
subject . perform
end
let ( :object_json ) do
{
id : [ ActivityPub :: TagManager . instance . uri_for ( sender ) , '#bar' ] . join ,
type : 'Note' ,
content : 'Lorem ipsum' ,
cc : ActivityPub :: TagManager . instance . uri_for ( local_account ) ,
}
end
it 'creates status' do
status = sender . statuses . first
expect ( status ) . to_not be_nil
expect ( status . text ) . to eq 'Lorem ipsum'
end
end
context 'when the sender has no relevance to local activity' do
subject { described_class . new ( json , sender , delivery : true ) }
before do
subject . perform
end
let ( :object_json ) do
{
id : [ ActivityPub :: TagManager . instance . uri_for ( sender ) , '#bar' ] . join ,
type : 'Note' ,
content : 'Lorem ipsum' ,
}
end
it 'does not create anything' do
expect ( sender . statuses . count ) . to eq 0
end
end
end
end