diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-05-17 14:52:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 14:52:26 +0200 |
commit | e0bdaeab657d9a320aaf506d98ca82d41e7bfdd5 (patch) | |
tree | b53a50b162b46b1e9179bf2e49299a452544d115 /spec/services/resolve_url_service_spec.rb | |
parent | c78a622ba4bd7fce511e5f079dd6b8deb17f9cef (diff) |
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
Diffstat (limited to 'spec/services/resolve_url_service_spec.rb')
-rw-r--r-- | spec/services/resolve_url_service_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/services/resolve_url_service_spec.rb b/spec/services/resolve_url_service_spec.rb index 1b639dea9..b3e3defbf 100644 --- a/spec/services/resolve_url_service_spec.rb +++ b/spec/services/resolve_url_service_spec.rb @@ -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 |