enqueue user page job if no avatar uri is found
This commit is contained in:
@@ -21,7 +21,13 @@ class Domain::Fa::Job::UserAvatarJob < Domain::Fa::Job::Base
|
||||
|
||||
unless @avatar.file_uri
|
||||
# try to find a corresponding log entry
|
||||
log_entry = @avatar.guess_user_page_log_entry || raise("no user page log entry found")
|
||||
log_entry = @avatar.guess_user_page_log_entry || begin
|
||||
Domain::Fa::Job::UserPageJob.perform_later({
|
||||
user: @user,
|
||||
caused_by_entry: @caused_by_entry,
|
||||
})
|
||||
raise("no user page log entry found, enqueued user page scan")
|
||||
end
|
||||
@caused_by_entry ||= log_entry
|
||||
parser = Domain::Fa::Parser::Page.new(log_entry.response.contents, require_logged_in: false)
|
||||
@avatar.state_detail["guessed_log_entry_id"] = log_entry.id
|
||||
|
||||
@@ -62,6 +62,21 @@ describe Domain::Fa::Job::UserAvatarJob do
|
||||
expect(avatar).to eq(avatar2)
|
||||
end
|
||||
end
|
||||
|
||||
context "the user has not been page scanned yet" do
|
||||
it "enqueues a user page scan job" do
|
||||
ret = described_class.perform_now({ user: user })
|
||||
expect(ret).to be_a(Exception)
|
||||
expect(ret.message).to match(/no user page log entry/)
|
||||
expect(user.avatar.file_uri).to eq(nil)
|
||||
expect(SpecUtil.enqueued_jobs(Domain::Fa::Job::UserPageJob)).to match([
|
||||
including(args: [{
|
||||
user: user,
|
||||
caused_by_entry: "nil",
|
||||
}]),
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "the avatar model exists with a file uri" do
|
||||
|
||||
Reference in New Issue
Block a user