Merge upstream 2.0ish #165
This commit is contained in:
@@ -16,7 +16,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
end
|
||||
|
||||
describe '#call' do
|
||||
let(:account) { subject.call('https://example.com/alice') }
|
||||
let(:account) { subject.call('https://example.com/alice', id: true) }
|
||||
|
||||
shared_examples 'sets profile data' do
|
||||
it 'returns an account' do
|
||||
|
@@ -15,21 +15,11 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
||||
}
|
||||
end
|
||||
|
||||
let(:create) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: "https://#{valid_domain}/@foo/1234/activity",
|
||||
type: 'Create',
|
||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||
object: note,
|
||||
}
|
||||
end
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
before do
|
||||
subject.call(object[:id], Oj.dump(object))
|
||||
subject.call(object[:id], prefetched_body: Oj.dump(object))
|
||||
end
|
||||
|
||||
context 'with Note object' do
|
||||
@@ -42,34 +32,5 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
||||
expect(status.text).to eq 'Lorem ipsum'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Create activity' do
|
||||
let(:object) { create }
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.text).to eq 'Lorem ipsum'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Announce activity' do
|
||||
let(:status) { Fabricate(:status, account: recipient) }
|
||||
|
||||
let(:object) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: "https://#{valid_domain}/@foo/1234/activity",
|
||||
type: 'Announce',
|
||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||
object: ActivityPub::TagManager.instance.uri_for(status),
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates a reblog by sender of status' do
|
||||
expect(sender.reblogged?(status)).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -28,7 +28,7 @@ RSpec.describe ActivityPub::ProcessCollectionService do
|
||||
|
||||
it 'processes payload with sender if no signature exists' do
|
||||
expect_any_instance_of(ActivityPub::LinkedDataSignature).not_to receive(:verify_account!)
|
||||
expect(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), forwarder)
|
||||
expect(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), forwarder, instance_of(Hash))
|
||||
|
||||
subject.call(json, forwarder)
|
||||
end
|
||||
@@ -37,7 +37,7 @@ RSpec.describe ActivityPub::ProcessCollectionService do
|
||||
payload['signature'] = {'type' => 'RsaSignature2017'}
|
||||
|
||||
expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_account!).and_return(actor)
|
||||
expect(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), actor)
|
||||
expect(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), actor, instance_of(Hash))
|
||||
|
||||
subject.call(json, forwarder)
|
||||
end
|
||||
|
@@ -5,7 +5,7 @@ RSpec.describe BatchedRemoveStatusService do
|
||||
|
||||
let!(:alice) { Fabricate(:account) }
|
||||
let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', salmon_url: 'http://example.com/salmon') }
|
||||
let!(:jeff) { Fabricate(:account) }
|
||||
let!(:jeff) { Fabricate(:user).account }
|
||||
let!(:hank) { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
|
||||
let(:status1) { PostStatusService.new.call(alice, 'Hello @bob@example.com') }
|
||||
@@ -19,6 +19,7 @@ RSpec.describe BatchedRemoveStatusService do
|
||||
stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
|
||||
|
||||
Fabricate(:subscription, account: alice, callback_url: 'http://example.com/push', confirmed: true, expires_at: 30.days.from_now)
|
||||
jeff.user.update(current_sign_in_at: Time.now)
|
||||
jeff.follow!(alice)
|
||||
hank.follow!(alice)
|
||||
|
||||
|
@@ -22,7 +22,7 @@ describe FetchRemoteResourceService do
|
||||
allow(FetchAtomService).to receive(:new).and_return service
|
||||
feed_url = 'http://feed-url'
|
||||
feed_content = '<feed>contents</feed>'
|
||||
allow(service).to receive(:call).with(url).and_return([feed_url, feed_content])
|
||||
allow(service).to receive(:call).with(url).and_return([feed_url, { prefetched_body: feed_content }])
|
||||
|
||||
account_service = double
|
||||
allow(FetchRemoteAccountService).to receive(:new).and_return(account_service)
|
||||
@@ -39,7 +39,7 @@ describe FetchRemoteResourceService do
|
||||
allow(FetchAtomService).to receive(:new).and_return service
|
||||
feed_url = 'http://feed-url'
|
||||
feed_content = '<entry>contents</entry>'
|
||||
allow(service).to receive(:call).with(url).and_return([feed_url, feed_content])
|
||||
allow(service).to receive(:call).with(url).and_return([feed_url, { prefetched_body: feed_content }])
|
||||
|
||||
account_service = double
|
||||
allow(FetchRemoteStatusService).to receive(:new).and_return(account_service)
|
||||
|
@@ -16,7 +16,7 @@ RSpec.describe PrecomputeFeedService do
|
||||
|
||||
subject.call(account)
|
||||
|
||||
expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq status.id
|
||||
expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq status.id.to_f
|
||||
end
|
||||
|
||||
it 'does not raise an error even if it could not find any status' do
|
||||
|
Reference in New Issue
Block a user