diaspora/spec/workers/fetch_webfinger_spec.rb
Thorsten Claus 8691e650dc
Person.find_or_fetch_by_identifier never return nil
Person.find_or_fetch_by_identifier raises an exception if person is not found localy and not fetchable. It never returns nil. These code changes take care about this behaviour and changes specs and code to behave equally.

Also related to #8253
2021-08-16 00:24:33 +02:00

20 lines
760 B
Ruby

# frozen_string_literal: true
describe Workers::FetchWebfinger do
it "should webfinger and queue a job to fetch public posts" do
@person = FactoryGirl.create(:person)
allow(Person).to receive(:find_or_fetch_by_identifier).and_return(@person)
expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times
Workers::FetchWebfinger.new.perform(@person.diaspora_handle)
end
it "should webfinger and queue no job to fetch public posts if the person is not found" do
allow(Person).to receive(:find_or_fetch_by_identifier).and_raise DiasporaFederation::Discovery::DiscoveryError
expect(Diaspora::Fetcher::Public).not_to receive(:queue_for)
Workers::FetchWebfinger.new.perform("unknown-person@example.net")
end
end