Add bearcaps test
This commit is contained in:
parent
910621e86f
commit
a908f171e7
1 changed files with 49 additions and 0 deletions
|
@ -1188,5 +1188,54 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
expect(sender.statuses.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'when bearcaps' do
|
||||
subject { described_class.new(json, sender) }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/statuses/1234567890')
|
||||
.with(headers: { 'Authorization' => 'Bearer test_ohagi_token' })
|
||||
.to_return(status: 200, body: Oj.dump(object_json), headers: {})
|
||||
|
||||
subject.perform
|
||||
end
|
||||
|
||||
let!(:recipient) { Fabricate(:account) }
|
||||
let(:object_json) do
|
||||
{
|
||||
id: 'https://example.com/statuses/1234567890',
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
to: ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
attachment: [
|
||||
{
|
||||
type: 'Document',
|
||||
mediaType: 'image/png',
|
||||
url: 'http://example.com/attachment.png',
|
||||
},
|
||||
],
|
||||
}
|
||||
end
|
||||
let(:json) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'Create',
|
||||
actor: ActivityPub::TagManager.instance.uri_for(sender),
|
||||
object: "bear:?#{{ u: 'https://example.com/statuses/1234567890', t: 'test_ohagi_token' }.to_query}",
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.text).to eq 'Lorem ipsum'
|
||||
expect(status.mentions.map(&:account)).to include(recipient)
|
||||
expect(status.mentions.count).to eq 1
|
||||
expect(status.visibility).to eq 'limited'
|
||||
expect(status.media_attachments.map(&:remote_url)).to include('http://example.com/attachment.png')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue