2017-08-08 19:52:15 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe ActivityPub::FetchRemoteStatusService do
|
2017-11-30 03:06:20 +00:00
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
|
2017-08-24 14:21:42 +00:00
|
|
|
let(:sender) { Fabricate(:account) }
|
|
|
|
let(:recipient) { Fabricate(:account) }
|
|
|
|
let(:valid_domain) { Rails.configuration.x.local_domain }
|
|
|
|
|
|
|
|
let(:note) do
|
|
|
|
{
|
|
|
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
|
|
id: "https://#{valid_domain}/@foo/1234",
|
|
|
|
type: 'Note',
|
|
|
|
content: 'Lorem ipsum',
|
|
|
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
describe '#call' do
|
|
|
|
before do
|
2018-01-08 04:00:23 +00:00
|
|
|
sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender))
|
|
|
|
|
2017-11-30 03:06:20 +00:00
|
|
|
stub_request(:head, 'https://example.com/watch?v=12345').to_return(status: 404, body: '')
|
2017-10-03 23:13:48 +00:00
|
|
|
subject.call(object[:id], prefetched_body: Oj.dump(object))
|
2017-08-24 14:21:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with Note object' do
|
|
|
|
let(:object) { note }
|
|
|
|
|
|
|
|
it 'creates status' do
|
|
|
|
status = sender.statuses.first
|
2017-11-17 01:52:30 +00:00
|
|
|
|
2017-08-24 14:21:42 +00:00
|
|
|
expect(status).to_not be_nil
|
|
|
|
expect(status.text).to eq 'Lorem ipsum'
|
|
|
|
end
|
|
|
|
end
|
2017-11-30 03:06:20 +00:00
|
|
|
|
|
|
|
context 'with Video object' do
|
|
|
|
let(:object) do
|
|
|
|
{
|
|
|
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
|
|
id: "https://#{valid_domain}/@foo/1234",
|
|
|
|
type: 'Video',
|
|
|
|
name: 'Nyan Cat 10 hours remix',
|
|
|
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
|
|
|
url: [
|
|
|
|
{
|
|
|
|
type: 'Link',
|
|
|
|
mimeType: 'application/x-bittorrent',
|
2018-01-08 04:00:23 +00:00
|
|
|
href: "https://#{valid_domain}/12345.torrent",
|
2017-11-30 03:06:20 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
type: 'Link',
|
|
|
|
mimeType: 'text/html',
|
2018-01-08 04:00:23 +00:00
|
|
|
href: "https://#{valid_domain}/watch?v=12345",
|
2017-11-30 03:06:20 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates status' do
|
|
|
|
status = sender.statuses.first
|
|
|
|
|
|
|
|
expect(status).to_not be_nil
|
2018-01-08 04:00:23 +00:00
|
|
|
expect(status.url).to eq "https://#{valid_domain}/watch?v=12345"
|
|
|
|
expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remix https://#{valid_domain}/watch?v=12345"
|
2017-11-30 03:06:20 +00:00
|
|
|
end
|
|
|
|
end
|
2017-08-24 14:21:42 +00:00
|
|
|
end
|
2017-08-08 19:52:15 +00:00
|
|
|
end
|