* Fix: #284 `FetchInstanceInfoWorker`が原因でSidekiqのJobが詰まる問題 * Fix: InstanceInfoを取得するタイミング * Fix test * Fix test * Fix: HTTPコード * 調整
This commit is contained in:
parent
903b9ad347
commit
5173481ab7
8 changed files with 44 additions and 58 deletions
|
@ -67,9 +67,22 @@ describe ActivityPub::FetchInstanceInfoWorker do
|
|||
Instance.refresh
|
||||
end
|
||||
|
||||
it 'does not update immediately' do
|
||||
stub_request(:get, 'https://example.com/nodeinfo/2.0').to_return(status: 200, body: nodeinfo_json)
|
||||
subject.perform('example.com')
|
||||
stub_request(:get, 'https://example.com/nodeinfo/2.0').to_return(status: 200, body: new_nodeinfo_json)
|
||||
subject.perform('example.com')
|
||||
|
||||
info = InstanceInfo.find_by(domain: 'example.com')
|
||||
expect(info).to_not be_nil
|
||||
expect(info.software).to eq 'mastodon'
|
||||
expect(info.version).to eq '4.2.0-beta1'
|
||||
end
|
||||
|
||||
it 'performs a mastodon instance' do
|
||||
stub_request(:get, 'https://example.com/nodeinfo/2.0').to_return(status: 200, body: nodeinfo_json)
|
||||
subject.perform('example.com')
|
||||
Rails.cache.delete('fetch_instance_info:example.com')
|
||||
stub_request(:get, 'https://example.com/nodeinfo/2.0').to_return(status: 200, body: new_nodeinfo_json)
|
||||
subject.perform('example.com')
|
||||
|
||||
|
@ -93,5 +106,12 @@ describe ActivityPub::FetchInstanceInfoWorker do
|
|||
info = InstanceInfo.find_by(domain: 'example.com')
|
||||
expect(info).to be_nil
|
||||
end
|
||||
|
||||
it 'does not fetch again immediately' do
|
||||
expect(subject.perform('example.com')).to be true
|
||||
expect(subject.perform('example.com')).to be true
|
||||
|
||||
expect(a_request(:get, 'https://example.com/.well-known/nodeinfo')).to have_been_made.once
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue