Fix NoMethodError when resolving a link that redirects to a local post (#18314)

* Fix NoMethodError when resolving a link that redirects to a local post

* Fix tests
This commit is contained in:
Claire 2022-05-17 14:52:26 +02:00 committed by GitHub
parent c78a622ba4
commit e0bdaeab65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 24 deletions

View file

@ -126,5 +126,24 @@ describe ResolveURLService, type: :service do
end
end
end
context 'searching for a link that redirects to a local public status' do
let(:account) { Fabricate(:account) }
let(:poster) { Fabricate(:account) }
let!(:status) { Fabricate(:status, account: poster, visibility: :public) }
let(:url) { 'https://link.to/foobar' }
let(:status_url) { ActivityPub::TagManager.instance.url_for(status) }
let(:uri) { ActivityPub::TagManager.instance.uri_for(status) }
before do
stub_request(:get, url).to_return(status: 302, headers: { 'Location' => status_url })
body = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter).to_json
stub_request(:get, status_url).to_return(body: body, headers: { 'Content-Type' => 'application/activity+json' })
end
it 'returns status by url' do
expect(subject.call(url, on_behalf_of: account)).to eq(status)
end
end
end
end