* Fix: #284 `FetchInstanceInfoWorker`が原因でSidekiqのJobが詰まる問題 * Fix: InstanceInfoを取得するタイミング * Fix test * Fix test * Fix: HTTPコード * 調整
This commit is contained in:
parent
94070aa41e
commit
bea82f2279
8 changed files with 44 additions and 58 deletions
|
@ -55,6 +55,7 @@ RSpec.describe ActivityPub::Activity::Update do
|
|||
stub_request(:get, actor_json[:following]).to_return(status: 404)
|
||||
stub_request(:get, actor_json[:featured]).to_return(status: 404)
|
||||
stub_request(:get, actor_json[:featuredTags]).to_return(status: 404)
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(status: 404)
|
||||
|
||||
subject.perform
|
||||
end
|
||||
|
|
|
@ -5,6 +5,10 @@ require 'rails_helper'
|
|||
RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(status: 404)
|
||||
end
|
||||
|
||||
context 'with searchability' do
|
||||
subject { described_class.new.call('alice', 'example.com', payload) }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Scheduler::UpdateInstanceInfoScheduler do
|
||||
let(:worker) { described_class.new }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(status: 200, body: '{}')
|
||||
Fabricate(:account, domain: 'example.com')
|
||||
Instance.refresh
|
||||
end
|
||||
|
||||
describe 'perform' do
|
||||
it 'runs without error' do
|
||||
expect { worker.perform }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue