Fix rspec at least services
This commit is contained in:
parent
27391f1bc7
commit
1ecb577a8a
5 changed files with 21 additions and 4 deletions
|
@ -39,10 +39,13 @@ class UpdateStatusService < BaseService
|
|||
|
||||
queue_poll_notifications!
|
||||
reset_preview_card!
|
||||
update_references!
|
||||
update_metadata!
|
||||
update_references!
|
||||
broadcast_updates!
|
||||
|
||||
# Mentions are not updated (Cause unknown)
|
||||
@status.reload
|
||||
|
||||
@status
|
||||
rescue NoChangesSubmittedError
|
||||
# For calls that result in no changes, swallow the error
|
||||
|
@ -164,7 +167,6 @@ class UpdateStatusService < BaseService
|
|||
def update_metadata!
|
||||
ProcessHashtagsService.new.call(@status)
|
||||
ProcessMentionsService.new.call(@status)
|
||||
ProcessReferencesWorker.perform_async(@status.id, (@options[:status_reference_ids] || []).map(&:to_i).filter(&:positive?), [])
|
||||
end
|
||||
|
||||
def broadcast_updates!
|
||||
|
|
|
@ -46,6 +46,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
|||
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
it 'fetches resource' do
|
||||
|
@ -69,6 +70,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
|||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
it 'fetches resource' do
|
||||
|
@ -96,6 +98,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
|||
stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
it 'fetches resource' do
|
||||
|
@ -127,6 +130,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
|||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
it 'fetches resource' do
|
||||
|
@ -151,6 +155,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
|||
stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
it 'fetches resource' do
|
||||
|
|
|
@ -52,7 +52,7 @@ RSpec.describe ActivityPub::FetchRemoteKeyService, type: :service do
|
|||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
|
||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '[]')
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
describe '#call' do
|
||||
|
|
|
@ -19,6 +19,10 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
it 'parses out of attachment' do
|
||||
account = subject.call('alice', 'example.com', payload)
|
||||
expect(account.fields).to be_a Array
|
||||
|
@ -127,6 +131,9 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
|
||||
before do
|
||||
stub_const 'ActivityPub::ProcessAccountService::SUBDOMAINS_RATELIMIT', 5
|
||||
8.times do |i|
|
||||
stub_request(:get, "https://test#{i}.testdomain.com/.well-known/nodeinfo").to_return(body: '{}')
|
||||
end
|
||||
end
|
||||
|
||||
it 'creates at least some accounts' do
|
||||
|
@ -192,6 +199,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
|||
stub_request(:get, "https://foo.test/users/#{i}/featured").to_return(status: 200, body: featured_json.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, "https://foo.test/users/#{i}/status").to_return(status: 200, body: status_json.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, "https://foo.test/.well-known/webfinger?resource=acct:user#{i}@foo.test").to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://foo.test/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe ResolveAccountService, type: :service do
|
|||
stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(status: 404)
|
||||
stub_request(:get, 'https://quitter.no/avatar/7477-300-20160211190340.png').to_return(request_fixture('avatar.txt'))
|
||||
stub_request(:get, 'https://ap.example.com/.well-known/webfinger?resource=acct:foo@ap.example.com').to_return(request_fixture('activitypub-webfinger.txt'))
|
||||
stub_request(:get, 'https://ap.example.com/.well-known/nodeinfo').to_return('{}')
|
||||
stub_request(:get, 'https://ap.example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
stub_request(:get, 'https://ap.example.com/users/foo').to_return(request_fixture('activitypub-actor.txt'))
|
||||
stub_request(:get, 'https://ap.example.com/users/foo.atom').to_return(request_fixture('activitypub-feed.txt'))
|
||||
stub_request(:get, %r{https://ap\.example\.com/users/foo/\w+}).to_return(status: 404)
|
||||
|
@ -137,8 +137,10 @@ RSpec.describe ResolveAccountService, type: :service do
|
|||
before do
|
||||
webfinger = { subject: 'acct:foo@evil.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
||||
stub_request(:get, 'https://redirected.example.com/.well-known/webfinger?resource=acct:Foo@redirected.example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://redirected.example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
webfinger2 = { subject: 'acct:foo@ap.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
||||
stub_request(:get, 'https://evil.example.com/.well-known/webfinger?resource=acct:foo@evil.example.com').to_return(body: Oj.dump(webfinger2), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://evil.example.com/.well-known/nodeinfo').to_return(body: '{}')
|
||||
end
|
||||
|
||||
it 'does not return a new remote account' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue