add tests for early returning, fix tests to put root status outside of debounce window

This commit is contained in:
sneakers-the-rat 2024-12-02 19:48:13 -08:00 committed by Jonny Saunders
parent d97b1800b2
commit 63ed1ddd15

View File

@ -113,7 +113,14 @@ RSpec.describe ActivityPub::FetchAllRepliesWorker do
end
let(:account) { Fabricate(:account, domain: 'example.com') }
let(:status) { Fabricate(:status, account: account, uri: top_note_uri) }
let(:status) do
Fabricate(
:status,
account: account,
uri: top_note_uri,
created_at: 1.day.ago - Status::FetchRepliesConcern::CREATED_RECENTLY_DEBOUNCE
)
end
before do
allow(FetchReplyWorker).to receive(:push_bulk)
@ -254,5 +261,27 @@ RSpec.describe ActivityPub::FetchAllRepliesWorker do
expect(got_uris).to match_array(top_items + top_items_paged + nested_items)
end
end
context 'when replies should not be fetched' do
# ensure that we should not fetch by setting the status to be created in the debounce window
let(:status) do
Fabricate(
:status,
account: account,
uri: top_note_uri,
created_at: DateTime.now
)
end
before do
stub_const('Status::FetchRepliesConcern::CREATED_RECENTLY_DEBOUNCE', 1.week)
end
it 'returns nil without fetching' do
got_uris = subject.perform(status.id)
expect(got_uris).to be_nil
assert_not_requested :get, top_note_uri
end
end
end
end