diff --git a/app/jobs/regular/pull_user_profile_hotlinked_images.rb b/app/jobs/regular/pull_user_profile_hotlinked_images.rb index 66280f2f7eb..22c7b21e9dc 100644 --- a/app/jobs/regular/pull_user_profile_hotlinked_images.rb +++ b/app/jobs/regular/pull_user_profile_hotlinked_images.rb @@ -7,7 +7,7 @@ module Jobs raise Discourse::InvalidParameters.new(:user_id) if @user_id.blank? user_profile = UserProfile.find_by(user_id: @user_id) - return if user_profile.blank? + return if user_profile.blank? || user_profile.bio_cooked.nil? large_image_urls = [] broken_image_urls = [] diff --git a/spec/jobs/pull_user_profile_hotlinked_images_spec.rb b/spec/jobs/pull_user_profile_hotlinked_images_spec.rb index a0605978a61..748709e35d0 100644 --- a/spec/jobs/pull_user_profile_hotlinked_images_spec.rb +++ b/spec/jobs/pull_user_profile_hotlinked_images_spec.rb @@ -21,5 +21,10 @@ describe Jobs::PullUserProfileHotlinkedImages do expect { Jobs::PullUserProfileHotlinkedImages.new.execute(user_id: user.id) }.to change { Upload.count }.by(1) expect(user.user_profile.reload.bio_cooked).to include(Upload.last.url) end + + it 'handles nil bio' do + expect { Jobs::PullUserProfileHotlinkedImages.new.execute(user_id: user.id) }.to change { Upload.count }.by(0) + expect(user.user_profile.reload.bio_cooked).to eq(nil) + end end end